All Packages Class Hierarchy This Package Previous Next Index
Class jdsl.simple.ref.MyDeque
java.lang.Object
|
+----jdsl.simple.ref.MyDeque
- public class MyDeque
- extends Object
- implements Deque
This is the implementation of the Deque interface Dbmy means of a doubly-
linked list. Note that this class uses class DLNode, which is the node that
stores the previos and next nodes in the list, and a reference to its
element.
- Version:
- Thu Aug 21 20:24:01 1997
- Author:
- Natasha Gelfand
-
MyDeque()
-
-
first()
-
Inspect the first element without modifying the deque.
-
insertFirst(Object)
-
Add an element at the front of the sequence.
-
insertLast(Object)
-
Add an element at the back of the sequence.
-
isEmpty()
-
This function returns true if and only if the deque is empty
-
last()
-
Inspect the last element without modifying the deque.
-
removeFirst()
-
Delete the element at the front of the sequence.
-
removeLast()
-
Delete the element at the back of the sequence.
-
size()
-
Return the size of the deque, that is the number of elements it has.
MyDeque
public MyDeque()
size
public int size()
- Return the size of the deque, that is the number of elements it has.
- Returns:
- Number of elements in the deque
isEmpty
public boolean isEmpty()
- This function returns true if and only if the deque is empty
- Returns:
- true if the deque is empty, false otherwise
first
public Object first() throws DequeEmptyException
- Inspect the first element without modifying the deque.
- Returns:
- The first element in the sequence
last
public Object last() throws DequeEmptyException
- Inspect the last element without modifying the deque.
- Returns:
- The last element in the sequence
insertFirst
public void insertFirst(Object o)
- Add an element at the front of the sequence.
- Parameters:
- element - New element for the front of the deque
insertLast
public void insertLast(Object o)
- Add an element at the back of the sequence.
- Parameters:
- element - New element for the back of the deque
removeFirst
public Object removeFirst() throws DequeEmptyException
- Delete the element at the front of the sequence.
- Returns:
- The element formerly known as "first()"
removeLast
public Object removeLast() throws DequeEmptyException
- Delete the element at the back of the sequence.
- Returns:
- The element formerly known as "last()"
All Packages Class Hierarchy This Package Previous Next Index