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 Objectprotected Objectstatic final PairA special pair used to indicate incomplete input.Fields inherited from class gnu.lists.AbstractSequence
noIntsFields 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 intintstatic booleanbooleanget(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.booleanhasNext(int ipos) booleanisEmpty()True is this sequence contains no elements.lastPair()intlength()static PairintnextPos(int ipos) Return the next position following the argument.voidNeeded to override readResolve in LList.voidvoidsetCarBackdoor(Object car) May go away soon.voidvoidsetCdrBackdoor(Object cdr) intsize()See java.util.List.Object[]toArray()Object[]voidMethods 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, toStringMethods inherited from class gnu.lists.ExtSequence
copyPos, isAfterPos, nextIndex, releasePosMethods 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, unsupportedExceptionMethods inherited from class java.lang.Object
clone, finalize, getClass, notify, notifyAll, wait, wait, waitMethods inherited from interface java.util.Collection
parallelStream, removeIf, stream, toArrayMethods 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:SequenceSee java.util.List. -
isEmpty
public boolean isEmpty()Description copied from interface:SequenceTrue 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:AbstractSequenceReturn 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:AbstractSequenceGet the element following the specified position.- Overrides:
getPosNextin 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:AbstractSequenceGet the element before the specified position.- Overrides:
getPosPreviousin 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:
compareToin interfaceComparable- Overrides:
compareToin classLList
-
get
Description copied from interface:SequenceSee java.util.List. -
equals
-
make
-
toArray
- Specified by:
toArrayin interfaceCollection<Object>- Specified by:
toArrayin interfaceList<Object>- Overrides:
toArrayin classAbstractSequence<Object>
-
toArray
- Specified by:
toArrayin interfaceCollection<Object>- Specified by:
toArrayin interfaceList<Object>- Overrides:
toArrayin classAbstractSequence<Object>
-
writeExternal
- Specified by:
writeExternalin interfaceExternalizable- Overrides:
writeExternalin classLList- Throws:
IOException
-
readExternal
- Specified by:
readExternalin interfaceExternalizable- Overrides:
readExternalin classLList- Throws:
IOExceptionClassNotFoundException
-
readResolve
Needed to override readResolve in LList.- Overrides:
readResolvein classLList- Throws:
ObjectStreamException
-