ix.util.lisp
Class LListCollector
java.lang.Object
java.util.AbstractCollection<E>
java.util.AbstractList<E>
java.util.AbstractSequentialList
ix.util.lisp.LListCollector
- All Implemented Interfaces:
- Collector, java.io.Serializable, java.lang.Iterable, java.util.Collection, java.util.List
public class LListCollector
- extends java.util.AbstractSequentialList
- implements Collector, java.io.Serializable
A Collector that uses an LList to hold the elements and that provides
a number of different ways to add elements.
As a Java Collection, it is sequential, variable-sized, and modifiable.
Unlike Java's LinkedList class, which uses a doubly-linked list
internally, this class uses a list that is only forward-linked;
but it maintains a pointer to the last cell in the list to allow
elements to be added efficiently at either the beginning or end.
However, deleting the last element takes time proportional to
the length of the list. LListCollectors can therefore be used
efficiently as stacks or queues, but not as double-ended queues
(deques).
The ListIterator for this class can efficiently add or remove
at any point in the list except for deleting the last element,
which again requires time proportional to the length. Note
that some of these operations may change a car as well as a cdr.
- See Also:
- Serialized Form
Fields inherited from class java.util.AbstractList |
modCount |
Methods inherited from class java.util.AbstractSequentialList |
add, addAll, get, iterator, remove, set |
Methods inherited from class java.util.AbstractList |
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 |
clone, finalize, getClass, notify, notifyAll, wait, wait, wait |
Methods inherited from interface java.util.List |
addAll, contains, containsAll, remove, removeAll, retainAll, toArray, toArray |
head
transient Cons head
tail
Cons tail
LListCollector
public LListCollector()
LListCollector
public LListCollector(java.util.Collection initialContents)
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
add
public boolean add(java.lang.Object o)
- Specified by:
add
in interface java.util.Collection
- Specified by:
add
in interface java.util.List
- Overrides:
add
in class java.util.AbstractList
clear
public void clear()
- Specified by:
clear
in interface java.util.Collection
- Specified by:
clear
in interface java.util.List
- Overrides:
clear
in class java.util.AbstractList
lastIndexOf
public int lastIndexOf(java.lang.Object o)
- Specified by:
lastIndexOf
in interface java.util.List
- Overrides:
lastIndexOf
in class java.util.AbstractList
addElement
public void addElement(java.lang.Object e)
- Specified by:
addElement
in interface Collector
deleteElement
public void deleteElement(java.lang.Object e)
pushElement
public void pushElement(java.lang.Object e)
firstElement
public java.lang.Object firstElement()
popElement
public java.lang.Object popElement()
popToAny
public LList popToAny(java.util.Collection delimiters)
insertElement
public void insertElement(java.lang.Object e,
Predicate2 lessp)
elements
public java.util.Enumeration elements()
contents
public LList contents()
result
public java.lang.Object result()
- Specified by:
result
in interface Collector
setContents
public void setContents(LList newContents)
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
length
public int length()
concLList
public void concLList(LList l)
appendLList
public void appendLList(LList l)
pushLList
public void pushLList(LList l)
elementAdder
public Function1 elementAdder()
elementPusher
public Function1 elementPusher()
llistAppender
public Function1 llistAppender()
llistConcer
public Function1 llistConcer()