edu.rice.comp211.laundry.list
Class BiList<T>

java.lang.Object
  extended by edu.rice.comp211.laundry.list.BiList<T>
All Implemented Interfaces:
BiListI<T>, EnumI<T>, ListI<T>
Direct Known Subclasses:
SyncBiList

public class BiList<T>
extends Object
implements BiListI<T>

A circularly linked class implementing the BiListI interface.


Constructor Summary
BiList()
           
 
Method Summary
<R> R
accept(BiListIVisitor<T,R> visitor)
           
 boolean equals(Object other)
          Returns true if all elements in this list and the given list are equal.
 BiList<T> insertFront(T o)
          Inserts the given value at the front of the list
 BiList<T> insertRear(T o)
          Insert the given value at the end of the list
 boolean isEmpty()
          Test if this enumeration is empty
 int length()
          Returns the number of elements in the list
 BiIteratorI<T> newIterator()
          Factory method that creates an iterator initialized to point at the start of the list.
 BiListI<T> newList()
          Factory method for a new, empty list that holds the same type of elements as this list.
 T remFront()
          Removes the first element of the list
 T remRear()
          Remove the last element in the list
 String toString()
           
 
Methods inherited from class java.lang.Object
clone, finalize, getClass, hashCode, notify, notifyAll, wait, wait, wait
 

Constructor Detail

BiList

public BiList()
Method Detail

toString

public String toString()
Overrides:
toString in class Object

isEmpty

public boolean isEmpty()
Description copied from interface: EnumI
Test if this enumeration is empty

Specified by:
isEmpty in interface EnumI<T>
Returns:
true if this enumeration is empty.

accept

public <R> R accept(BiListIVisitor<T,R> visitor)
Specified by:
accept in interface BiListI<T>

newList

public BiListI<T> newList()
Factory method for a new, empty list that holds the same type of elements as this list.

Specified by:
newList in interface BiListI<T>
Specified by:
newList in interface ListI<T>
Returns:
a new BiList<T>

length

public int length()
Returns the number of elements in the list

Specified by:
length in interface ListI<T>
Returns:
the number of elements in the list

insertFront

public BiList<T> insertFront(T o)
Inserts the given value at the front of the list

Specified by:
insertFront in interface ListI<T>
Parameters:
o - the new element to insert
Returns:
a reference to this list.

insertRear

public BiList<T> insertRear(T o)
Insert the given value at the end of the list

Specified by:
insertRear in interface ListI<T>
Parameters:
o - the new element to insert
Returns:
a reference to this list

remFront

public T remFront()
Removes the first element of the list

Specified by:
remFront in interface ListI<T>
Returns:
the element that was removed.
Throws:
IllegalState - exception if list is empty

newIterator

public BiIteratorI<T> newIterator()
Factory method that creates an iterator initialized to point at the start of the list. Virtual constructors for iterators; identical except for return type

Specified by:
newIterator in interface BiListI<T>
Specified by:
newIterator in interface EnumI<T>
Specified by:
newIterator in interface ListI<T>
Returns:
a BiIteratorI<T> interator

remRear

public T remRear()
Remove the last element in the list

Specified by:
remRear in interface BiListI<T>
Returns:
the element that was removed
Throws:
IllegalStateException - if the list is empty.

equals

public boolean equals(Object other)
Returns true if all elements in this list and the given list are equal.

Overrides:
equals in class Object
Parameters:
o - the other list
Returns:
true if all elements are equal, false otherwise.