|
||||||||
PREV CLASS NEXT CLASS | FRAMES NO FRAMES | |||||||
SUMMARY: NESTED | FIELD | CONSTR | METHOD | DETAIL: FIELD | CONSTR | METHOD |
java.lang.Objectstructure.AbstractStructure
structure.OrderedList
public class OrderedList
A class that implements a collection of values that are kept in order. Base values must be comparable. Unlike Lists there is no notion of head or tail.
Field Summary | |
---|---|
protected int |
count
Number of elements in list |
protected Node |
data
Pointer to the smallest element, maintained as a singly linked list |
protected java.util.Comparator |
ordering
The ordereding used to arange the values |
Constructor Summary | |
---|---|
OrderedList()
Construct an empty ordered list |
|
OrderedList(java.util.Comparator ordering)
Construct an empty ordered list with alternative ordering |
Method Summary | |
---|---|
void |
add(java.lang.Object value)
Add a value to the ordered list, keeping values in order |
void |
clear()
Remove all the elements from the ordered list |
boolean |
contains(java.lang.Object value)
Determine if the ordered list contains a value |
boolean |
isEmpty()
Determine if the list is empty |
java.util.Iterator |
iterator()
Construct an iterator for traversing elements of ordered list in ascending order |
java.lang.Object |
remove(java.lang.Object value)
Remove a value from the ordered list. |
int |
size()
Determine the number of elements in the list |
java.lang.String |
toString()
Generate string representation of the ordered list |
Methods inherited from class structure.AbstractStructure |
---|
elements, hashCode, values |
Methods inherited from class java.lang.Object |
---|
clone, equals, finalize, getClass, notify, notifyAll, wait, wait, wait |
Methods inherited from interface structure.Structure |
---|
elements, values |
Field Detail |
---|
protected Node data
protected int count
protected java.util.Comparator ordering
Constructor Detail |
---|
public OrderedList()
public OrderedList(java.util.Comparator ordering)
ordering
- the Comparator to be used in comparisonMethod Detail |
---|
public void clear()
clear
in interface Structure
public void add(java.lang.Object value)
add
in interface Structure
value
- The value to be added to the listpublic boolean contains(java.lang.Object value)
contains
in interface Structure
contains
in class AbstractStructure
value
- The value sought in the list
public java.lang.Object remove(java.lang.Object value)
remove
in interface Structure
value
- The value to be removed
public int size()
size
in interface Structure
public boolean isEmpty()
isEmpty
in interface Structure
isEmpty
in class AbstractStructure
public java.util.Iterator iterator()
iterator
in interface Structure
AbstractIterator
,
Iterator
,
Enumeration
,
Structure.elements()
public java.lang.String toString()
toString
in class java.lang.Object
|
||||||||
PREV CLASS NEXT CLASS | FRAMES NO FRAMES | |||||||
SUMMARY: NESTED | FIELD | CONSTR | METHOD | DETAIL: FIELD | CONSTR | METHOD |