A "pair" object, as used in Lisp-like languages.
When used to implement a list, the 'car' field contains an
element's value, and the 'cdr' field points to either the next Pair
or LList.Empty (which represents the end of the list). (The names
"car" and "cdr" [pronounced "coulder"] are historical; better names
might be "value" and "next".) While a Pair is normally usued to
implement a linked list, sometimes the 'cdr' field ponus to some
other non-list object; this is traditionally callled a "dotted list".
compareTo
public static int compareTo(Pair pair1,
Pair pair2)
equals
public boolean equals(Object obj)
- equals in interface LList
equals
public static boolean equals(Pair pair1,
Pair pair2)
get
public Object get(int index)
See java.util.List.
- get in interface Sequence
- get in interface LList
getPosNext
public Object getPosNext(int ipos)
Get the element following the specified position.
- getPosNext in interface LList
ipos
- the specified position.
- the following element, or eofValue if there is none.
Called by SeqPosition.getNext.
getPosPrevious
public Object getPosPrevious(int ipos)
Get the element before the specified position.
- getPosPrevious in interface LList
ipos
- the specified position.
- the following element, or eofValue if there is none.
hasNext
public boolean hasNext(int ipos)
- hasNext in interface LList
lastPair
public final Pair lastPair()
length
public int length()
make
public static Pair make(Object car,
Object cdr)
nextPos
public int nextPos(int ipos)
Return the next position following the argument.
The new position has the isAfter property.
The argument is implicitly released (as in releasePos).
Returns 0 if we are already at end of file.
- nextPos in interface LList
readExternal
public void readExternal(ObjectInput in)
throws IOException,
ClassNotFoundException
- readExternal in interface LList
readResolve
public Object readResolve()
throws ObjectStreamException
Needed to override readResolve in LList.
- readResolve in interface LList
writeExternal
public void writeExternal(ObjectOutput out)
throws IOException
- writeExternal in interface LList