|
Graphics2D Actor API | |||||||||
| PREV CLASS NEXT CLASS | FRAMES NO FRAMES | |||||||||
| SUMMARY: NESTED | FIELD | CONSTR | METHOD | DETAIL: FIELD | CONSTR | METHOD | |||||||||
java.lang.Objectjava.util.AbstractCollection
java.util.AbstractList
g2d.jlambda.List
public class List
Nearest thing to a Lisp List I have come up with so far. The only anomaly
is that the empty list () is actually a cons cell with the
empty flag switched on. Square pegs & round holes. This version of List
is built upon the AbstractList and is both modifiable
and of variable size.
AbstractSequentialList
December 11th 2005.)| Field Summary | |
|---|---|
protected Object |
car
The car of this List, and arbitrary Object. |
protected List |
cdr
The cdr, or rest, of this list. |
protected boolean |
empty
A flag to distinguish an empty list from an non-empty one. |
| Fields inherited from class java.util.AbstractList |
|---|
modCount |
| Constructor Summary | |
|---|---|
List()
Creates a new empty list. |
|
List(Collection collection)
Creates a new list from the given Collection. |
|
List(Object[] array)
Creates a new list from the given object array. |
|
List(Object car,
List cdr)
Adds a new element onto an existing list. |
|
| Method Summary | |
|---|---|
void |
add(int index,
Object element)
As specified by the AbstractList template. |
static List |
array2List(Object obj)
|
Object |
caar()
The car of the car of this list. |
Object |
caddr()
The car of the cdr of the cdr. |
Object |
cadr()
The car of the cdr of this list. |
Object |
car()
The ubiquitous Lisp/Scheme car accessor. |
Object |
cdar()
The cdr of the car of this list. |
List |
cddr()
The cdr of the cdr of this list. |
List |
cdr()
The ubiquitous Lisp/Scheme cdr accessor. |
Object |
get(int index)
As specified by the AbstractList template. |
boolean |
isEmpty()
Determines if this list is empty. |
int |
length()
The length, or number of elements, in this list. |
static List |
list()
A static convenience method, that creates new empty lists. |
static List |
list(Object o1)
A static convenience method, that creates a new singleton list. |
static List |
list(Object o1,
Object o2)
A static convenience method, that creates a new list with two elements. |
static List |
list(Object a,
Object b,
Object c)
A static convenience method, that creates a new list with two elements. |
static void |
main(String[] args)
|
Object |
nth(int n)
Returns the nth element of this list, starting from zero. |
Object |
remove(int index)
As specified by the AbstractList template. |
Object |
set(int index,
Object element)
As specified by the AbstractList template. |
int |
size()
As specified by the AbstractList template. |
protected List |
snoc(Iterator iter)
Adds the contents of the Iterator object destructively onto the end of this list. |
protected List |
snoc(Object obj)
Destructively updates this, which must be an empty list, so that it's car in the obj passed in, and it's cdr is a new empty list. |
protected List |
snoc(Object[] array)
Adds the contents of the array of Objects destructively onto the end of this list. |
String |
toString()
The unprettyprinted String representation of this list. |
| Methods inherited from class java.util.AbstractList |
|---|
add, addAll, clear, equals, hashCode, indexOf, iterator, lastIndexOf, listIterator, listIterator, removeRange, subList |
| Methods inherited from class java.util.AbstractCollection |
|---|
addAll, contains, containsAll, remove, removeAll, retainAll, toArray, toArray |
| 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 |
| Field Detail |
|---|
protected Object car
protected List cdr
protected boolean empty
| Constructor Detail |
|---|
public List()
public List(Object car,
List cdr)
car - the new first element of the resulting new list.cdr - the tail of the resulting new list.public List(Collection collection)
collection - the collection whose members will make up the new list.
It creates an new empty list if the collection is null.public List(Object[] array)
array - the object array whose members will make up the new list.
It creates an new empty list if the array reference is null.| Method Detail |
|---|
public static List array2List(Object obj)
public int size()
AbstractList template.
The length, or number of elements, in this list.
size in interface Collectionsize in interface Listsize in class AbstractCollectionpublic Object get(int index)
AbstractList template.
get in interface Listget in class AbstractList
public void add(int index,
Object element)
AbstractList template.
add in interface Listadd in class AbstractListpublic Object remove(int index)
AbstractList template.
remove in interface Listremove in class AbstractList
public Object set(int index,
Object element)
AbstractList template.
set in interface Listset in class AbstractListpublic static List list()
public static List list(Object o1)
o1 - the single element of the new list.
public static List list(Object o1,
Object o2)
o1 - the first element of the new list.o2 - the second element of the new list.
public static List list(Object a,
Object b,
Object c)
a - the first element of the new list.b - the second element of the new list.c - the thrid element of the new list.
public final Object car()
-ea flag
this will generate a failed assertion, otherwise null will be returned.
public final List cdr()
-ea flag
this will generate a failed assertion, otherwise null will be returned.
public final Object caar()
ClassCastException - if the car of the list is not a List, and
assertions are not enabled.public final Object cadr()
public final Object cdar()
ClassCastException - if the car of the list is not a List, and
assertions are not enabled.public final List cddr()
public final Object caddr()
public Object nth(int n)
n - an int specifying the element to return, starting from zero.
NullPointerException - if the list has fewer elements.public boolean isEmpty()
isEmpty in interface CollectionisEmpty in interface ListisEmpty in class AbstractCollectionpublic int length()
public String toString()
toString in class AbstractCollectionpublic static void main(String[] args)
protected List snoc(Object obj)
obj - the new car.
protected List snoc(Iterator iter)
iter - an Iterator.
protected List snoc(Object[] array)
array - an array of objects.
|
Graphics2D Actor API | |||||||||
| PREV CLASS NEXT CLASS | FRAMES NO FRAMES | |||||||||
| SUMMARY: NESTED | FIELD | CONSTR | METHOD | DETAIL: FIELD | CONSTR | METHOD | |||||||||