|
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>
E
- the element type of objects contained in the arraypublic class ConstArray<E>
A read-only array containing elements of an arbitrary type.
Note: this class implements Serializable in order to avoid preventing trusted (non-Joe-E) code from serializing it. The Java Serialization API is tamed away as unsafe, and thus is not available to Joe-E code.
Nested Class Summary | |
---|---|
static class |
ConstArray.Builder<E>
A ConstArray factory. |
Method Summary | ||
---|---|---|
static
|
array()
Construct an empty ConstArray . |
|
static
|
array(T... values)
Construct a ConstArray . |
|
static
|
array(T value)
Construct a ConstArray with one element. |
|
static
|
array(T value1,
T value2)
Construct a ConstArray with two elements. |
|
static
|
array(T value1,
T value2,
T value3)
Construct a ConstArray with three elements. |
|
static
|
array(T value1,
T value2,
T value3,
T value4)
Construct a ConstArray with four elements. |
|
static
|
builder()
Get a ConstArray.Builder . |
|
static
|
builder(int estimate)
Get a ConstArray.Builder . |
|
boolean |
equals(java.lang.Object other)
Test for equality with another object. |
|
E |
get(int i)
Gets the element at a specified position. |
|
int |
hashCode()
Computes a digest of the array for hashing. |
|
org.joe_e.array.ArrayIterator<E> |
iterator()
Return a new iterator over the array |
|
int |
length()
Return the length of the array |
|
|
toArray(T[] prototype)
Return a mutable copy of the array |
|
java.lang.String |
toString()
Return a string representation of the array. |
|
ConstArray<E> |
with(E newE)
Return a new ConstArray that contains the same elements
as this one but with a new element added to the end |
|
ConstArray<E> |
without(int i)
Return a new ConstArray that contains the same elements
as this one excluding the element at a specified index |
Methods inherited from class java.lang.Object |
---|
getClass, notify, notifyAll, wait, wait, wait |
Method Detail |
---|
public static <T> ConstArray<T> array(T... values)
ConstArray
.
values
- each valuepublic static <T> ConstArray<T> array()
ConstArray
.
public static <T> ConstArray<T> array(T value)
ConstArray
with one element.
value
- the valuepublic static <T> ConstArray<T> array(T value1, T value2)
ConstArray
with two elements.
value1
- the first valuevalue2
- the second valuepublic static <T> ConstArray<T> array(T value1, T value2, T value3)
ConstArray
with three elements.
value1
- the first valuevalue2
- the second valuevalue3
- the third valuepublic static <T> ConstArray<T> array(T value1, T value2, T value3, T value4)
ConstArray
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 java.lang.Object
public int hashCode()
Arrays.hashCode(Object[])
for a Java array with
the same elements. The precise behavior when some elements are not
Selfless is unspecified, and may change in future releases. It is,
however, guaranteed to be deterministic for a given library version.
hashCode
in interface Selfless
hashCode
in class java.lang.Object
public java.lang.String toString()
toString
in class java.lang.Object
public org.joe_e.array.ArrayIterator<E> iterator()
iterator
in interface java.lang.Iterable<E>
public E get(int i)
i
- position of the element to return
java.lang.ArrayIndexOutOfBoundsException
- i
is out of boundspublic int length()
public <T> T[] toArray(T[] prototype)
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 ConstArray<E> with(E newE)
ConstArray
that contains the same elements
as this one but with a new element added to the end
newE
- the element to add
public ConstArray<E> without(int i)
ConstArray
that contains the same elements
as this one excluding the element at a specified index
i
- the index of the element to exclude
public static <E> ConstArray.Builder<E> builder()
ConstArray.Builder
. This is equivalent to the
constructor.
public static <E> ConstArray.Builder<E> builder(int estimate)
ConstArray.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.