|
|||||||||
PREV CLASS NEXT CLASS | FRAMES NO FRAMES | ||||||||
SUMMARY: NESTED | FIELD | CONSTR | METHOD | DETAIL: FIELD | CONSTR | METHOD |
java.lang.Object lrs.LRStruct
public class LRStruct
Mutable linear recursive structure.
Visitor Pattern: Serves as a host capable of executing algorithms which are visitors.
Field Summary | |
---|---|
private ANode |
_head
The state of of this LRStruct . |
Constructor Summary | |
---|---|
LRStruct()
Initializes this LRStruct to the empty state. |
|
LRStruct(ANode node)
Initiazes this LRStruct with a given head node. |
Method Summary | |
---|---|
java.lang.Object |
execute(IAlgo algo,
java.lang.Object inp)
Hook method to execute an algorithm with a given input and return an appropriate output object. |
java.lang.Object |
getFirst()
Gets the first data element from this LRStruct |
(package private) ANode |
getHead()
Gets the head node (i.e. |
LRStruct |
getRest()
Gets the rest of this LRStruct . |
LRStruct |
insertFront(java.lang.Object dat)
Inserts dat to the front of this LRStruct. post condition: getFirst() now returns dat. |
java.lang.Object |
removeFront()
Removes and returns this LRStruct 's first. |
LRStruct |
setFirst(java.lang.Object dat)
Sets first data element to a new value. |
(package private) LRStruct |
setHead(ANode head)
Changes the head node (i.e. |
LRStruct |
setRest(LRStruct 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 _head
LRStruct
.
Constructor Detail |
---|
public LRStruct()
LRStruct
to the empty state.
LRStruct(ANode 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.Object
public final LRStruct insertFront(java.lang.Object dat)
getFirst()
now returns dat.
dat
- data to be inserted.
LRStruct
public final java.lang.Object removeFront()
LRStruct
's first.
public final java.lang.Object getFirst()
LRStruct
public final LRStruct setFirst(java.lang.Object dat)
dat
- replaces the existing first for this LRStruct
.
LRStruct
NoSuchElementException
- if this LRStruct
is empty.public final LRStruct getRest()
LRStruct
.
NoSuchElementException
- if this LRStruct
is empty.public final LRStruct setRest(LRStruct tail)
LRStruct
.getRest()
now returns tail.
LRStruct
NoSuchElementException
- if this LRStruct
is empty.public final java.lang.Object execute(IAlgo algo, java.lang.Object inp)
algo
- an algorithm (!= null) that operates on this LRStruct.inp
- input object needed by visitor algo.
final LRStruct setHead(ANode head)
LRStruct
.
head
- replaces the existing state of this LRStruct
.
LRStruct
final ANode getHead()
LRStruct
.
|
|||||||||
PREV CLASS NEXT CLASS | FRAMES NO FRAMES | ||||||||
SUMMARY: NESTED | FIELD | CONSTR | METHOD | DETAIL: FIELD | CONSTR | METHOD |