Package gnu.lists
Class Pair
- All Implemented Interfaces:
BoundedHashable
,Consumable
,Sequence<Object>
,Externalizable
,Serializable
,Comparable
,Iterable<Object>
,Collection<Object>
,List<Object>
,SequencedCollection<Object>
- Direct Known Subclasses:
ImmutablePair
,Translator.FormStack
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 points to some
other non-list object; this is traditionally callled a "dotted list".
- See Also:
-
Field Summary
FieldsModifier and TypeFieldDescriptionprotected Object
protected Object
static final Pair
A special pair used to indicate incomplete input.Fields inherited from class gnu.lists.AbstractSequence
noInts
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
Constructors -
Method Summary
Modifier and TypeMethodDescriptionstatic int
int
static boolean
boolean
get
(int index) See java.util.List.getCar()
getCdr()
getPosNext
(int ipos) Get the element following the specified position.getPosPrevious
(int ipos) Get the element before the specified position.boolean
hasNext
(int ipos) boolean
isEmpty()
True is this sequence contains no elements.lastPair()
int
length()
static Pair
int
nextPos
(int ipos) Return the next position following the argument.void
Needed to override readResolve in LList.void
void
setCarBackdoor
(Object car) May go away soon.void
void
setCdrBackdoor
(Object cdr) int
size()
See java.util.List.Object[]
toArray()
Object[]
void
Methods inherited from class gnu.lists.LList
boundedHash, chain1, chain4, checkNonList, consume, consX, createPos, createRelativePos, getIterator, hashCode, length, list1, list2, list3, list4, listLength, makeList, makeList, makeList, reverseInPlace, setPosNext, setPosPrevious, toString
Methods inherited from class gnu.lists.ExtSequence
copyPos, isAfterPos, nextIndex, releasePos
Methods inherited from class gnu.lists.AbstractSequence
add, add, addAll, addAll, addPos, asImmutable, badRank, checkCanWrite, checkRank, clear, compare, compare, compare, consume, consumeNext, consumePosRange, contains, containsAll, effectiveIndex, effectiveIndex, effectiveIndex, effectiveIndex, effectiveIndex, elements, endPos, equals, fill, fill, fillPosRange, firstAttributePos, firstChildPos, firstChildPos, fromEndIndex, get, get, get, get, getAttribute, getAttributeLength, getBooleanRaw, getByteRaw, getCharRaw, getContainingSequenceSize, getDoubleRaw, getElementKind, getFloatRaw, getIndexDifference, getInt, getInt, getInt, getInt, getInt, getIntRaw, getIterator, getIteratorAtPos, getLongRaw, getLowBound, getNextKind, getNextTypeName, getNextTypeObject, getRaw, getRowMajor, getShortRaw, getSize, getSize, gotoAttributesStart, gotoChildrenStart, gotoParent, hasPrevious, indexOf, iterator, lastIndexOf, listIterator, listIterator, nextIndex, nextMatching, parentPos, previousPos, rank, remove, remove, removeAll, removePos, removePosRange, retainAll, set, set, setAt, setBuffer, setRaw, stableCompare, startPos, subList, subSequence, subSequencePos, toString, unsupported, unsupportedException
Methods inherited from class java.lang.Object
clone, finalize, getClass, notify, notifyAll, wait, wait, wait
Methods inherited from interface java.util.Collection
parallelStream, removeIf, stream, toArray
Methods inherited from interface java.util.List
add, add, addAll, addAll, addFirst, addLast, clear, contains, containsAll, getFirst, getLast, indexOf, iterator, lastIndexOf, listIterator, listIterator, remove, remove, removeAll, removeFirst, removeLast, replaceAll, retainAll, reversed, sort, spliterator, subList
-
Field Details
-
car
-
cdr
-
incompleteListMarker
A special pair used to indicate incomplete input.
-
-
Constructor Details
-
Pair
-
Pair
public Pair()
-
-
Method Details
-
getCar
-
getCdr
-
setCar
-
setCdr
-
setCarBackdoor
May go away soon. -
setCdrBackdoor
-
size
public int size()Description copied from interface:Sequence
See java.util.List. -
isEmpty
public boolean isEmpty()Description copied from interface:Sequence
True is this sequence contains no elements. -
length
public int length() -
hasNext
public boolean hasNext(int ipos) -
nextPos
public int nextPos(int ipos) Description copied from class:AbstractSequence
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. -
getPosNext
Description copied from class:AbstractSequence
Get the element following the specified position.- Overrides:
getPosNext
in classLList
- Parameters:
ipos
- the specified position.- Returns:
- the following element, or eofValue if there is none. Called by SeqPosition.getNext. FIXME Should change eof handling so return type can be E.
-
getPosPrevious
Description copied from class:AbstractSequence
Get the element before the specified position.- Overrides:
getPosPrevious
in classLList
- Parameters:
ipos
- the specified position.- Returns:
- the following element, or eofValue if there is none. FIXME Should change eof handling so return type can be E.
-
lastPair
-
equals
-
compareTo
-
compareTo
- Specified by:
compareTo
in interfaceComparable
- Overrides:
compareTo
in classLList
-
get
Description copied from interface:Sequence
See java.util.List. -
equals
-
make
-
toArray
- Specified by:
toArray
in interfaceCollection<Object>
- Specified by:
toArray
in interfaceList<Object>
- Overrides:
toArray
in classAbstractSequence<Object>
-
toArray
- Specified by:
toArray
in interfaceCollection<Object>
- Specified by:
toArray
in interfaceList<Object>
- Overrides:
toArray
in classAbstractSequence<Object>
-
writeExternal
- Specified by:
writeExternal
in interfaceExternalizable
- Overrides:
writeExternal
in classLList
- Throws:
IOException
-
readExternal
- Specified by:
readExternal
in interfaceExternalizable
- Overrides:
readExternal
in classLList
- Throws:
IOException
ClassNotFoundException
-
readResolve
Needed to override readResolve in LList.- Overrides:
readResolve
in classLList
- Throws:
ObjectStreamException
-