org.basex.util.list
Class IntList

java.lang.Object
  extended by org.basex.util.list.ElementList
      extended by org.basex.util.list.IntList

public class IntList
extends ElementList

This is a simple container for native integers.

Author:
BaseX Team 2005-13, BSD License, Christian Gruen

Field Summary
protected  int[] list
          Element container.
 
Fields inherited from class org.basex.util.list.ElementList
factor, size
 
Constructor Summary
IntList()
          Default constructor.
IntList(double resize)
          Constructor, specifying a resize factor.
IntList(int capacity)
          Constructor, specifying an initial internal array size.
IntList(int[] elements)
          Lightweight constructor, adopting the specified elements.
 
Method Summary
 void add(int element)
          Adds an element to the array.
 boolean contains(int element)
          Checks if the specified element is found in the list.
 void delete(int element)
          Removes all occurrences of the specified element from the list.
 void deleteAt(int index)
          Deletes the element at the specified position.
 int get(int index)
          Returns the element at the specified position.
 void insert(int index, int[] element)
          Inserts elements at the specified index position.
 void move(int diff, int index)
          Adds a difference to all elements starting from the specified index.
 int peek()
          Returns the uppermost element from the stack.
 int pop()
          Pops the uppermost element from the stack.
 void push(int element)
          Pushes an element onto the stack.
 void set(int index, int element)
          Stores an element at the specified position.
 IntList sort()
          Sorts the data.
 void sort(byte[][] tok, boolean num, boolean asc)
          Sorts the data in the order of the specified token array.
 void sort(double[] num, boolean asc)
          Sorts the data in the order of the specified numeric array.
 void sort(int[] num, boolean asc)
          Sorts the data in the order of the specified numeric array.
 int sortedIndexOf(int element)
          Searches the specified element via binary search.
 int[] toArray()
          Returns an array with all elements.
 java.lang.String toString()
           
 IntList unique()
          Removes duplicates from a sorted list.
 
Methods inherited from class org.basex.util.list.ElementList
isEmpty, newSize, newSize, reset, size, size
 
Methods inherited from class java.lang.Object
clone, equals, finalize, getClass, hashCode, notify, notifyAll, wait, wait, wait
 

Field Detail

list

protected int[] list
Element container.

Constructor Detail

IntList

public IntList()
Default constructor.


IntList

public IntList(int capacity)
Constructor, specifying an initial internal array size.

Parameters:
capacity - initial array capacity

IntList

public IntList(double resize)
Constructor, specifying a resize factor. Smaller values are more memory-saving, while larger will provide better performance.

Parameters:
resize - resize factor

IntList

public IntList(int[] elements)
Lightweight constructor, adopting the specified elements.

Parameters:
elements - initial array
Method Detail

add

public final void add(int element)
Adds an element to the array.

Parameters:
element - element to be added

get

public final int get(int index)
Returns the element at the specified position.

Parameters:
index - index of the element to return
Returns:
element

set

public final void set(int index,
                      int element)
Stores an element at the specified position.

Parameters:
index - index of the element to replace
element - element to be stored

contains

public final boolean contains(int element)
Checks if the specified element is found in the list.

Parameters:
element - element to be found
Returns:
result of check

insert

public final void insert(int index,
                         int[] element)
Inserts elements at the specified index position.

Parameters:
index - inserting position
element - elements to be inserted

delete

public final void delete(int element)
Removes all occurrences of the specified element from the list.

Parameters:
element - element to be removed

deleteAt

public final void deleteAt(int index)
Deletes the element at the specified position.

Parameters:
index - index of the element to delete

move

public final void move(int diff,
                       int index)
Adds a difference to all elements starting from the specified index.

Parameters:
diff - difference
index - index of the first element

peek

public final int peek()
Returns the uppermost element from the stack.

Returns:
the uppermost element

pop

public final int pop()
Pops the uppermost element from the stack.

Returns:
the popped element

push

public final void push(int element)
Pushes an element onto the stack.

Parameters:
element - element

sortedIndexOf

public final int sortedIndexOf(int element)
Searches the specified element via binary search. Note that all elements must be sorted.

Parameters:
element - element to be found
Returns:
index of the search key, or the negative insertion point - 1

toArray

public final int[] toArray()
Returns an array with all elements.

Returns:
array

unique

public IntList unique()
Removes duplicates from a sorted list.

Returns:
self reference

sort

public IntList sort()
Sorts the data.

Returns:
self reference

sort

public final void sort(byte[][] tok,
                       boolean num,
                       boolean asc)
Sorts the data in the order of the specified token array. Note that the input array will be resorted as well. The algorithm is derived from Arrays.sort(int[]).

Parameters:
tok - token array to sort by
num - numeric sort
asc - ascending

sort

public final void sort(double[] num,
                       boolean asc)
Sorts the data in the order of the specified numeric array. Note that the input array will be resorted as well. The algorithm is derived from Arrays.sort(int[]).

Parameters:
num - token array to sort by
asc - ascending

sort

public final void sort(int[] num,
                       boolean asc)
Sorts the data in the order of the specified numeric array. Note that the input array will be resorted as well. The algorithm is derived from Arrays.sort(int[]).

Parameters:
num - token array to sort by
asc - ascending

toString

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