|
|||||||||
| PREV CLASS NEXT CLASS | FRAMES NO FRAMES | ||||||||
| SUMMARY: NESTED | FIELD | CONSTR | METHOD | DETAIL: FIELD | CONSTR | METHOD | ||||||||
java.lang.Objectedu.colorado.collections.LinkedSeq
public class LinkedSeq
This class is a homework assignment;
A LinkedSeq is a sequence of references to Objects.
The sequence can have a special "current element," which is specified and
accessed through four methods that are not available in the bag classes
(start, getCurrent, advance, and isCurrent).
Long.MAX_VALUE elements, the size method
does not work. This is not a
problem for current implementations of the Java Virtual Machine (JVM).
But future JVMs could have heaps that allow linked lists longer than
Long.MAX_VALUE.
| Constructor Summary | |
|---|---|
LinkedSeq()
Initialize an empty sequence. |
|
| Method Summary | |
|---|---|
void |
addAfter(java.lang.Object element)
Adds a new element to this sequence, after the current element. |
void |
addAll(LinkedSeq addend)
Place the contents of another sequence at the end of this sequence. |
void |
addBefore(java.lang.Object element)
Adds a new element to this sequence, before the current element. |
void |
advance()
Move forward, so that the current element is now the next element in the sequence. |
java.lang.Object |
clone()
Generate a copy of this sequence. |
static LinkedSeq |
concatentation(LinkedSeq s1,
LinkedSeq s2)
Create a new sequence that contains all the elements from one sequence followed by another. |
java.lang.Object |
getCurrent()
Accessor method to determine the current capacity of this sequence. |
boolean |
isCurrent()
Accessor method to determine whether this sequence has a specified current element that can be retrieved with the getCurrent method. |
void |
removeCurrent()
Remove the current element from this sequence. |
long |
size()
Accessor method to determine the number of elements in this sequence. |
void |
start()
Set the current element at the front of this sequence. |
| Methods inherited from class java.lang.Object |
|---|
equals, getClass, hashCode, notify, notifyAll, toString, wait, wait, wait |
| Constructor Detail |
|---|
public LinkedSeq()
- - none
| Method Detail |
|---|
public void addAfter(java.lang.Object element)
element - a reference to the new element that is being added
java.lang.OutOfMemoryError - Indicates insufficient memory for a new node.public void addBefore(java.lang.Object element)
element - a reference to the new element that is being added
java.lang.OutOfMemoryError - Indicates insufficient memory for a new node.public void addAll(LinkedSeq addend)
addend - a sequence whose contents will be placed at the end of this sequence
addend, is not null.
addend have been placed at the end of
this sequence. The current element of this sequence remains where it
was, and the addend is also unchanged.
java.lang.NullPointerException - Indicates that addend is null.
java.lang.OutOfMemoryError - Indicates insufficient memory to increase the size of this sequence.public void advance()
- - none
isCurrent( ) returns true.
java.lang.IllegalStateException - Indicates that there is no current element, so advance may not be
activated.public java.lang.Object clone()
clone in class java.lang.Object- - none
LinkedSeq before it is used.
java.lang.OutOfMemoryError - Indicates insufficient memory for creating the clone.
public static LinkedSeq concatentation(LinkedSeq s1,
LinkedSeq s2)
s1 - the first of two sequencess2 - the second of two sequences
s1 nor s2 is null.
s1 followed by
s2 (with no current element)
java.lang.NullPointerException - Indicates that one of the arguments is null.
java.lang.OutOfMemoryError - Indicates insufficient memory for the new sequence.public java.lang.Object getCurrent()
addBefore and addAfter methods works efficiently
(without needing more memory) until this capacity is reached.
- - none
public boolean isCurrent()
getCurrent method.
- - none
return
true (there is a current element) or false
(there is no current element at the moment)public void removeCurrent()
- - none
isCurrent() returns true.
java.lang.IllegalStateException - Indicates that there is no current element, so removeCurrent
may not be called.public long size()
- - none
public void start()
- - none
|
|||||||||
| PREV CLASS NEXT CLASS | FRAMES NO FRAMES | ||||||||
| SUMMARY: NESTED | FIELD | CONSTR | METHOD | DETAIL: FIELD | CONSTR | METHOD | ||||||||