public class ImmutableArray<S> extends Object implements Iterable<S>, Serializable
Modifier and Type | Class and Description |
---|---|
private static class |
ImmutableArray.ArrayIterator<T> |
Modifier and Type | Field and Description |
---|---|
private S[] |
content |
private static long |
serialVersionUID |
Constructor and Description |
---|
ImmutableArray()
creates an empty new
|
ImmutableArray(List<S> list)
creates a new
|
ImmutableArray(S... arr)
creates a new
|
Modifier and Type | Method and Description |
---|---|
void |
arraycopy(int srcIdx,
Object dest,
int destIndex,
int length) |
boolean |
contains(S op) |
boolean |
equals(Object o) |
S |
get(int pos)
gets the element at the specified position
|
int |
hashCode() |
boolean |
isEmpty() |
Iterator<S> |
iterator() |
S |
last()
returns the last element of the array
|
int |
size() |
<T> T[] |
toArray(T[] array)
Convert the array to a Java array (O(n))
|
ImmutableList<S> |
toImmutableList()
Convert an
ImmutableArray to an ImmutableList . |
String |
toString() |
private static final long serialVersionUID
private final S[] content
public ImmutableArray()
public ImmutableArray(S... arr)
arr
- the ProgrammElement array to wrappublic final S get(int pos)
pos
- an int describing the positionpublic final S last()
public int size()
public void arraycopy(int srcIdx, Object dest, int destIndex, int length)
public final boolean isEmpty()
public boolean contains(S op)
public <T> T[] toArray(T[] array)
ClassCastException
- if T is not a supertype of Spublic ImmutableList<S> toImmutableList()
ImmutableArray
to an ImmutableList
.ImmutableList
.