public class ImmutableArray<S>
extends java.lang.Object
implements java.lang.Iterable<S>, java.io.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(java.util.List<S> list)
creates a new
|
ImmutableArray(S... arr)
creates a new
|
Modifier and Type | Method and Description |
---|---|
void |
arraycopy(int srcIdx,
java.lang.Object dest,
int destIndex,
int length) |
boolean |
contains(S op) |
boolean |
equals(java.lang.Object o) |
S |
get(int pos)
gets the element at the specified position
|
int |
hashCode() |
boolean |
isEmpty() |
java.util.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 . |
java.lang.String |
toString() |
private static final long serialVersionUID
private final S[] content
public ImmutableArray()
public ImmutableArray(S... arr)
arr
- the ProgrammElement array to wrappublic ImmutableArray(java.util.List<S> list)
list
- a LinkedList (order is preserved)public final S get(int pos)
pos
- an int describing the positionpublic final S last()
public int size()
public void arraycopy(int srcIdx, java.lang.Object dest, int destIndex, int length)
public final boolean isEmpty()
public boolean contains(S op)
public <T> T[] toArray(T[] array)
java.lang.ClassCastException
- if T is not a supertype of Spublic int hashCode()
hashCode
in class java.lang.Object
public boolean equals(java.lang.Object o)
equals
in class java.lang.Object
public java.lang.String toString()
toString
in class java.lang.Object
public java.util.Iterator<S> iterator()
iterator
in interface java.lang.Iterable<S>
public ImmutableList<S> toImmutableList()
ImmutableArray
to an ImmutableList
.ImmutableList
.