Class Sequence
java.lang.Object
|
+--Sequence
- public class Sequence
- extends java.lang.Object
A sequence. This is implemented using a double-linked list with
locators which means that most operations run in time O(1).
Created: Fri Mar 31 09:33:27 2000
Constructor Summary |
Sequence()
Constructs an empty sequence. |
Method Summary |
java.util.Enumeration |
elements()
Makes an Enumeration of all the elements of the sequence. |
Locator |
insertLast(java.lang.Object o)
Inserts an object at the last posistion of the sequence. |
void |
remove(Locator l)
Removes an element from the sequence given that elemnts
locator. |
java.lang.Object |
removeLast()
Removes the last element in the sequence. |
int |
size()
|
java.lang.String |
toString()
Make a string representation of the sequence. |
Methods inherited from class java.lang.Object |
clone, equals, finalize, getClass, hashCode, notify, notifyAll, wait, wait, wait |
Sequence
public Sequence()
- Constructs an empty sequence. O(1)
size
public int size()
insertLast
public Locator insertLast(java.lang.Object o)
- Inserts an object at the last posistion of the sequence.
O(1).
- Parameters:
o
- the object to be insterted.
removeLast
public java.lang.Object removeLast()
- Removes the last element in the sequence.
- Returns:
- the last element in the sequence.
- Throws:
java.util.NoSuchElementException
- if the sequence is empty.
remove
public void remove(Locator l)
- Removes an element from the sequence given that elemnts
locator. O(1).
- Parameters:
l
- The locator of the element to be removed.
toString
public java.lang.String toString()
- Make a string representation of the sequence. It is just the
string representation of all the elements.
- Overrides:
toString
in class java.lang.Object
- Returns:
- the constructed string.
elements
public java.util.Enumeration elements()
- Makes an Enumeration of all the elements of the sequence. This
method uses O(1) time and so does all of the
methods of the constructed Enumeration.
- Returns:
- the constructed enumeration