org.h2.dev.util
Class ImmutableArray<K>

java.lang.Object
  extended by org.h2.dev.util.ImmutableArray<K>
Type Parameters:
K - the type
All Implemented Interfaces:
java.lang.Iterable<K>

public final class ImmutableArray<K>
extends java.lang.Object
implements java.lang.Iterable<K>

An immutable array.


Method Summary
 K[] array()
          Get the data.
static
<K> ImmutableArray<K>
create(K... array)
          Create an immutable array.
static
<K> ImmutableArray<K>
empty()
          Get an empty immutable array.
 K get(int index)
          Get the entry at this index.
 ImmutableArray<K> insert(int index, K obj)
          Insert an entry at this index.
 java.util.Iterator<K> iterator()
          Get an iterator over all entries.
 int length()
          Get the length.
 ImmutableArray<K> remove(int index)
          Remove the entry at this index.
 ImmutableArray<K> set(int index, K obj)
          Set the entry at this index.
 ImmutableArray<K> subArray(int fromIndex, int toIndex)
          Get a sub-array.
 java.lang.String toString()
           
 
Methods inherited from class java.lang.Object
clone, equals, finalize, getClass, hashCode, notify, notifyAll, wait, wait, wait
 

Method Detail

get

public K get(int index)
Get the entry at this index.

Parameters:
index - the index
Returns:
the entry

length

public int length()
Get the length.

Returns:
the length

set

public ImmutableArray<K> set(int index,
                             K obj)
Set the entry at this index.

Parameters:
index - the index
obj - the object
Returns:
the new immutable array

insert

public ImmutableArray<K> insert(int index,
                                K obj)
Insert an entry at this index.

Parameters:
index - the index
obj - the object
Returns:
the new immutable array

remove

public ImmutableArray<K> remove(int index)
Remove the entry at this index.

Parameters:
index - the index
Returns:
the new immutable array

subArray

public ImmutableArray<K> subArray(int fromIndex,
                                  int toIndex)
Get a sub-array.

Parameters:
fromIndex - the index of the first entry
toIndex - the end index, plus one
Returns:
the new immutable array

create

public static <K> ImmutableArray<K> create(K... array)
Create an immutable array.

Parameters:
array - the data
Returns:
the new immutable array

array

public K[] array()
Get the data.

Returns:
the data

toString

public java.lang.String toString()
Overrides:
toString in class java.lang.Object

empty

public static <K> ImmutableArray<K> empty()
Get an empty immutable array.

Type Parameters:
K - the key type
Returns:
the array

iterator

public java.util.Iterator<K> iterator()
Get an iterator over all entries.

Specified by:
iterator in interface java.lang.Iterable<K>
Returns:
the iterator