|
||||||||
PREV CLASS NEXT CLASS | FRAMES NO FRAMES | |||||||
SUMMARY: NESTED | FIELD | CONSTR | METHOD | DETAIL: FIELD | CONSTR | METHOD |
java.lang.Object java.util.AbstractCollection<E> java.util.AbstractList<E> de.grogra.xl.util.ObjectList<E>
public class ObjectList<E>
A ObjectList
represents a list of Object
values.
It provides list- and stack-oriented methods for insertion, addition,
and removal, of values. The methods are not thread-safe.
Field Summary | |
---|---|
java.lang.Object[] |
elements
The array holding the elements. |
int |
size
The size of this list. |
boolean |
useEquals
Determines whether comparisons between objects should be based on the equals -method or on the equality operator
== . |
Fields inherited from class java.util.AbstractList |
---|
modCount |
Constructor Summary | |
---|---|
ObjectList()
Constructs a new ObjectList . |
|
ObjectList(E[] elements)
Constructs a new ObjectList whose elements are
a copy of elements . |
|
ObjectList(int capacity)
Constructs a new ObjectList with a given initial capacity. |
|
ObjectList(int capacity,
boolean useEquals)
Constructs a new ObjectList with a given initial capacity. |
Method Summary | ||
---|---|---|
boolean |
add(E o)
Adds o as last element to this list. |
|
void |
add(int index,
E o)
Inserts o at position index to this list. |
|
boolean |
addAll(java.util.Collection<? extends E> v)
Appends all elements of v to this list. |
|
ObjectList<E> |
addAll(java.lang.Object[] v,
int begin,
int length)
Appends length components of v to this list,
starting at index begin . |
|
ObjectList<E> |
addAll(ObjectList<? extends E> v)
Appends all elements of v to this list. |
|
void |
addIfNotContained(E o)
Adds o as last element to this list if is not
yet contained as reported by contains(Object) . |
|
void |
addInOrder(java.lang.Comparable<? super E> o)
Inserts o into this ordered list. |
|
void |
addInOrder(E o,
java.util.Comparator<? super E> c)
Inserts o into this ordered list, based on c . |
|
static void |
arraycopy(java.lang.Object[] src,
int srcIndex,
java.lang.Object[] dest,
int destIndex,
int length)
|
|
void |
clear()
Removes all of the elements from this list. |
|
static void |
clear(java.lang.Object[] array,
int index,
int length)
|
|
java.lang.Object |
clone()
|
|
void |
consume(E value)
Receives a value of type T . |
|
boolean |
contains(java.lang.Object o)
Returns true iff this list contains the given
element o . |
|
void |
ensureCapacity(int capacity)
Ensures a capacity of the internal array of at least capacity . |
|
boolean |
equals(java.lang.Object o)
|
|
void |
evaluateObject(ObjectConsumer<? super E> cons)
This generator method yields all values to cons . |
|
E |
get(int index)
Returns the list element at index . |
|
int |
hashCode()
|
|
int |
indexOf(java.lang.Object o)
Returns the index of o in this list. |
|
boolean |
isEmpty()
Returns if this list is empty, i.e., if its size is zero. |
|
int |
lastIndexOf(java.lang.Object o)
Returns the last index of o in this list. |
|
E |
peek(int index)
Returns the list element at index as seen from
the top, i.e., at absolute position size - index . |
|
E |
pop()
Removes and returns the object at the top of this list. |
|
ObjectList<E> |
push(E o)
Pushes o on top of this list, i.e., as last element. |
|
ObjectList<E> |
push(E o1,
E o2)
Pushes o1 and o2 on top of this list,
i.e., as last elements. |
|
ObjectList<E> |
push(E o1,
E o2,
E o3)
Pushes o1 ... o3 on top of this list,
i.e., as last elements. |
|
E |
remove(int index)
Removes the element at position index . |
|
boolean |
remove(java.lang.Object o)
Removes the element o . |
|
E |
removeAt(int index)
Removes the element at position index . |
|
E |
set(int index,
E o)
Sets the element at position index to o . |
|
void |
setSize(int size)
Sets the size of this list to the given value. |
|
int |
size()
Returns the size of this list. |
|
java.lang.Object[] |
toArray()
Returns an array containing the elements of this list. |
|
|
toArray(T[] array)
Returns an array containing the elements of this list. |
|
void |
trimToSize()
Trims the capacity of this list to be its current size. |
|
void |
values(ObjectConsumer<? super E> cons)
This method is an alias for evaluateObject(de.grogra.xl.lang.ObjectConsumer super E>) . |
Methods inherited from class java.util.AbstractList |
---|
addAll, iterator, listIterator, listIterator, removeRange, subList |
Methods inherited from class java.util.AbstractCollection |
---|
containsAll, removeAll, retainAll, toString |
Methods inherited from class java.lang.Object |
---|
finalize, getClass, notify, notifyAll, wait, wait, wait |
Methods inherited from interface java.util.List |
---|
containsAll, removeAll, retainAll |
Field Detail |
---|
public transient java.lang.Object[] elements
size - 1
are valid. Direct operation on this
array has to be designed carefully to avoid inconsistencies.
public int size
public boolean useEquals
equals
-method or on the equality operator
==
.
Constructor Detail |
---|
public ObjectList()
ObjectList
.
public ObjectList(E[] elements)
ObjectList
whose elements are
a copy of elements
.
elements
- the initial elements of the listpublic ObjectList(int capacity)
ObjectList
with a given initial capacity.
capacity
- the initial capacitypublic ObjectList(int capacity, boolean useEquals)
ObjectList
with a given initial capacity.
capacity
- the initial capacityuseEquals
- the value for useEquals
Method Detail |
---|
public boolean add(E o)
o
as last element to this list.
add
in interface java.util.Collection<E>
add
in interface java.util.List<E>
add
in class java.util.AbstractList<E>
o
- the value to add
true
public void add(int index, E o)
o
at position index
to this list.
If index
is not less than size
, the
list is enlarged and filled with null
-values before.
add
in interface java.util.List<E>
add
in class java.util.AbstractList<E>
index
- the insert positiono
- the value to insertpublic boolean addAll(java.util.Collection<? extends E> v)
v
to this list.
addAll
in interface java.util.Collection<E>
addAll
in interface java.util.List<E>
addAll
in class java.util.AbstractCollection<E>
v
- the list of elements to add
true
iff this list changed as a result of the invocationpublic ObjectList<E> addAll(java.lang.Object[] v, int begin, int length)
length
components of v
to this list,
starting at index begin
.
v
- the array of elements to addbegin
- the array index to begin withlength
- the number of elements to add
public ObjectList<E> addAll(ObjectList<? extends E> v)
v
to this list.
v
- the list of elements to add
public void addIfNotContained(E o)
o
as last element to this list if is not
yet contained as reported by contains(Object)
.
o
- the value to addpublic void addInOrder(java.lang.Comparable<? super E> o)
o
into this ordered list.
This list has to be sorted in ascending order as defined by
o
. o
will then be added at a position
according to this order.
o
- the value to addpublic void addInOrder(E o, java.util.Comparator<? super E> c)
o
into this ordered list, based on c
.
This list has to be sorted in ascending order as defined by
c
. o
will then be added at a position
according to this order.
o
- the value to addc
- the comparator which defines the orderpublic static void arraycopy(java.lang.Object[] src, int srcIndex, java.lang.Object[] dest, int destIndex, int length)
public void clear()
clear
in interface java.util.Collection<E>
clear
in interface java.util.List<E>
clear
in class java.util.AbstractList<E>
public static void clear(java.lang.Object[] array, int index, int length)
public java.lang.Object clone()
clone
in class java.lang.Object
public void consume(E value)
ObjectConsumer
T
.
consume
in interface ObjectConsumer<E>
public boolean contains(java.lang.Object o)
true
iff this list contains the given
element o
.
contains
in interface java.util.Collection<E>
contains
in interface java.util.List<E>
contains
in class java.util.AbstractCollection<E>
o
- a value
true
iff o
is containedpublic void ensureCapacity(int capacity)
capacity
.
capacity
- the desired minimum capacitypublic boolean equals(java.lang.Object o)
equals
in interface java.util.Collection<E>
equals
in interface java.util.List<E>
equals
in class java.util.AbstractList<E>
public void evaluateObject(ObjectConsumer<? super E> cons)
cons
.
evaluateObject
in interface VoidToObjectGenerator<E>
cons
- the consumer which receives the valuespublic E get(int index)
index
. If
index
is not less than size
,
null
is returned.
get
in interface java.util.List<E>
get
in class java.util.AbstractList<E>
index
- the position
index
public int hashCode()
hashCode
in interface java.util.Collection<E>
hashCode
in interface java.util.List<E>
hashCode
in class java.util.AbstractList<E>
public int indexOf(java.lang.Object o)
o
in this list.
indexOf
in interface java.util.List<E>
indexOf
in class java.util.AbstractList<E>
o
- a value
o
, or -1 of o
is not containedpublic final boolean isEmpty()
isEmpty
in interface java.util.Collection<E>
isEmpty
in interface java.util.List<E>
isEmpty
in class java.util.AbstractCollection<E>
true
iff this list is emptypublic int lastIndexOf(java.lang.Object o)
o
in this list.
lastIndexOf
in interface java.util.List<E>
lastIndexOf
in class java.util.AbstractList<E>
o
- a value
o
, or -1 of o
is not containedpublic E peek(int index)
index
as seen from
the top, i.e., at absolute position size - index
.
Thus, the topmost element has index 1.
index
- the position as seen from the top
public E pop()
public final ObjectList<E> push(E o)
o
on top of this list, i.e., as last element.
o
- the value to push
public final ObjectList<E> push(E o1, E o2)
o1
and o2
on top of this list,
i.e., as last elements. The effect is the same as the invocation
list.push(o1).push(o2)
.
o1
- the first value to pusho2
- the second value to push
public final ObjectList<E> push(E o1, E o2, E o3)
o1 ... o3
on top of this list,
i.e., as last elements. The effect is the same as the invocation
list.push(o1).push(o2).push(o3)
.
o1
- the first value to pusho2
- the second value to pusho3
- the third value to push
public E remove(int index)
index
.
remove
in interface java.util.List<E>
remove
in class java.util.AbstractList<E>
index
- the position of the element to be removed
public boolean remove(java.lang.Object o)
o
. The last occurence of
o
in this list is removed.
remove
in interface java.util.Collection<E>
remove
in interface java.util.List<E>
remove
in class java.util.AbstractCollection<E>
o
- the element to be removed
true
iff o
was found and removed from the listpublic E removeAt(int index)
index
.
index
- the position of the element to be removed
public E set(int index, E o)
index
to o
.
If index
is not less than size
, the
list is enlarged and filled with null
-values before.
set
in interface java.util.List<E>
set
in class java.util.AbstractList<E>
index
- the positiono
- the new value
index
public void setSize(int size)
null
-values.
size
- the new sizepublic final int size()
size
in interface java.util.Collection<E>
size
in interface java.util.List<E>
size
in class java.util.AbstractCollection<E>
public java.lang.Object[] toArray()
toArray
in interface java.util.Collection<E>
toArray
in interface java.util.List<E>
toArray
in class java.util.AbstractCollection<E>
public <T> T[] toArray(T[] array)
array
. If this
list fits in the specified array
,
it is returned therein. Otherwise,
a new array is allocated whose length is the size of this list's size,
the values of this list are copied into the new array, and this
array is returned.
If there is room for an additional element in the array
,
a null
-value is written behind the last copied element.
toArray
in interface java.util.Collection<E>
toArray
in interface java.util.List<E>
toArray
in class java.util.AbstractCollection<E>
array
- an array to use
public void trimToSize()
public void values(ObjectConsumer<? super E> cons)
evaluateObject(de.grogra.xl.lang.ObjectConsumer super E>)
.
|
||||||||
PREV CLASS NEXT CLASS | FRAMES NO FRAMES | |||||||
SUMMARY: NESTED | FIELD | CONSTR | METHOD | DETAIL: FIELD | CONSTR | METHOD |