Semi-abstract class for traditions Lisp-style lists.
A list is implemented as a chain of Pair objects, where the
'car' field of the Pair points to a data element, and the 'cdr'
field points to the next Pair. (The names 'car' and 'cdr' are
historical; they refer to hardware on machines form the 60's.)
Includes singleton static Empty, and the Pair sub-class.
chain1
public static Pair chain1(Pair old,
Object arg1)
Utility function used by compiler when inlining `list'.
chain4
public static Pair chain4(Pair old,
Object arg1,
Object arg2,
Object arg3,
Object arg4)
Utility function used by compiler when inlining `list'.
checkNonList
public static Object checkNonList(Object rest)
Helper to protect against pathological LLists (neithr Pair nor Empty).
compareTo
public int compareTo(Object obj)
consX
public static Object consX(Object[] args)
SRFI-1's cons* and Common Lisp's list* function.
createPos
public int createPos(int index,
boolean isAfter)
Generate a position at a given index.
The result is a position cookie that must be free'd with releasePos.
- createPos in interface AbstractSequence
index
- offset from beginning of desired positionisAfter
- should the position have the isAfter property
getPosNext
public Object getPosNext(int ipos)
Get the element following the specified position.
- getPosNext in interface AbstractSequence
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 AbstractSequence
ipos
- the specified position.
- the following element, or eofValue if there is none.
length
public static final int length(Object arg)
list1
public static Pair list1(Object arg1)
list2
public static Pair list2(Object arg1,
Object arg2)
list3
public static Pair list3(Object arg1,
Object arg2,
Object arg3)
list4
public static Pair list4(Object arg1,
Object arg2,
Object arg3,
Object arg4)
listLength
public static int listLength(Object obj,
boolean allowOtherSequence)
A safe function to count the length of a list.
obj
- the putative list to measureallowOtherSequence
- if a non-List Sequence is seen, allow that
- the length, or -1 for a circular list, or -2 for an improper list
listTail
public static Object listTail(Object list,
int count)
makeList
public static LList makeList(Object[] vals,
int offset)
makeList
public static LList makeList(Object[] vals,
int offset,
int length)
makeList
public static LList makeList(java.util.List vals)
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 AbstractSequence
readExternal
public void readExternal(ObjectInput in)
throws IOException,
ClassNotFoundException
readResolve
public Object readResolve()
throws ObjectStreamException
reverseInPlace
public static LList reverseInPlace(Object list)
Reverse a list in place, by modifying the cdr fields.
writeExternal
public void writeExternal(ObjectOutput out)
throws IOException