|
||||||||||
| PREV CLASS NEXT CLASS | FRAMES NO FRAMES | |||||||||
| SUMMARY: NESTED | FIELD | CONSTR | METHOD | DETAIL: FIELD | CONSTR | METHOD | |||||||||
java.lang.Objectjava.util.AbstractCollection<E>
java.util.AbstractList<E>
java.util.AbstractSequentialList
ix.util.lisp.LList
public abstract class LList
Lisp-style lists.
An LList can be treated as a Collection that is sequential, fixed-size, and modifiable. However, the linked structure is visible; and that allows them to be used in ways that typical Java collections cannot. Two LLists can share structure by having a common tail. Moreover, an LList is not constructed by creating an empty LList and then adding elements; instead it is typically made from a single element, which becomes the first element of the LList, plus an existing LList that contains the rest. This supports a different style of programming closer to what is used in functional languages, Lisp, and Prolog.
For a Collection based on LLists that works in the more usual
Java manner, use an LListCollector.
The class structure is like that in Common Lisp -- there is an abstract class LList with two subclasses, Cons and Null -- but only proper lists are allowed. The car of a Cons can be any Object, but the cdr must be a List.
The empty list is the value of Lisp.NIL and is the only
instance of the class Null.
An important goal was that all lists, including the empty list, could be enumerated. That's one reason for having a List subclass for the empty list, rather than just using a unique Object or null. The subclass also allows a number of other methods to be defined for all lists. (A plausible alternative, however, would be to have just one class, LList, and have the empty list be a unique instance of that class.)
LListCollector,
Lisp,
Cons,
Null,
Serialized Form| Field Summary |
|---|
| Fields inherited from class java.util.AbstractList |
|---|
modCount |
| Constructor Summary | |
|---|---|
LList()
|
|
| Method Summary | |
|---|---|
Cons |
alistEntry(java.lang.Object key)
Treats this LList as an association list (alist) of (key value) pairs and returns the first pair with a key that equals the one specified. |
LList |
alistKeys()
|
java.util.Map |
alistToMap(java.util.Map map)
Treats this LList as an association list (alist) and returns a map that maps the same keys to the same values. |
java.lang.Object |
alistValue(java.lang.Object key)
|
abstract LList |
append(LList tail)
|
abstract java.lang.Object |
car()
|
abstract LList |
cdr()
|
java.lang.Object |
clone()
|
LList |
delete(java.lang.Object e)
|
LList |
drop(int n)
|
LList |
dropTo(java.lang.Object a)
|
abstract java.lang.Object |
elementAt(int i)
|
abstract java.util.Enumeration |
elements()
|
abstract boolean |
equal(LList list)
|
abstract boolean |
find(java.lang.Object a)
|
LList |
flatmap(Function1 f)
|
java.lang.Object |
get(int index)
|
java.lang.Object |
get(java.lang.Object propname)
|
LList |
insert(java.lang.Object e,
Predicate2 lessp)
|
LList |
intersect(LList set)
|
boolean |
isEmpty()
|
abstract boolean |
isNull()
|
java.util.Iterator |
iterator()
Returns an interator over the elements of the list. |
Cons |
lastCons()
|
int |
lastIndexOf(java.lang.Object o)
|
abstract int |
length()
|
java.util.ListIterator |
listIterator(int index)
|
static LList |
LListify(java.util.List l)
Returns an LList copy of a possibly nested List. |
LList |
mapc(Function1 f)
|
LList |
mapcar(Function1 f)
|
LList |
mapNth(int n)
Returns a list of the nth elements from a list of lists. |
static LList |
mapToAlist(java.util.Map map)
|
LList |
mapTree(Function1 f)
|
static LList |
newLList(java.util.Collection c)
|
LList |
permute()
|
LList |
put(java.lang.Object propname,
java.lang.Object value)
Returns a plist that maps propname to value. |
LList |
replaceAll(java.lang.Object old,
java.lang.Object neu)
|
LList |
reverse()
|
int |
size()
|
LList |
take(int n)
|
LList |
takeTo(java.lang.Object a)
|
java.lang.String |
toJavaString()
|
void |
walkTree(Function1 f)
|
LList |
without(java.lang.Object e)
Returns an LList that does not contain any element == to e. |
LList |
withoutAll(java.util.Collection c)
Returns an LList that does not contain any element of a specified collection. |
LList |
withoutFirst(java.lang.Object e)
Returns an LList that does not contain the first element, if any, that is == to e. |
LList |
withoutFirstEqual(java.lang.Object e)
Returns an LList that does not contain the first element, if any, that equals e. |
| Methods inherited from class java.util.AbstractSequentialList |
|---|
add, addAll, remove, set |
| Methods inherited from class java.util.AbstractList |
|---|
add, clear, equals, hashCode, indexOf, listIterator, removeRange, subList |
| Methods inherited from class java.util.AbstractCollection |
|---|
addAll, contains, containsAll, remove, removeAll, retainAll, toArray, toArray, toString |
| Methods inherited from class java.lang.Object |
|---|
finalize, getClass, notify, notifyAll, wait, wait, wait |
| Methods inherited from interface java.lang.Comparable |
|---|
compareTo |
| Methods inherited from interface java.util.List |
|---|
addAll, contains, containsAll, remove, removeAll, retainAll, toArray, toArray |
| Constructor Detail |
|---|
public LList()
| Method Detail |
|---|
public static LList newLList(java.util.Collection c)
public static LList LListify(java.util.List l)
public java.util.ListIterator listIterator(int index)
listIterator in interface java.util.ListlistIterator in class java.util.AbstractSequentialListpublic int size()
size in interface java.util.Collectionsize in interface java.util.Listsize in class java.util.AbstractCollectionpublic java.util.Iterator iterator()
iterator in interface java.lang.Iterableiterator in interface java.util.Collectioniterator in interface java.util.Listiterator in class java.util.AbstractSequentialListpublic boolean isEmpty()
isEmpty in interface java.util.CollectionisEmpty in interface java.util.ListisEmpty in class java.util.AbstractCollectionpublic java.lang.Object get(int index)
get in interface java.util.Listget in class java.util.AbstractSequentialListpublic int lastIndexOf(java.lang.Object o)
lastIndexOf in interface java.util.ListlastIndexOf in class java.util.AbstractListpublic abstract boolean isNull()
public abstract java.lang.Object car()
public abstract LList cdr()
public abstract int length()
public abstract java.lang.Object elementAt(int i)
public abstract java.util.Enumeration elements()
public abstract boolean equal(LList list)
public abstract boolean find(java.lang.Object a)
public abstract LList append(LList tail)
public java.lang.Object clone()
clone in class java.lang.Objectpublic LList reverse()
public java.lang.Object get(java.lang.Object propname)
public LList put(java.lang.Object propname,
java.lang.Object value)
public Cons alistEntry(java.lang.Object key)
public java.lang.Object alistValue(java.lang.Object key)
public LList alistKeys()
public java.util.Map alistToMap(java.util.Map map)
public static LList mapToAlist(java.util.Map map)
public Cons lastCons()
public LList take(int n)
public LList drop(int n)
public LList takeTo(java.lang.Object a)
public LList dropTo(java.lang.Object a)
public LList without(java.lang.Object e)
public LList withoutAll(java.util.Collection c)
public LList withoutFirst(java.lang.Object e)
public LList withoutFirstEqual(java.lang.Object e)
public LList delete(java.lang.Object e)
public LList insert(java.lang.Object e,
Predicate2 lessp)
public LList replaceAll(java.lang.Object old,
java.lang.Object neu)
public LList mapc(Function1 f)
public LList mapcar(Function1 f)
public LList flatmap(Function1 f)
public LList mapNth(int n)
public void walkTree(Function1 f)
public LList mapTree(Function1 f)
public LList intersect(LList set)
public LList permute()
public java.lang.String toJavaString()
|
||||||||||
| PREV CLASS NEXT CLASS | FRAMES NO FRAMES | |||||||||
| SUMMARY: NESTED | FIELD | CONSTR | METHOD | DETAIL: FIELD | CONSTR | METHOD | |||||||||