|
||||||||
PREV CLASS NEXT CLASS | FRAMES NO FRAMES | |||||||
SUMMARY: NESTED | FIELD | CONSTR | METHOD | DETAIL: FIELD | CONSTR | METHOD |
java.lang.Object de.grogra.xl.util.FloatList
public class FloatList
A FloatList
represents a list of float
values.
It provides list- and stack-oriented methods for insertion, addition,
and removal, of values. The methods are not thread-safe.
Field Summary | |
---|---|
float[] |
elements
The array holding the elements. |
int |
size
The size of this list. |
Constructor Summary | |
---|---|
FloatList()
Constructs a new FloatList . |
|
FloatList(float[] elements)
Constructs a new FloatList whose elements are
a copy of elements . |
|
FloatList(int capacity)
Constructs a new FloatList with a given initial capacity. |
Method Summary | |
---|---|
boolean |
add(float o)
Adds o as last element to this list. |
void |
add(int index,
float o)
Inserts o at position index to this list. |
FloatList |
addAll(float[] v,
int begin,
int length)
Appends length components of v to this list,
starting at index begin . |
FloatList |
addAll(FloatList v)
Appends all elements of v to this list. |
void |
addIfNotContained(float o)
Adds o as last element to this list if is not
yet contained as reported by contains(float) . |
static void |
arraycopy(float[] src,
int srcIndex,
float[] dest,
int destIndex,
int length)
|
int |
binarySearch(float value)
Searches this list for the specified value using the binary search algorithm. |
static int |
binarySearch(float[] array,
float value)
|
static int |
binarySearch(float[] array,
float value,
int fromIndex,
int toIndex)
|
void |
clear()
Removes all of the elements from this list. |
static void |
clear(float[] array,
int index,
int length)
|
java.lang.Object |
clone()
|
void |
consume(float value)
Receives a value of type float . |
boolean |
contains(float 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 |
evaluateFloat(FloatConsumer cons)
This generator method yields all values to cons . |
float |
get(int index)
Returns the list element at index . |
int |
hashCode()
|
int |
indexOf(float 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(float o)
Returns the last index of o in this list. |
float |
peek(int index)
Returns the list element at index as seen from
the top, i.e., at absolute position size - index . |
float |
pop()
Removes and returns the object at the top of this list. |
FloatList |
push(float o)
Pushes o on top of this list, i.e., as last element. |
FloatList |
push(float o1,
float o2)
Pushes o1 and o2 on top of this list,
i.e., as last elements. |
FloatList |
push(float o1,
float o2,
float o3)
Pushes o1 ... o3 on top of this list,
i.e., as last elements. |
boolean |
remove(float o)
Removes the element o . |
float |
removeAt(int index)
Removes the element at position index . |
float |
set(int index,
float 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. |
float[] |
toArray()
Returns an array containing the elements of this list. |
float[] |
toArray(float[] array)
Returns an array containing the elements of this list. |
java.lang.String |
toString()
|
void |
trimToSize()
Trims the capacity of this list to be its current size. |
void |
values(FloatConsumer cons)
This method is an alias for evaluateFloat(de.grogra.xl.lang.FloatConsumer) . |
void |
writeTo(java.nio.FloatBuffer out)
|
Methods inherited from class java.lang.Object |
---|
finalize, getClass, notify, notifyAll, wait, wait, wait |
Field Detail |
---|
public transient float[] elements
size - 1
are valid. Direct operation on this
array has to be designed carefully to avoid inconsistencies.
public int size
Constructor Detail |
---|
public FloatList()
FloatList
.
public FloatList(float[] elements)
FloatList
whose elements are
a copy of elements
.
elements
- the initial elements of the listpublic FloatList(int capacity)
FloatList
with a given initial capacity.
capacity
- the initial capacityMethod Detail |
---|
public boolean add(float o)
o
as last element to this list.
o
- the value to add
true
public void add(int index, float o)
o
at position index
to this list.
If index
is not less than size
, the
list is enlarged and filled with 0
-values before.
index
- the insert positiono
- the value to insertpublic FloatList addAll(float[] 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 FloatList addAll(FloatList v)
v
to this list.
v
- the list of elements to add
public void addIfNotContained(float o)
o
as last element to this list if is not
yet contained as reported by contains(float)
.
o
- the value to addpublic static void arraycopy(float[] src, int srcIndex, float[] dest, int destIndex, int length)
public int binarySearch(float value)
value
- the value to be searched for
(-(insertion point) - 1)
. The
insertion point is defined as the point at which the
value would be inserted into the list: the index of the first
element greater than the value, or size()
, if all
elements in the list are less than the specified value.public static int binarySearch(float[] array, float value)
public static int binarySearch(float[] array, float value, int fromIndex, int toIndex)
public void clear()
public static void clear(float[] array, int index, int length)
public java.lang.Object clone()
clone
in class java.lang.Object
public void consume(float value)
FloatConsumer
float
.
consume
in interface FloatConsumer
public boolean contains(float o)
true
iff this list contains the given
element o
.
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 class java.lang.Object
public void evaluateFloat(FloatConsumer cons)
cons
.
evaluateFloat
in interface VoidToFloatGenerator
cons
- the consumer which receives the valuespublic float get(int index)
index
. If
index
is not less than size
,
0
is returned.
index
- the position
index
public int hashCode()
hashCode
in class java.lang.Object
public int indexOf(float o)
o
in this list.
o
- a value
o
, or -1 of o
is not containedpublic final boolean isEmpty()
true
iff this list is emptypublic int lastIndexOf(float o)
o
in this list.
o
- a value
o
, or -1 of o
is not containedpublic float 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 float pop()
public final FloatList push(float o)
o
on top of this list, i.e., as last element.
o
- the value to push
public final FloatList push(float o1, float 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 FloatList push(float o1, float o2, float 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 boolean remove(float o)
o
. The last occurence of
o
in this list is removed.
o
- the element to be removed
true
iff o
was found and removed from the listpublic float removeAt(int index)
index
.
index
- the position of the element to be removed
public float set(int index, float o)
index
to o
.
If index
is not less than size
, the
list is enlarged and filled with 0
-values before.
index
- the positiono
- the new value
index
public void setSize(int size)
0
-values.
size
- the new sizepublic final int size()
public float[] toArray()
public float[] toArray(float[] 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 0
-value is written behind the last copied element.
array
- an array to use
public java.lang.String toString()
toString
in class java.lang.Object
public void trimToSize()
public void values(FloatConsumer cons)
evaluateFloat(de.grogra.xl.lang.FloatConsumer)
.
public void writeTo(java.nio.FloatBuffer out)
|
||||||||
PREV CLASS NEXT CLASS | FRAMES NO FRAMES | |||||||
SUMMARY: NESTED | FIELD | CONSTR | METHOD | DETAIL: FIELD | CONSTR | METHOD |