|
|||||||||
| PREV CLASS NEXT CLASS | FRAMES NO FRAMES | ||||||||
| SUMMARY: NESTED | FIELD | CONSTR | METHOD | DETAIL: FIELD | CONSTR | METHOD | ||||||||
java.lang.Objectlrs.LRStruct<T>
public class LRStruct<T>
Mutable linear recursive structure.
Visitor Pattern: Serves as a host capable of executing algorithms which are visitors.
| Field Summary | |
|---|---|
private ANode<T> |
_head
The state of of this LRStruct. |
| Constructor Summary | |
|---|---|
LRStruct()
Initializes this LRStruct to the empty state. |
|
LRStruct(ANode<T> node)
Initiazes this LRStruct with a given head node. |
|
| Method Summary | ||
|---|---|---|
|
execute(IAlgo<T,R,P> algo,
P... inp)
Hook method to execute an algorithm with a given input and return an appropriate output object. |
|
T |
getFirst()
Gets the first data element from this LRStruct |
|
(package private) ANode<T> |
getHead()
Gets the head node (i.e. |
|
LRStruct<T> |
getRest()
Gets the rest of this LRStruct. |
|
LRStruct<T> |
insertFront(T dat)
Inserts dat to the front of this LRStruct. post condition: getFirst() now returns dat. |
|
T |
removeFront()
Removes and returns this LRStruct's first. |
|
LRStruct<T> |
setFirst(T dat)
Sets first data element to a new value. |
|
(package private) LRStruct<T> |
setHead(ANode<T> head)
Changes the head node (i.e. |
|
LRStruct<T> |
setRest(LRStruct<T> tail)
Sets a new tail for this LRStruct.post condition: getRest() now returns tail. |
|
java.lang.String |
toString()
Returns "()" if empty, otherwise returns the contents of this LRStruct enclosed in parentheses. |
|
| Methods inherited from class java.lang.Object |
|---|
clone, equals, finalize, getClass, hashCode, notify, notifyAll, wait, wait, wait |
| Field Detail |
|---|
private ANode<T> _head
LRStruct.
| Constructor Detail |
|---|
public LRStruct()
LRStruct to the empty state.
LRStruct(ANode<T> node)
LRStruct with a given head node.
node - != null.| Method Detail |
|---|
public java.lang.String toString()
LRStruct enclosed in parentheses.
toString in class java.lang.Objectpublic final LRStruct<T> insertFront(T dat)
getFirst() now returns dat.
dat - data to be inserted.
LRStructpublic final T removeFront()
LRStruct's first.
public final T getFirst()
LRStruct
public final LRStruct<T> setFirst(T dat)
dat - replaces the existing first for this LRStruct.
LRStruct
NoSuchElementException - if this LRStruct is empty.public final LRStruct<T> getRest()
LRStruct.
NoSuchElementException - if this LRStruct is empty.public final LRStruct<T> setRest(LRStruct<T> tail)
LRStruct.getRest() now returns tail.
LRStruct
NoSuchElementException - if this LRStruct is empty.
public final <R,P> R execute(IAlgo<T,R,P> algo,
P... inp)
algo - an algorithm (!= null) that operates on this LRStruct.inp - input variable argument list of objects needed by visitor algo.
final LRStruct<T> setHead(ANode<T> head)
LRStruct.
head - replaces the exisiting state of this LRStruct.
LRStructfinal ANode<T> getHead()
LRStruct.
|
|||||||||
| PREV CLASS NEXT CLASS | FRAMES NO FRAMES | ||||||||
| SUMMARY: NESTED | FIELD | CONSTR | METHOD | DETAIL: FIELD | CONSTR | METHOD | ||||||||