|
Parsing Engine | |||||||||
PREV CLASS NEXT CLASS | FRAMES NO FRAMES | |||||||||
SUMMARY: NESTED | FIELD | CONSTR | METHOD | DETAIL: FIELD | CONSTR | METHOD |
java.lang.Objectdanbikel.util.SLNode
public class SLNode
Represents a node in a singly-linked list. This class provides
low-level and direct access to the nodes of a singly-linked list
and to the data objects at those nodes, and is thus intended to be
used when efficiency concerns outweigh data abstraction concerns.
For example, this class makes no attempt at providing synchronization
mechanisms, nor does it attempt to check for concurrent modifications,
as do most of the Collections framework classes. Also, zero-length
lists are represented implicitly by null
, as far as
this class is concerned.
Constructor Summary | |
---|---|
SLNode()
|
|
SLNode(Object data,
SLNode next)
Constructs a new SLNode with the specified data object
and next node. |
Method Summary | |
---|---|
Object |
data()
Returns the data associated with this node of the list. |
Iterator |
iterator()
Returns an iterator to iterate over the elements of this list. |
int |
length()
Returns the length of this list. |
SLNode |
next()
Returns the next node of this list. |
SLNode |
set(Object data,
SLNode next)
|
SLNode |
setData(Object data)
|
int |
size()
Returns the length of this list. |
LinkedList |
toList()
Returns a new LinkedList object containing all the data of
this list. |
String |
toString()
Returns a human- and Sexp -readable version of the
singly-linked list headed by this node. |
Methods inherited from class java.lang.Object |
---|
clone, equals, finalize, getClass, hashCode, notify, notifyAll, wait, wait, wait |
Constructor Detail |
---|
public SLNode()
public SLNode(Object data, SLNode next)
SLNode
with the specified data object
and next
node.
data
- the data to associate with this nodenext
- the next object in the singly-linked list, or
null
if this is the last node in the listMethod Detail |
---|
public Object data()
public SLNode next()
public SLNode set(Object data, SLNode next)
public SLNode setData(Object data)
public int length()
next
pointers until null
is reached.
public int size()
public LinkedList toList()
LinkedList
object containing all the data of
this list.
public Iterator iterator()
for (SLNode curr = <init>; curr.next() != null; curr = curr.next()) { Object data = curr.data(); // operate on data at current node... }
public String toString()
Sexp
-readable version of the
singly-linked list headed by this node.
toString
in class Object
|
Parsing Engine | |||||||||
PREV CLASS NEXT CLASS | FRAMES NO FRAMES | |||||||||
SUMMARY: NESTED | FIELD | CONSTR | METHOD | DETAIL: FIELD | CONSTR | METHOD |