Overview | Package | Class | Use | Tree | Deprecated | Index | Help
PREV CLASS NEXT CLASS | FRAMES NO FRAMES
SUMMARY: NESTED | FIELD | CONSTR | METHOD | DETAIL: FIELD | CONSTR | METHOD

## ix.util.lisp
Class LList

    java.lang.Object
      java.util.AbstractCollection<E>
          java.util.AbstractList<E>
              java.util.AbstractSequentialList
                  ix.util.lisp.LList

All Implemented Interfaces:
  LispObject, java.io.Serializable, java.lang.Comparable, java.lang.Iterable, java.util.Collection, java.util.List

Direct Known Subclasses:
  Cons, Null

    public abstract class LList

extends java.util.AbstractSequentialList
implements LispObject, java.io.Serializable, java.lang.Comparable

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.)

See Also:
  `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

### LList

    public LList()

Method Detail

### newLList

    public static LList newLList(java.util.Collection c)

### LListify

    public static LList LListify(java.util.List l)

  Returns an LList copy of a possibly nested List. This is a way to convert a List to an LList. The copying is recursive down to any non-Lists (which are not copied).

### listIterator

    public java.util.ListIterator listIterator(int index)

  Specified by:
    `listIterator` in interface `java.util.List`
  Specified by:
    `listIterator` in class `java.util.AbstractSequentialList`

### size

    public int size()

  Specified by:
    `size` in interface `java.util.Collection`
  Specified by:
    `size` in interface `java.util.List`
  Specified by:
    `size` in class `java.util.AbstractCollection`

### iterator

    public java.util.Iterator iterator()

  Returns an interator over the elements of the list. Note that the result is a plain Iterator, not a ListIterator, because Iterators require less state and can be implemented more efficiently.

  Specified by:
    `iterator` in interface `java.lang.Iterable`
  Specified by:
    `iterator` in interface `java.util.Collection`
  Specified by:
    `iterator` in interface `java.util.List`
  Overrides:
    `iterator` in class `java.util.AbstractSequentialList`

### isEmpty

    public boolean isEmpty()

  Specified by:
    `isEmpty` in interface `java.util.Collection`
  Specified by:
    `isEmpty` in interface `java.util.List`
  Overrides:
    `isEmpty` in class `java.util.AbstractCollection`

### get

    public java.lang.Object get(int index)

  Specified by:
    `get` in interface `java.util.List`
  Overrides:
    `get` in class `java.util.AbstractSequentialList`

### lastIndexOf

    public int lastIndexOf(java.lang.Object o)

  Specified by:
    `lastIndexOf` in interface `java.util.List`
  Overrides:
    `lastIndexOf` in class `java.util.AbstractList`

### isNull

    public abstract boolean isNull()

### car

    public abstract java.lang.Object car()

### cdr

    public abstract LList cdr()

### length

    public abstract int length()

### elementAt

    public abstract java.lang.Object elementAt(int i)

### elements

    public abstract java.util.Enumeration elements()

### equal

    public abstract boolean equal(LList list)

### find

    public abstract boolean find(java.lang.Object a)

### append

    public abstract LList append(LList tail)

### clone

    public java.lang.Object clone()

  Overrides:
    `clone` in class `java.lang.Object`

### reverse

    public LList reverse()

### get

    public java.lang.Object get(java.lang.Object propname)

### put

    public LList put(java.lang.Object propname,
                     java.lang.Object value)

  Returns a plist that maps propname to value. If propname is already a property, the existing value is replaced; otherwise a new list (propname value . oldList) is returned.

### alistEntry

    public 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. Elements that are not conses are skipped.

  Returns:
    a list beginning with the specified key or else null if no such list could be found.

### alistValue

    public java.lang.Object alistValue(java.lang.Object key)

### alistKeys

    public LList alistKeys()

### alistToMap

    public 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.

### mapToAlist

    public static LList mapToAlist(java.util.Map map)

### lastCons

    public Cons lastCons()

### take

    public LList take(int n)

### drop

    public LList drop(int n)

### takeTo

    public LList takeTo(java.lang.Object a)

### dropTo

    public LList dropTo(java.lang.Object a)

### without

    public LList without(java.lang.Object e)

  Returns an LList that does not contain any element == to e. If no removals are required, the result is == to this LList; otherwise, it is a copy up to the tail after the last removal, with the rest shared with this LList.

### withoutAll

    public LList withoutAll(java.util.Collection c)

  Returns an LList that does not contain any element of a specified collection. Membership in the collection is determined by its contains(Object) method, not by == comparisons. If no removals are required, the result is == to this LList; otherwise, it is a copy up to the tail after the last removal, with the rest shared with this LList.

### withoutFirst

    public LList withoutFirst(java.lang.Object e)

  Returns an LList that does not contain the first element, if any, that is == to e. If no such element occurs, the result is == to this LList; otherwise, it is a copy up to the tail after the removal, sharing with this LList thereafter.

### withoutFirstEqual

    public LList withoutFirstEqual(java.lang.Object e)

  Returns an LList that does not contain the first element, if any, that equals e. If no such element occurs, the result is == to this LList; otherwise, it is a copy up to the tail after the removal, sharing with this LList thereafter.

### delete

    public LList delete(java.lang.Object e)

### insert

    public LList insert(java.lang.Object e,
                        Predicate2 lessp)

### replaceAll

    public LList replaceAll(java.lang.Object old,
                            java.lang.Object neu)

### mapc

    public LList mapc(Function1 f)

### mapcar

    public LList mapcar(Function1 f)

### flatmap

    public LList flatmap(Function1 f)

### mapNth

    public LList mapNth(int n)

  Returns a list of the nth elements from a list of lists.

### walkTree

    public void walkTree(Function1 f)

### mapTree

    public LList mapTree(Function1 f)

### intersect

    public LList intersect(LList set)

### permute

    public LList permute()

### toJavaString

    public java.lang.String toJavaString()

Overview | Package | Class | Use | Tree | Deprecated | Index | Help
PREV CLASS NEXT CLASS | FRAMES NO FRAMES
SUMMARY: NESTED | FIELD | CONSTR | METHOD | DETAIL: FIELD | CONSTR | METHOD