gnu.lists

Class Pair

public class Pair extends LList implements Externalizable

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".
Field Summary
Objectcar
Objectcdr
Constructor Summary
Pair(Object carval, Object cdrval)
Pair()
Method Summary
static intcompareTo(Pair pair1, Pair pair2)
intcompareTo(Object obj)
static booleanequals(Pair pair1, Pair pair2)
booleanequals(Object obj)
Objectget(int index)
ObjectgetPosNext(int ipos)
ObjectgetPosPrevious(int ipos)
inthashCode()
booleanhasNext(int ipos)
booleanisEmpty()
PairlastPair()
intlength()
static Pairmake(Object car, Object cdr)
intnextPos(int ipos)
voidreadExternal(ObjectInput in)
ObjectreadResolve()
Needed to override readResolve in LList.
intsize()
Object[]toArray()
Object[]toArray(Object[] arr)
voidwriteExternal(ObjectOutput out)

Field Detail

car

public Object car

cdr

public Object cdr

Constructor Detail

Pair

public Pair(Object carval, Object cdrval)

Pair

public Pair()

Method Detail

compareTo

public static int compareTo(Pair pair1, Pair pair2)

compareTo

public int compareTo(Object obj)

equals

public static boolean equals(Pair pair1, Pair pair2)

equals

public boolean equals(Object obj)

get

public Object get(int index)

getPosNext

public Object getPosNext(int ipos)

getPosPrevious

public Object getPosPrevious(int ipos)

hashCode

public int hashCode()

hasNext

public boolean hasNext(int ipos)

isEmpty

public boolean isEmpty()

lastPair

public final Pair lastPair()

length

public int length()

make

public static Pair make(Object car, Object cdr)

nextPos

public int nextPos(int ipos)

readExternal

public void readExternal(ObjectInput in)

readResolve

public Object readResolve()
Needed to override readResolve in LList.

size

public int size()

toArray

public Object[] toArray()

toArray

public Object[] toArray(Object[] arr)

writeExternal

public void writeExternal(ObjectOutput out)

Serial Data: Write the car followed by the cdr.