org.joe_e.array
Class LongArray

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<Long>
              extended by org.joe_e.array.LongArray
All Implemented Interfaces:
Serializable, Iterable<Long>, Immutable, Powerless, Selfless

public final class LongArray
extends PowerlessArray<Long>

An immutable array of long.

See Also:
Serialized Form

Nested Class Summary
static class LongArray.Builder
          A LongArray factory.
 
Method Summary
static LongArray array()
          Construct an empty LongArray
static LongArray array(long... longs)
          Constructs an array of longs.
static LongArray array(long value)
          Construct a LongArray with one element.
static LongArray array(long value1, long value2)
          Construct a LongArray with two elements.
static LongArray array(long value1, long value2, long value3)
          Construct a LongArray with three elements.
static LongArray array(long value1, long value2, long value3, long value4)
          Construct a LongArray with four elements.
static LongArray.Builder builder()
          Get a LongArray.Builder.
static LongArray.Builder builder(int estimate)
          Get a LongArray.Builder.
 boolean equals(Object other)
          Test for equality with another object
 Long get(int i)
          Creates a Long for a specified long.
 long getLong(int i)
          Gets the long 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
 long[] toLongArray()
          Creates a mutable copy of the long array
 String toString()
          Return a string representation of the array
 LongArray with(long newLong)
          Creates a LongArray with an appended long.
 LongArray with(Long newLong)
          Creates a LongArray with an appended Long.
 LongArray without(int i)
          Return a new LongArray 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 LongArray array(long... longs)
Constructs an array of longs.

Parameters:
longs - each element

array

public static LongArray array()
Construct an empty LongArray


array

public static LongArray array(long value)
Construct a LongArray with one element.

Parameters:
value - the value

array

public static LongArray array(long value1,
                              long value2)
Construct a LongArray with two elements.

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

array

public static LongArray array(long value1,
                              long value2,
                              long value3)
Construct a LongArray with three elements.

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

array

public static LongArray array(long value1,
                              long value2,
                              long value3,
                              long value4)
Construct a LongArray 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<Long>
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<Long>
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<Long>
Returns:
a string representation of this array

length

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

Overrides:
length in class ConstArray<Long>

get

public Long get(int i)
Creates a Long for a specified long.

Overrides:
get in class ConstArray<Long>
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<Long>
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 LongArray with(Long newLong)
Creates a LongArray with an appended Long.

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

getLong

public long getLong(int i)
Gets the long at a specified position.

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

toLongArray

public long[] toLongArray()
Creates a mutable copy of the long array


with

public LongArray with(long newLong)
Creates a LongArray with an appended long.

Parameters:
newLong - the element to append

without

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

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

builder

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

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

builder

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

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