org.joe_e.array
Class FloatArray

java.lang.Object
  extended by org.joe_e.array.ConstArray<E>
      extended by org.joe_e.array.ImmutableArray<E>
          extended by org.joe_e.array.PowerlessArray<Float>
              extended by org.joe_e.array.FloatArray
All Implemented Interfaces:
Serializable, Iterable<Float>, Immutable, Powerless, Selfless

public final class FloatArray
extends PowerlessArray<Float>

An immutable array of float.

See Also:
Serialized Form

Nested Class Summary
static class FloatArray.Builder
          A FloatArray factory.
 
Method Summary
static FloatArray array()
          Construct an empty FloatArray
static FloatArray array(float... floats)
          Constructs an array of floats.
static FloatArray array(float value)
          Construct a FloatArray with one element.
static FloatArray array(float value1, float value2)
          Construct a FloatArray with two elements.
static FloatArray array(float value1, float value2, float value3)
          Construct a FloatArray with three elements.
static FloatArray array(float value1, float value2, float value3, float value4)
          Construct a FloatArray with four elements.
static FloatArray.Builder builder()
          Get a FloatArray.Builder.
static FloatArray.Builder builder(int estimate)
          Get a FloatArray.Builder.
 boolean equals(Object other)
          Test for equality with another object
 Float get(int i)
          Creates a Float for a specified float.
 float getFloat(int i)
          Gets the float at a specified position.
 int hashCode()
          Computes a digest of the array for hashing.
 int length()
          Gets the length of the array.
<T> T[]
toArray(T[] prototype)
          Return a mutable copy of the array
 float[] toFloatArray()
          Creates a mutable copy of the float array
 String toString()
          Return a string representation of the array
 FloatArray with(float newFloat)
          Creates a FloatArray with an appended float.
 FloatArray with(Float newFloat)
          Creates a FloatArray with an appended Float.
 FloatArray without(int i)
          Return a new FloatArray that contains the same elements as this one excluding the element at a specified index
 
Methods inherited from class org.joe_e.array.PowerlessArray
array
 
Methods inherited from class org.joe_e.array.ConstArray
iterator
 
Methods inherited from class java.lang.Object
clone, finalize, getClass, notify, notifyAll, wait, wait, wait
 

Method Detail

array

public static FloatArray array(float... floats)
Constructs an array of floats.

Parameters:
floats - each element

array

public static FloatArray array()
Construct an empty FloatArray


array

public static FloatArray array(float value)
Construct a FloatArray with one element.

Parameters:
value - the value

array

public static FloatArray array(float value1,
                               float value2)
Construct a FloatArray with two elements.

Parameters:
value1 - the first value
value2 - the second value

array

public static FloatArray array(float value1,
                               float value2,
                               float value3)
Construct a FloatArray with three elements.

Parameters:
value1 - the first value
value2 - the second value
value3 - the third value

array

public static FloatArray array(float value1,
                               float value2,
                               float value3,
                               float value4)
Construct a FloatArray with four elements.

Parameters:
value1 - the first value
value2 - the second value
value3 - the third value
value4 - the fourth value

equals

public boolean equals(Object other)
Test for equality with another object

Overrides:
equals in class ConstArray<Float>
Parameters:
other - the reference object with which to compare.
Returns:
true if the other object is a ConstArray with the same contents as this array
See Also:
Object.hashCode(), HashMap

hashCode

public int hashCode()
Computes a digest of the array for hashing. The hash code is the same as Arrays.hashCode(Object[]) called on a Java array containing the same elements.

Specified by:
hashCode in interface Selfless
Overrides:
hashCode in class ConstArray<Float>
Returns:
a hash code based on the contents of this array
See Also:
Object.equals(java.lang.Object), System.identityHashCode(java.lang.Object)

toString

public String toString()
Return a string representation of the array

Overrides:
toString in class ConstArray<Float>
Returns:
a string representation of this array

length

public int length()
Gets the length of the array.

Overrides:
length in class ConstArray<Float>

get

public Float get(int i)
Creates a Float for a specified float.

Overrides:
get in class ConstArray<Float>
Parameters:
i - position of the element to return
Throws:
ArrayIndexOutOfBoundsException - i is out of bounds

toArray

public <T> T[] toArray(T[] prototype)
Return a mutable copy of the array

Overrides:
toArray in class ConstArray<Float>
Parameters:
prototype - prototype of the array to copy into
Returns:
an array containing the contents of this ConstArray of the same type as prototype
Throws:
ArrayStoreException - if an element cannot be stored in the array

with

public FloatArray with(Float newFloat)
Creates a FloatArray with an appended Float.

Overrides:
with in class PowerlessArray<Float>
Parameters:
newFloat - the element to append
Returns:
the new array
Throws:
NullPointerException - newFloat is null

getFloat

public float getFloat(int i)
Gets the float at a specified position.

Parameters:
i - position of the element to return
Throws:
ArrayIndexOutOfBoundsException - i is out of bounds

toFloatArray

public float[] toFloatArray()
Creates a mutable copy of the float array


with

public FloatArray with(float newFloat)
Creates a FloatArray with an appended float.

Parameters:
newFloat - the element to append

without

public FloatArray without(int i)
Return a new FloatArray that contains the same elements as this one excluding the element at a specified index

Overrides:
without in class PowerlessArray<Float>
Parameters:
i - the index of the element to exclude
Returns:
the new array

builder

public static FloatArray.Builder builder()
Get a FloatArray.Builder. This is equivalent to the constructor.

Returns:
a new builder instance, with the default internal array length

builder

public static FloatArray.Builder builder(int estimate)
Get a FloatArray.Builder. This is equivalent to the constructor.

Parameters:
estimate - estimated array length
Returns:
a new builder instance