|
ImageScience 3.0.0 | ||||||
PREV CLASS NEXT CLASS | FRAMES NO FRAMES | ||||||
SUMMARY: NESTED | FIELD | CONSTR | METHOD | DETAIL: FIELD | CONSTR | METHOD |
java.lang.Objectimagescience.array.FloatArray
public class FloatArray
A dynamic array of float
values. Provides more flexibility than float[]
objects and more efficiency than java.util.Vector<Float>
objects.
Constructor Summary | |
---|---|
FloatArray()
Default constructor. |
|
FloatArray(float[] array)
Array constructor. |
|
FloatArray(int capacity)
Capacity constructor. |
|
FloatArray(int capacity,
int increment)
Capacity constructor. |
Method Summary | |
---|---|
void |
add(float f)
Appends the array with the given float . |
void |
append(float f)
Appends the array with the given float . |
float[] |
array()
Returns a handle to the internal array. |
int |
capacity()
Returns the capacity of the array. |
void |
clear()
Removes all elements. |
FloatArray |
duplicate()
Duplicates the array. |
boolean |
empty()
Indicates whether this array has no elements. |
void |
ensure(int capacity)
Ensures that the capacity of the array is at least the given capacity. |
boolean |
equals(FloatArray array)
Indicates whether this array contains the same data as the given array. |
float |
first()
Returns the first element of the array. |
float[] |
get()
Returns a handle to the internal array. |
float |
get(int index)
Returns the element at the given index in the array. |
int |
increment()
Returns the capacity increment of the array. |
void |
increment(int increment)
Sets the capacity increment of the array. |
void |
insert(float f,
int index)
Inserts the given float at the given index in the array. |
float |
last()
Returns the last element of the array. |
int |
length()
Returns the number of elements in the array. |
void |
length(int length)
Sets the length of the array to the given length. |
void |
remove(int index)
Removes the element at the given index from the array. |
void |
reset()
Removes all elements. |
void |
set(float[] array)
Sets the internal array to the given array. |
void |
set(float f,
int index)
Replaces the element at the given index in the array by the given float . |
int |
size()
Returns the number of elements in the array. |
void |
size(int length)
Sets the length of the array to the given length. |
void |
trim()
Trims the capacity of the array down to the length of the array. |
Methods inherited from class java.lang.Object |
---|
equals, getClass, hashCode, notify, notifyAll, toString, wait, wait, wait |
Constructor Detail |
---|
public FloatArray()
0
but with an initial capacity of 10
elements and a capacity increment of 0
.
public FloatArray(int capacity)
0
but with given initial capacity and a capacity increment of 0
.
capacity
- The capacity of the new array.
java.lang.IllegalArgumentException
- If capacity
is less than 0
.public FloatArray(int capacity, int increment)
0
but with given initial capacity and capacity increment.
capacity
- The capacity of the new array.increment
- The capacity increment of the new array. A value less than or equal to 0
means the capacity of the array is doubled each time it needs to grow.
java.lang.IllegalArgumentException
- If capacity
is less than 0
.public FloatArray(float[] array)
0
.
array
- The array initially used as internal array.
java.lang.NullPointerException
- If array
is null
.Method Detail |
---|
public float[] array()
get()
.
capacity()
. By first calling trim()
, the length of the returned array will be equal to the actual number of elements in the array, that is the value returned by length()
.public int length()
size()
.
public void length(int length)
size(int)
.
length
- The new length of the array. If the value of this parameter is less than the current length, the current length is simply set to the given length, without changing the capacity of the array. If it is larger than the current length, the capacity of the array is adjusted as necessary. The capacity increment is retained.
java.lang.IllegalArgumentException
- If length
is less than 0
.public int size()
length()
.
public void size(int length)
length(int)
.
length
- The new length of the array. If the value of this parameter is less than the current length, the current length is simply set to the given length, without changing the capacity of the array. If it is larger than the current length, the capacity of the array is adjusted as necessary. The capacity increment is retained.
java.lang.IllegalArgumentException
- If length
is less than 0
.public boolean empty()
true
if the array has no elements, that is if the length of the array is 0
, or false
otherwise.public int capacity()
public int increment()
public void increment(int increment)
increment
- The new capacity increment of the array. A value less than or equal to 0
means the capacity of the array is doubled each time it needs to grow.public float[] get()
array()
.
capacity()
. By first calling trim()
, the length of the returned array will be equal to the actual number of elements in the array, that is the value returned by length()
.public float get(int index)
index
- The index.
java.lang.ArrayIndexOutOfBoundsException
- If index
is less than 0
or larger than or equal to the length of the array.public float first()
java.util.NoSuchElementException
- If the length of the array is 0
.public float last()
java.util.NoSuchElementException
- If the length of the array is 0
.public void add(float f)
float
. The same as method append(float)
.
f
- The float
to be appended to the array.public void append(float f)
float
. The same as method add(float)
.
f
- The float
to be appended to the array.public void insert(float f, int index)
float
at the given index in the array.
f
- The float
to be inserted in the array.index
- The index at which f
is inserted. The indices of the elements originally at this index and higher are increased by 1
.
java.lang.ArrayIndexOutOfBoundsException
- If index
is less than 0
or larger than or equal to the length of the array.public void set(float f, int index)
float
.
f
- The float
to be placed in the array.index
- The index at which f
is to be placed.
java.lang.ArrayIndexOutOfBoundsException
- If index
is less than 0
or larger than or equal to the length of the array.public void set(float[] array)
array
- The array to which the internal array is to be set. The length and capacity of the array are both set to the length of the given array. The capacity increment is retained.
java.lang.NullPointerException
- If array
is null
.public void reset()
clear()
. The length of the array is set to 0
but the capacity and capacity increment are retained.
public void clear()
reset()
. The length of the array is set to 0
but the capacity and capacity increment are retained.
public void trim()
public void remove(int index)
index
- The index whose element is to be removed from the array. The indices of the elements at the next index and higher are decreased by 1
.
java.lang.ArrayIndexOutOfBoundsException
- If index
is less than 0
or larger than or equal to the length of the array.public FloatArray duplicate()
FloatArray
object that is an exact copy of this object. All information is copied and no memory is shared between this and the returned object.public void ensure(int capacity)
capacity
- The minimum capacity that the array is ensured to have.public boolean equals(FloatArray array)
array
- The array to compare this array with.
true
if array
is not null
, has the same length as this array, and each element of array
has the exact same value as the corresponding element of this array, or false
if this is not the case.
|
ImageScience 3.0.0 | ||||||
PREV CLASS NEXT CLASS | FRAMES NO FRAMES | ||||||
SUMMARY: NESTED | FIELD | CONSTR | METHOD | DETAIL: FIELD | CONSTR | METHOD |
Copyright (C) Erik Meijering. Permission to use this software and corresponding documentation for educational, research, and not-for-profit purposes, without a fee and without a signed licensing agreement, is granted, subject to the following terms and conditions.
IT IS NOT ALLOWED TO REDISTRIBUTE, SELL, OR LEASE THIS SOFTWARE, OR DERIVATIVE WORKS THEREOF, WITHOUT PERMISSION IN WRITING FROM THE COPYRIGHT HOLDER. THE COPYRIGHT HOLDER IS FREE TO MAKE VERSIONS OF THE SOFTWARE AVAILABLE FOR A FEE OR COMMERCIALLY ONLY.
IN NO EVENT SHALL THE COPYRIGHT HOLDER BE LIABLE TO ANY PARTY FOR DIRECT, INDIRECT, SPECIAL, INCIDENTAL, OR CONSEQUENTIAL DAMAGES, OF ANY KIND WHATSOEVER, ARISING OUT OF THE USE OF THIS SOFTWARE AND ITS DOCUMENTATION, EVEN IF ADVISED OF THE POSSIBILITY THEREOF.
THE COPYRIGHT HOLDER SPECIFICALLY DISCLAIMS ANY WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE EXPRESS OR IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE. THE SOFTWARE AND CORRESPONDING DOCUMENTATION IS PROVIDED "AS IS". THE COPYRIGHT HOLDER HAS NO OBLIGATION TO PROVIDE MAINTENANCE, SUPPORT, UPDATES, ENHANCEMENTS, OR MODIFICATIONS.