|
||||||||||
PREV CLASS NEXT CLASS | FRAMES NO FRAMES | |||||||||
SUMMARY: NESTED | FIELD | CONSTR | METHOD | DETAIL: FIELD | CONSTR | METHOD |
java.lang.Object gnu.lists.AbstractSequence gnu.lists.ExtSequence gnu.lists.LList gnu.lists.Pair
public class Pair
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 | |
---|---|
java.lang.Object |
car
|
java.lang.Object |
cdr
|
Fields inherited from class gnu.lists.LList |
---|
Empty |
Fields inherited from interface gnu.lists.Sequence |
---|
ATTRIBUTE_VALUE, BOOLEAN_VALUE, CDATA_VALUE, CHAR_VALUE, COMMENT_VALUE, DOCUMENT_VALUE, DOUBLE_VALUE, ELEMENT_VALUE, EOF_VALUE, eofValue, FLOAT_VALUE, INT_S16_VALUE, INT_S32_VALUE, INT_S64_VALUE, INT_S8_VALUE, INT_U16_VALUE, INT_U32_VALUE, INT_U64_VALUE, INT_U8_VALUE, OBJECT_VALUE, PRIM_VALUE, PROCESSING_INSTRUCTION_VALUE, TEXT_BYTE_VALUE |
Constructor Summary | |
---|---|
Pair()
|
|
Pair(java.lang.Object carval,
java.lang.Object cdrval)
|
Method Summary | |
---|---|
int |
compareTo(java.lang.Object obj)
|
static int |
compareTo(Pair pair1,
Pair pair2)
|
boolean |
equals(java.lang.Object obj)
|
static boolean |
equals(Pair pair1,
Pair pair2)
|
java.lang.Object |
get(int index)
See java.util.List. |
java.lang.Object |
getPosNext(int ipos)
Get the element following the specified position. |
java.lang.Object |
getPosPrevious(int ipos)
Get the element before the specified position. |
int |
hashCode()
|
boolean |
hasNext(int ipos)
|
boolean |
isEmpty()
True is this sequence contains no elements. |
Pair |
lastPair()
|
int |
length()
|
static Pair |
make(java.lang.Object car,
java.lang.Object cdr)
|
int |
nextPos(int ipos)
Return the next position following the argument. |
void |
readExternal(java.io.ObjectInput in)
|
java.lang.Object |
readResolve()
Needed to override readResolve in LList. |
int |
size()
See java.util.List. |
java.lang.Object[] |
toArray()
|
java.lang.Object[] |
toArray(java.lang.Object[] arr)
|
void |
writeExternal(java.io.ObjectOutput out)
|
Methods inherited from class gnu.lists.LList |
---|
chain1, chain4, checkNonList, consume, consX, createPos, createRelativePos, getIterator, length, list1, list2, list3, list4, listLength, listTail, makeList, makeList, makeList, reverseInPlace, setPosNext, setPosPrevious, toString |
Methods inherited from class gnu.lists.ExtSequence |
---|
copyPos, isAfterPos, nextIndex, releasePos |
Methods inherited from class java.lang.Object |
---|
clone, finalize, getClass, notify, notifyAll, wait, wait, wait |
Methods inherited from interface gnu.lists.Sequence |
---|
elements, fill, set |
Methods inherited from interface java.util.List |
---|
add, add, addAll, addAll, clear, contains, containsAll, indexOf, iterator, lastIndexOf, listIterator, listIterator, remove, remove, removeAll, retainAll, subList |
Field Detail |
---|
public java.lang.Object car
public java.lang.Object cdr
Constructor Detail |
---|
public Pair(java.lang.Object carval, java.lang.Object cdrval)
public Pair()
Method Detail |
---|
public int size()
AbstractSequence
size
in interface Sequence
size
in interface java.util.Collection
size
in interface java.util.List
size
in class LList
public boolean isEmpty()
Sequence
isEmpty
in interface Sequence
isEmpty
in interface java.util.Collection
isEmpty
in interface java.util.List
isEmpty
in class LList
public int length()
public boolean hasNext(int ipos)
hasNext
in class LList
public int nextPos(int ipos)
AbstractSequence
nextPos
in class LList
public java.lang.Object getPosNext(int ipos)
AbstractSequence
getPosNext
in class LList
ipos
- the specified position.
public java.lang.Object getPosPrevious(int ipos)
AbstractSequence
getPosPrevious
in class LList
ipos
- the specified position.
public final Pair lastPair()
public int hashCode()
hashCode
in interface java.util.Collection
hashCode
in interface java.util.List
hashCode
in class AbstractSequence
public static boolean equals(Pair pair1, Pair pair2)
public static int compareTo(Pair pair1, Pair pair2)
public int compareTo(java.lang.Object obj)
compareTo
in interface java.lang.Comparable
compareTo
in class LList
public java.lang.Object get(int index)
AbstractSequence
get
in interface Sequence
get
in interface java.util.List
get
in class LList
public boolean equals(java.lang.Object obj)
equals
in interface java.util.Collection
equals
in interface java.util.List
equals
in class LList
public static Pair make(java.lang.Object car, java.lang.Object cdr)
public java.lang.Object[] toArray()
toArray
in interface java.util.Collection
toArray
in interface java.util.List
toArray
in class AbstractSequence
public java.lang.Object[] toArray(java.lang.Object[] arr)
toArray
in interface java.util.Collection
toArray
in interface java.util.List
toArray
in class AbstractSequence
public void writeExternal(java.io.ObjectOutput out) throws java.io.IOException
writeExternal
in interface java.io.Externalizable
writeExternal
in class LList
java.io.IOException
public void readExternal(java.io.ObjectInput in) throws java.io.IOException, java.lang.ClassNotFoundException
readExternal
in interface java.io.Externalizable
readExternal
in class LList
java.io.IOException
java.lang.ClassNotFoundException
public java.lang.Object readResolve() throws java.io.ObjectStreamException
readResolve
in class LList
java.io.ObjectStreamException
|
||||||||||
PREV CLASS NEXT CLASS | FRAMES NO FRAMES | |||||||||
SUMMARY: NESTED | FIELD | CONSTR | METHOD | DETAIL: FIELD | CONSTR | METHOD |