edu.rice.comp211.laundry.list
Class BiList.BiIterator

java.lang.Object
  extended by edu.rice.comp211.laundry.list.BiList.BiIterator
All Implemented Interfaces:
BiIteratorI<T>, IteratorI<T>, ReadIteratorI<T>
Enclosing class:
BiList<T>

private class BiList.BiIterator
extends java.lang.Object
implements BiIteratorI<T>

A class used to generate iterators for this list. A genuine named inner class that includes a link (BiList.this) to the enclosing BiList.


Field Summary
(package private)  BiList.Node<T> current
          The current node the iterator is pointing to
 
Constructor Summary
BiList.BiIterator()
          Constructor for the class Initializes the current node to reference the front of the list
 
Method Summary
 boolean atEnd()
           
 boolean atStart()
          Returns true if BiList is non-empty and current is the first node in the list.
 T currentItem()
           
 void first()
          Moves cursor to first element of the collection.
 void insert(T o)
          Destructively inserts the object o immediately before the current item.
 void last()
          Puts the cursor on the last element of the collection.
 void next()
          Moves cursor to next element of the collection.
 void prev()
          Puts the cursor on the previous element of the collection.
 T remove()
          Removes the current element e.
 
Methods inherited from class java.lang.Object
clone, equals, finalize, getClass, hashCode, notify, notifyAll, toString, wait, wait, wait
 

Field Detail

current

BiList.Node<T> current
The current node the iterator is pointing to

Constructor Detail

BiList.BiIterator

BiList.BiIterator()
Constructor for the class Initializes the current node to reference the front of the list

Method Detail

first

public void first()
Description copied from interface: ReadIteratorI
Moves cursor to first element of the collection. Places the cursor on dummy element if collection is empty.

Specified by:
first in interface ReadIteratorI<T>

last

public void last()
Description copied from interface: BiIteratorI
Puts the cursor on the last element of the collection. Unspecified behavior if the collection is empty.

Specified by:
last in interface BiIteratorI<T>

next

public void next()
Description copied from interface: ReadIteratorI
Moves cursor to next element of the collection. If current is the last element (atLast() == true) on entry, moves cursor to dummy element following the last element.

Specified by:
next in interface ReadIteratorI<T>

prev

public void prev()
Description copied from interface: BiIteratorI
Puts the cursor on the previous element of the collection. Unspecified behavior if the collection is empty.

Specified by:
prev in interface BiIteratorI<T>

currentItem

public T currentItem()
Specified by:
currentItem in interface ReadIteratorI<T>
Returns:
the current element (pointed to by the cursor).

atEnd

public boolean atEnd()
Specified by:
atEnd in interface ReadIteratorI<T>
Returns:
true if the cursor is pointing to dummy element following the collection.

atStart

public boolean atStart()
Returns true if BiList is non-empty and current is the first node in the list.

Specified by:
atStart in interface ReadIteratorI<T>
Returns:
true if the cursor is pointing to the first element of the collection. atEnd() => ! atStart().

insert

public void insert(T o)
Description copied from interface: IteratorI
Destructively inserts the object o immediately before the current item. If the list is empty, or the cursor is atEnd(), the node is inserted immediately before the dummy node of the list.

Specified by:
insert in interface IteratorI<T>

remove

public T remove()
Description copied from interface: IteratorI
Removes the current element e.

Specified by:
remove in interface IteratorI<T>
Returns:
the removed element e.