org.h2.util
Class IntArray

java.lang.Object
  extended by org.h2.util.IntArray

public class IntArray
extends java.lang.Object

An array with integer element.


Constructor Summary
IntArray()
          Create an int array with the default initial capacity.
IntArray(int capacity)
          Create an int array with specified initial capacity.
IntArray(int[] data)
          Create an int array with the given values and size.
 
Method Summary
 void add(int value)
          Append a value.
 void add(int index, int value)
          Insert an element at the given position.
 void addValueSorted(int value)
          Insert an element at the correct position in a sorted list.
 boolean equals(java.lang.Object obj)
           
 int findIndexSorted(int value)
          Return the index with a this value.
 int findNextIndexSorted(int value)
          Return the next index with a value larger than this one.
 int get(int index)
          Get the value at the given index.
 int hashCode()
           
 void remove(int index)
          Remove the value at the given index.
 void removeAllSorted(IntArray removeSorted)
          Remove all values from the given sorted list from this sorted list.
 void removeLastValue(int value)
          Remove the last element of this list that matches this value.
 void removeRange(int fromIndex, int toIndex)
          Remove a number of elements.
 void removeValue(int value)
          Remove the first element of this list that matches this value.
 void set(int index, int value)
          Update the value at the given index.
 int size()
          Get the size of the list.
 void sort()
          Sort the array by value.
 void toArray(int[] array)
          Convert this list to an array.
 java.lang.String toString()
           
 
Methods inherited from class java.lang.Object
clone, finalize, getClass, notify, notifyAll, wait, wait, wait
 

Constructor Detail

IntArray

public IntArray()
Create an int array with the default initial capacity.


IntArray

public IntArray(int capacity)
Create an int array with specified initial capacity.


IntArray

public IntArray(int[] data)
Create an int array with the given values and size.

Method Detail

add

public void add(int value)
Append a value.

Parameters:
value - the value to append

get

public int get(int index)
Get the value at the given index.

Parameters:
index - the index
Returns:
the value

remove

public void remove(int index)
Remove the value at the given index.

Parameters:
index - the index

add

public void add(int index,
                int value)
Insert an element at the given position. The element at this position and all elements with a higher index move one element.

Parameters:
index - the index where to insert the value
value - the value to insert

set

public void set(int index,
                int value)
Update the value at the given index.

Parameters:
index - the index
value - the new value

equals

public boolean equals(java.lang.Object obj)
Overrides:
equals in class java.lang.Object

hashCode

public int hashCode()
Overrides:
hashCode in class java.lang.Object

size

public int size()
Get the size of the list.

Returns:
the size

addValueSorted

public void addValueSorted(int value)
Insert an element at the correct position in a sorted list. If the list is not sorted, the result of this operation is undefined.

Parameters:
value - the value to insert

removeValue

public void removeValue(int value)
Remove the first element of this list that matches this value.

Parameters:
value - the value to be remove

removeLastValue

public void removeLastValue(int value)
Remove the last element of this list that matches this value.

Parameters:
value - the value to be remove

findIndexSorted

public int findIndexSorted(int value)
Return the index with a this value. If the list is not sorted, the result of this operation is undefined.

Parameters:
value - the value to find
Returns:
the index or -1 if not found

findNextIndexSorted

public int findNextIndexSorted(int value)
Return the next index with a value larger than this one. If the list is not sorted, the result of this operation is undefined.

Parameters:
value - the value to find
Returns:
the index

sort

public void sort()
Sort the array by value.


toArray

public void toArray(int[] array)
Convert this list to an array. The target array must be big enough.

Parameters:
array - the target array

removeAllSorted

public void removeAllSorted(IntArray removeSorted)
Remove all values from the given sorted list from this sorted list.

Parameters:
removeSorted - the value to remove

toString

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

removeRange

public void removeRange(int fromIndex,
                        int toIndex)
Remove a number of elements.

Parameters:
fromIndex - the index of the first item to remove
toIndex - upper bound (exclusive)