gnu.lists

Class LList

public class LList extends ExtSequence implements Sequence, Externalizable, Comparable

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.
Field Summary
static LListEmpty
Constructor Summary
LList()
Do not use - only public for serialization!
Method Summary
static Pairchain1(Pair old, Object arg1)
Utility function used by compiler when inlining `list'.
static Pairchain4(Pair old, Object arg1, Object arg2, Object arg3, Object arg4)
Utility function used by compiler when inlining `list'.
static ObjectcheckNonList(Object rest)
Helper to protect against pathological LLists (neithr Pair nor Empty).
intcompareTo(Object obj)
voidconsume(Consumer out)
static ObjectconsX(Object[] args)
SRFI-1's cons* and Common Lisp's list* function.
intcreatePos(int index, boolean isAfter)
intcreateRelativePos(int pos, int delta, boolean isAfter)
booleanequals(Object obj)
Objectget(int index)
SeqPositiongetIterator(int index)
ObjectgetPosNext(int ipos)
ObjectgetPosPrevious(int ipos)
booleanhasNext(int ipos)
booleanisEmpty()
static intlength(Object arg)
static Pairlist1(Object arg1)
static Pairlist2(Object arg1, Object arg2)
static Pairlist3(Object arg1, Object arg2, Object arg3)
static Pairlist4(Object arg1, Object arg2, Object arg3, Object arg4)
static intlistLength(Object obj, boolean allowOtherSequence)
A safe function to count the length of a list.
static ObjectlistTail(Object list, int count)
static LListmakeList(List vals)
static LListmakeList(Object[] vals, int offset, int length)
static LListmakeList(Object[] vals, int offset)
intnextPos(int ipos)
voidreadExternal(ObjectInput in)
ObjectreadResolve()
static LListreverseInPlace(Object list)
Reverse a list in place, by modifying the cdr fields.
protected voidsetPosNext(int ipos, Object value)
protected voidsetPosPrevious(int ipos, Object value)
intsize()
StringtoString()
voidwriteExternal(ObjectOutput out)

Field Detail

Empty

public static final LList Empty

Constructor Detail

LList

public LList()
Do not use - only public for serialization!

Method Detail

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)

consume

public void consume(Consumer out)

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)

createRelativePos

public int createRelativePos(int pos, int delta, boolean isAfter)

equals

public boolean equals(Object obj)

get

public Object get(int index)

getIterator

public SeqPosition getIterator(int index)

getPosNext

public Object getPosNext(int ipos)

getPosPrevious

public Object getPosPrevious(int ipos)

hasNext

public boolean hasNext(int ipos)

isEmpty

public boolean isEmpty()

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.

Parameters: obj the putative list to measure allowOtherSequence if a non-List Sequence is seen, allow that

Returns: 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(List vals)

makeList

public static LList makeList(Object[] vals, int offset, int length)

makeList

public static LList makeList(Object[] vals, int offset)

nextPos

public int nextPos(int ipos)

readExternal

public void readExternal(ObjectInput in)

readResolve

public Object readResolve()

reverseInPlace

public static LList reverseInPlace(Object list)
Reverse a list in place, by modifying the cdr fields.

setPosNext

protected void setPosNext(int ipos, Object value)

setPosPrevious

protected void setPosPrevious(int ipos, Object value)

size

public int size()

toString

public String toString()

writeExternal

public void writeExternal(ObjectOutput out)

Serial Data: Write nothing. (Don't need to write anything.)