Package blbutil
Class FloatArray
java.lang.Object
blbutil.FloatArray
Class
FloatArray represents an immutable list of float floating
point values.-
Constructor Summary
ConstructorsConstructorDescriptionFloatArray(double[] values) Constructs anFloatArrayobject with the specified values.FloatArray(float[] values) Constructs anFloatArrayobject with the specified values. -
Method Summary
Modifier and TypeMethodDescriptionintbinarySearch(float key) Searchesthisfor the specified value using the binary search algorithm.intbinarySearch(int fromIndex, int toIndex, float key) Searches the specified range ofthisfor the specified value using the binary search algorithm.static FloatArrayfromIntBits(int[] bits) Constructs and returns a FloatArray from the specified list of bit representations.floatget(int index) Returns the float at the specified position in this list.booleanisEmpty()Returnstrueif this list has no elements, and returnsfalseotherwise.intsize()Returns the number of elements in this list.float[]toArray()Returns an integer array containing the sequence of elements in this list.toString()Returns a string representation of this list that is obtained by callingjava.util.Arrays.toString(this.toArray()).
-
Constructor Details
-
FloatArray
public FloatArray(float[] values) Constructs anFloatArrayobject with the specified values.- Parameters:
values- the list of floating point values- Throws:
NullPointerException- ifvalues == null
-
FloatArray
public FloatArray(double[] values) Constructs anFloatArrayobject with the specified values.- Parameters:
values- the list of floating point values- Throws:
NullPointerException- ifvalues == null
-
-
Method Details
-
fromIntBits
Constructs and returns a FloatArray from the specified list of bit representations. Eachintegeris transformed into a float using theFloat.intBitsToFloat()method.- Parameters:
bits- a list of bit- Returns:
- a
FloatArray
-
get
public float get(int index) Returns the float at the specified position in this list.- Parameters:
index- the index of the returned float- Returns:
- the float at the specified position in this list
- Throws:
IndexOutOfBoundsException- ifindex < 0 || index >= size
-
size
public int size()Returns the number of elements in this list.- Returns:
- the number of elements in this list
-
isEmpty
public boolean isEmpty()Returnstrueif this list has no elements, and returnsfalseotherwise.- Returns:
trueif this list has no elements, and returnsfalseotherwise
-
binarySearch
public int binarySearch(float key) Searchesthisfor the specified value using the binary search algorithm. This list must be sorted (as by thejava.util.Arrays.sort(float[])method) prior to making this call. If it is not sorted, the results are undefined. If the list contains multiple elements with the specified value, there is no guarantee which one will be found. This method considers all NaN values to be equivalent and equal.- Parameters:
key- the value to be searched for- Returns:
- index of the search key, if it is contained in the list;
otherwise,
(-(insertion point) - 1). The insertion point is defined as the point at which the key would be inserted into the list: the index of the first element greater than the key, orthis.size()if all elements in the list are less than the specified key. Note that this guarantees that the return value will be>= 0if and only if the key is found.
-
binarySearch
public int binarySearch(int fromIndex, int toIndex, float key) Searches the specified range ofthisfor the specified value using the binary search algorithm. This range must be sorted (as by thejava.util.Arrays.sort(float[])method) prior to making this call. If it is not sorted, the results are undefined. If the range contains multiple elements with the specified value, there is no guarantee which one will be found. This method considers all NaN values to be equivalent and equal.- Parameters:
fromIndex- the index of the first element (inclusive) to be searchedtoIndex- the index of the last element (exclusive) to be searchedkey- the value to be searched for- Returns:
- index of the search key, if it is contained in the list;
otherwise,
(-(insertion point) - 1). The insertion point is defined as the point at which the key would be inserted into the list: the index of the first element greater than the key, orthis.size()if all elements in the list are less than the specified key. Note that this guarantees that the return value will be>= 0if and only if the key is found. - Throws:
IllegalArgumentException- iffromIndex > toIndexArrayIndexOutOfBoundsException- iffromIndex < 0 || toIndex > this.size()
-
toArray
public float[] toArray()Returns an integer array containing the sequence of elements in this list.- Returns:
- an integer array containing the sequence of elements in this list
-
toString
Returns a string representation of this list that is obtained by callingjava.util.Arrays.toString(this.toArray()).
-