|
sdr 0.7 | |||||||||
PREV CLASS NEXT CLASS | FRAMES NO FRAMES | |||||||||
SUMMARY: NESTED | FIELD | CONSTR | METHOD | DETAIL: FIELD | CONSTR | METHOD |
java.lang.Object net.cscott.sdr.util.LL<T>
public class LL<T>
Persistent Linked List.
Field Summary | |
---|---|
T |
head
Element at the start of the list |
LL<T> |
tail
Remainder of the elements in the list. |
Constructor Summary | |
---|---|
LL(T head,
LL<T> tail)
Add an element to the front of tail . |
Method Summary | ||
---|---|---|
static
|
create(List<T> elements)
Factory: create a list. |
|
static
|
create(T... elements)
Factory: create a list. |
|
boolean |
isEmpty()
Are there any elements in this list? |
|
Iterator<T> |
iterator()
Iterate over all the elements in this list from head to tail. |
|
static
|
NULL()
Return a new empty list. |
|
LL<T> |
pop()
Remove the head of the list. |
|
LL<T> |
push(T head)
Add the given element to the start of the list. |
|
LL<T> |
reverse()
Return a list with elements in reverse order. |
|
int |
size()
Return the number of items in this list. |
|
List<T> |
toList()
|
|
String |
toString()
|
Methods inherited from class java.lang.Object |
---|
clone, equals, finalize, getClass, hashCode, notify, notifyAll, wait, wait, wait |
Field Detail |
---|
public final T head
public final LL<T> tail
Constructor Detail |
---|
public LL(T head, LL<T> tail)
tail
.
Method Detail |
---|
public static <T> LL<T> create(T... elements)
js> l = LL.create("a","b","c","d"); [a, b, c, d]
public static <T> LL<T> create(List<T> elements)
js> l = LL.create(java.util.Arrays.asList("a","b","c","d")); [a, b, c, d]
public LL<T> push(T head)
js> l = LL.create("a","b","c","d"); [a, b, c, d] js> l = l.push("e"); [e, a, b, c, d] js> l = l.push("f"); [f, e, a, b, c, d]
public LL<T> pop()
js> l = LL.create("a","b","c","d"); [a, b, c, d] js> l = l.pop(); [b, c, d] js> l = l.pop(); [c, d] js> l = l.pop(); [d] js> l = l.pop(); []
public boolean isEmpty()
js> l = LL.create("a","b","c","d"); [a, b, c, d] js> l.isEmpty() false js> LL.NULL().isEmpty() true
public int size()
js> l = LL.create("a","b","c","d"); [a, b, c, d] js> l.size() 4 js> LL.NULL().size() 0
public Iterator<T> iterator()
iterator
in interface Iterable<T>
js> l = LL.create("a","b","c","d"); [a, b, c, d] js> [x for (x in Iterator(l))] a,b,c,d js> [x for (x in Iterator(LL.NULL()))].length 0
public static <T> LL<T> NULL()
js> LL.NULL(); [] js> LL.NULL().isEmpty(); true
public LL<T> reverse()
js> l = LL.create("asda","bar","foo"); [asda, bar, foo] js> l.reverse(); [foo, bar, asda] js> l = LL.NULL(); [] js> l.reverse(); []
public String toString()
toString
in class Object
public List<T> toList()
|
sdr 0.7 | |||||||||
PREV CLASS NEXT CLASS | FRAMES NO FRAMES | |||||||||
SUMMARY: NESTED | FIELD | CONSTR | METHOD | DETAIL: FIELD | CONSTR | METHOD |