com.sibvisions.util
Class ImmutableArray<V>

java.lang.Object
  extended by com.sibvisions.util.ImmutableArray<V>
Type Parameters:
V - value class

public class ImmutableArray<V>
extends java.lang.Object

The ImmutableArray gives the functionality of immutable arrays.


Constructor Summary
ImmutableArray(V... pArray)
          Constructs a new Array.
 
Method Summary
 ImmutableArray<V> add(ImmutableArray<V> pImmutableArray)
          Adds the given ImmutableArray to this ImmutableArray.
 ImmutableArray<V> add(int pIndex, ImmutableArray<V> pImmutableArray)
          Adds the given ImmutableArray to this ImmutableArray at the given index.
 ImmutableArray<V> add(int pIndex, V... pArray)
          Adds the given array to this ImmutableArray at the given index.
 ImmutableArray<V> add(V... pArray)
          Adds the given array to this ImmutableArray.
 boolean contains(V pValue)
          Gets true, if the array contains the given value.
 boolean equals(java.lang.Object pObject)
          
 V get(int pIndex)
          Gets the value of given index.
 int hashCode()
          
 int indexOf(V pValue)
          Gets the index of the given value.
 ImmutableArray<V> remove(ImmutableArray<V> pImmutableArray)
          Removes the given ImmutableArray to this ImmutableArray.
 ImmutableArray<V> remove(int pIndex)
          Removes one element at the given index.
 ImmutableArray<V> remove(int pIndex, int pAmount)
          Removes the given amount of elements at the given index.
 ImmutableArray<V> remove(V... pArray)
          Removes the given array to this ImmutableArray.
 ImmutableArray<V> removeAll()
          Removes all elements.
 ImmutableArray<V> removeFirst()
          Removes the first element.
 ImmutableArray<V> removeFirst(int pAmount)
          Removes the given amount at the beginning.
 ImmutableArray<V> removeLast()
          Removes the last element.
 ImmutableArray<V> removeLast(int pAmount)
          Removes the given amount at the end.
 ImmutableArray<V> set(int pIndex, V pValue)
          Sets the value of a given index.
 int size()
          Gets the length of the array.
 V[] toArray()
          Gets a mutable array of this immutable array.
 java.lang.String toString()
          
 
Methods inherited from class java.lang.Object
clone, finalize, getClass, notify, notifyAll, wait, wait, wait
 

Constructor Detail

ImmutableArray

public ImmutableArray(V... pArray)
Constructs a new Array.

Parameters:
pArray - the array.
Method Detail

hashCode

public int hashCode()

Overrides:
hashCode in class java.lang.Object

equals

public boolean equals(java.lang.Object pObject)

Overrides:
equals in class java.lang.Object

toString

public java.lang.String toString()

Overrides:
toString in class java.lang.Object

size

public int size()
Gets the length of the array.

Returns:
the length of the array.

get

public V get(int pIndex)
Gets the value of given index.

Parameters:
pIndex - the index.
Returns:
the value of given index.

set

public ImmutableArray<V> set(int pIndex,
                             V pValue)
Sets the value of a given index.

Parameters:
pIndex - the index.
pValue - the value.
Returns:
the new ImmutableArray.

add

public ImmutableArray<V> add(ImmutableArray<V> pImmutableArray)
Adds the given ImmutableArray to this ImmutableArray.

Parameters:
pImmutableArray - the ImmutableArray.
Returns:
the new ImmutableArray.

add

public ImmutableArray<V> add(V... pArray)
Adds the given array to this ImmutableArray.

Parameters:
pArray - the array.
Returns:
the new ImmutableArray.

add

public ImmutableArray<V> add(int pIndex,
                             ImmutableArray<V> pImmutableArray)
Adds the given ImmutableArray to this ImmutableArray at the given index.

Parameters:
pIndex - the index.
pImmutableArray - the ImmutableArray.
Returns:
the new ImmutableArray.

add

public ImmutableArray<V> add(int pIndex,
                             V... pArray)
Adds the given array to this ImmutableArray at the given index.

Parameters:
pIndex - the index.
pArray - the array.
Returns:
the new ImmutableArray.

indexOf

public int indexOf(V pValue)
Gets the index of the given value.

Parameters:
pValue - the value.
Returns:
the index of the given value.

contains

public boolean contains(V pValue)
Gets true, if the array contains the given value.

Parameters:
pValue - the value.
Returns:
true, if the array contains the given value.

remove

public ImmutableArray<V> remove(ImmutableArray<V> pImmutableArray)
Removes the given ImmutableArray to this ImmutableArray.

Parameters:
pImmutableArray - the ImmutableArray.
Returns:
the new ImmutableArray.

remove

public ImmutableArray<V> remove(V... pArray)
Removes the given array to this ImmutableArray.

Parameters:
pArray - the array.
Returns:
the new ImmutableArray.

remove

public ImmutableArray<V> remove(int pIndex)
Removes one element at the given index.

Parameters:
pIndex - the index.
Returns:
the new ImmutableArray.

removeAll

public ImmutableArray<V> removeAll()
Removes all elements.

Returns:
the new ImmutableArray.

removeFirst

public ImmutableArray<V> removeFirst()
Removes the first element.

Returns:
the new ImmutableArray.

removeFirst

public ImmutableArray<V> removeFirst(int pAmount)
Removes the given amount at the beginning.

Parameters:
pAmount - the amount.
Returns:
the new ImmutableArray.

removeLast

public ImmutableArray<V> removeLast()
Removes the last element.

Returns:
the new ImmutableArray.

removeLast

public ImmutableArray<V> removeLast(int pAmount)
Removes the given amount at the end.

Parameters:
pAmount - the amount.
Returns:
the new ImmutableArray.

remove

public ImmutableArray<V> remove(int pIndex,
                                int pAmount)
Removes the given amount of elements at the given index.

Parameters:
pIndex - the index.
pAmount - the amount.
Returns:
the new ImmutableArray.

toArray

public V[] toArray()
Gets a mutable array of this immutable array.

Returns:
a mutable array,


Copyright © 2009 SIB Visions GmbH. All Rights Reserved.