All Packages  Class Hierarchy  This Package  Previous  Next  Index  

Class structure.CircularList

java.lang.Object
    |
    +----structure.CircularList

public class CircularList
extends Object
implements List
A class implementing a singly linked circular list.


Constructor Index

 o CircularList()
Construct an empty circular list.

Method Index

 o add(Object)
Add an element to the head of the circular list.
 o addToHead(Object)
Add an element to the head of the list.
 o addToTail(Object)
Add a value to the tail of the circular list.
 o clear()
Remove the elements of the list.
 o contains(Object)
Check if a list contains an element.
 o elements()
Construct an iterator over the elements of the list.
 o isEmpty()
Determine if a list is empty.
 o peek()
Determine if a list is empty.
 o remove(Object)
Remove a value from a list.
 o removeFromHead()
Remove a value from the head of the list.
 o removeFromTail()
Remove a value from the tail of the list.
 o size()
Determine the size of the list.
 o tailPeek()
Peek at the last element of the list.
 o toString()
Generate a string representation of the list.

Constructors

 o CircularList
public CircularList()
Construct an empty circular list.

Precondition:
constructs a new circular list

Methods

 o add
public void add(Object value)
Add an element to the head of the circular list.

Postcondition:
adds value to beginning of list.

Parameters:
value - The value to be added to the list.
 o addToHead
public void addToHead(Object value)
Add an element to the head of the list.

Precondition:
value non-null
Postcondition:
adds element to head of list

Parameters:
value - The value added to the head of the list.
 o addToTail
public void addToTail(Object value)
Add a value to the tail of the circular list.

Precondition:
value non-null
Postcondition:
adds element to tail of list

Parameters:
value - The value to be added.
 o peek
public Object peek()
Determine if a list is empty.

Precondition:
!isEmpty()
Postcondition:
returns value at head of list

Returns:
True if there are no elements within the list.
 o tailPeek
public Object tailPeek()
Peek at the last element of the list.

Precondition:
!isEmpty()
Postcondition:
returns value at tail of list

Returns:
The value of the last element of the list.
 o removeFromHead
public Object removeFromHead()
Remove a value from the head of the list.

Precondition:
!isEmpty()
Postcondition:
returns and removes value from head of list

Returns:
The value removed.
 o removeFromTail
public Object removeFromTail()
Remove a value from the tail of the list.

Precondition:
!isEmpty()
Postcondition:
returns and removes value from tail of list

Returns:
The value removed.
 o contains
public boolean contains(Object value)
Check if a list contains an element.

Precondition:
value != null
Postcondition:
returns true if list contains value, else false

Parameters:
value - The value sought.
Returns:
True iff the value is within the list.
 o remove
public Object remove(Object value)
Remove a value from a list.

Precondition:
value != null
Postcondition:
removes and returns element equal to value, or null

Parameters:
value - The value sought.
Returns:
The value removed from the list.
 o size
public int size()
Determine the size of the list.

Postcondition:
returns number of elements in list

Returns:
The number of elements in list.
 o elements
public Iterator elements()
Construct an iterator over the elements of the list. Elements are traversed from head to tail.

Postcondition:
returns iterator to traverse list elements.

Returns:
The iterator associated with the list.
 o isEmpty
public boolean isEmpty()
Determine if a list is empty.

Postcondition:
returns true if no elements in list

Returns:
True iff the list is empty.
 o clear
public void clear()
Remove the elements of the list.

Postcondition:
removes all elements from list.

 o toString
public String toString()
Generate a string representation of the list.

Postcondition:
returns a string representing list

Returns:
String representing the list.
Overrides:
toString in class Object

All Packages  Class Hierarchy  This Package  Previous  Next  Index