public class MyList<AnyType> extends java.lang.Object implements SimpleList<AnyType>, SimpleQueue<AnyType>
Constructor and Description |
---|
MyList() |
Modifier and Type | Method and Description |
---|---|
boolean |
add(AnyType value)
Inserts a value at the end of the list.
|
AnyType |
dequeue()
Retrieves and removes the first element of the queue
|
void |
enqueue(AnyType value)
Inserts a value at the end of the queue
|
boolean |
isEmpty()
Determine whether the list is empty.
|
java.util.Iterator<AnyType> |
iterator()
Returns an Iterator object that iterates over the elements in this list
in proper sequence.
|
static void |
main(java.lang.String[] args) |
AnyType |
peek()
Retrieves, but does not rempve, the first element of the queue
|
boolean |
remove(AnyType value)
Removes the first element of the list that is equal to value
|
java.lang.String |
toString()
Returns a string representation of this linked list
|
public boolean isEmpty()
isEmpty
in interface SimpleList<AnyType>
isEmpty
in interface SimpleQueue<AnyType>
public boolean add(AnyType value)
add
in interface SimpleList<AnyType>
value
- the element to be inserted into the listpublic boolean remove(AnyType value)
remove
in interface SimpleList<AnyType>
value
- the object to removepublic void enqueue(AnyType value)
enqueue
in interface SimpleQueue<AnyType>
value
- the element to be inserted into the queuepublic AnyType dequeue()
dequeue
in interface SimpleQueue<AnyType>
public AnyType peek()
peek
in interface SimpleQueue<AnyType>
public java.util.Iterator<AnyType> iterator()
iterator
in interface java.lang.Iterable<AnyType>
public java.lang.String toString()
toString
in class java.lang.Object
public static void main(java.lang.String[] args)