|
ref_send API 2.17 defensive programming in Java |
|||||||||
PREV CLASS NEXT CLASS | FRAMES NO FRAMES | |||||||||
SUMMARY: NESTED | FIELD | CONSTR | METHOD | DETAIL: FIELD | CONSTR | METHOD |
java.lang.Object org.joe_e.array.ConstArray<E> org.joe_e.array.ImmutableArray<E> org.joe_e.array.PowerlessArray<java.lang.Integer> org.joe_e.array.IntArray
public final class IntArray
An immutable array of int
.
Nested Class Summary | |
---|---|
static class |
IntArray.Builder
A IntArray factory. |
Method Summary | ||
---|---|---|
static IntArray |
array()
Construct an empty IntArray |
|
static IntArray |
array(int... ints)
Constructs an array of int s. |
|
static IntArray |
array(int value)
Construct a IntArray with one element. |
|
static IntArray |
array(int value1,
int value2)
Construct a IntArray with two elements. |
|
static IntArray |
array(int value1,
int value2,
int value3)
Construct a IntArray with three elements. |
|
static IntArray |
array(int value1,
int value2,
int value3,
int value4)
Construct a IntArray with four elements. |
|
static IntArray.Builder |
builder()
Get a IntArray.Builder . |
|
static IntArray.Builder |
builder(int estimate)
Get a IntArray.Builder . |
|
boolean |
equals(java.lang.Object other)
Test for equality with another object |
|
java.lang.Integer |
get(int i)
Creates a Integer for a specified int . |
|
int |
getInt(int i)
Gets the int at a specified position. |
|
int |
hashCode()
Computes a digest of the array for hashing. |
|
int |
length()
Gets the length of the array. |
|
|
toArray(T[] prototype)
Return a mutable copy of the array |
|
int[] |
toIntArray()
Creates a mutable copy of the int array |
|
java.lang.String |
toString()
Return a string representation of the array |
|
IntArray |
with(int newInt)
Creates a IntArray with an appended int . |
|
IntArray |
with(java.lang.Integer newInt)
Creates a IntArray |
|
IntArray |
without(int i)
Return a new IntArray 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 |
---|
getClass, notify, notifyAll, wait, wait, wait |
Method Detail |
---|
public static IntArray array(int... ints)
int
s.
ints
- each elementpublic static IntArray array()
IntArray
public static IntArray array(int value)
IntArray
with one element.
value
- the valuepublic static IntArray array(int value1, int value2)
IntArray
with two elements.
value1
- the first valuevalue2
- the second valuepublic static IntArray array(int value1, int value2, int value3)
IntArray
with three elements.
value1
- the first valuevalue2
- the second valuevalue3
- the third valuepublic static IntArray array(int value1, int value2, int value3, int value4)
IntArray
with four elements.
value1
- the first valuevalue2
- the second valuevalue3
- the third valuevalue4
- the fourth valuepublic boolean equals(java.lang.Object other)
equals
in class ImmutableArray<java.lang.Integer>
ConstArray
with the same
contents as this arraypublic int hashCode()
Arrays.hashCode(Object[])
called on a Java array
containing the same elements.
hashCode
in interface Selfless
hashCode
in class ConstArray<java.lang.Integer>
public java.lang.String toString()
toString
in class ConstArray<java.lang.Integer>
public int length()
length
in class ConstArray<java.lang.Integer>
public java.lang.Integer get(int i)
Integer
for a specified int
.
get
in class ConstArray<java.lang.Integer>
i
- position of the element to return
java.lang.ArrayIndexOutOfBoundsException
- i
is out of boundspublic <T> T[] toArray(T[] prototype)
toArray
in class ConstArray<java.lang.Integer>
prototype
- prototype of the array to copy into
ConstArray
of the same type as prototype
java.lang.ArrayStoreException
- if an element cannot be stored in the arraypublic IntArray with(java.lang.Integer newInt)
IntArray with an appended Integer
.
- Overrides:
with
in class PowerlessArray<java.lang.Integer>
- Parameters:
newInt
- the element to append
- Returns:
- the new array
- Throws:
java.lang.NullPointerException
- newInt
is null
public int getInt(int i)
int
at a specified position.
i
- position of the element to return
java.lang.ArrayIndexOutOfBoundsException
- i
is out of boundspublic int[] toIntArray()
int
array
public IntArray with(int newInt)
IntArray
with an appended int
.
newInt
- the element to appendpublic IntArray without(int i)
IntArray
that contains the same elements
as this one excluding the element at a specified index
without
in class PowerlessArray<java.lang.Integer>
i
- the index of the element to exclude
public static IntArray.Builder builder()
IntArray.Builder
. This is equivalent to the
constructor.
public static IntArray.Builder builder(int estimate)
IntArray.Builder
. This is equivalent to the
constructor.
estimate
- estimated array length
|
ref_send API 2.17 defensive programming in Java |
|||||||||
PREV CLASS NEXT CLASS | FRAMES NO FRAMES | |||||||||
SUMMARY: NESTED | FIELD | CONSTR | METHOD | DETAIL: FIELD | CONSTR | METHOD |
Copyright 1998-2009 Waterken Inc. under the terms of the MIT X license.