net.sf.zig_project.gpl.common.arrays
Class IntList

java.lang.Object
  extended bynet.sf.zig_project.gpl.common.arrays.IntList

public class IntList
extends Object

An int list provides a list of int types, maintained in an array. The array is ordered based on the order in which ints were added, and is potentially more efficient than Collection based classes, as ints are stored directly as a primitive type, and are not required to be encapsulated by a wrapper class.

Version:
September 15, 2004
Author:
Frank Ziglar

Field Summary
protected  int[] intset
           
protected  ArraySizeSelector selector
           
protected  int size
           
 
Constructor Summary
IntList(int init_size)
          Construct an IntList with the specified initial size.
IntList(int init_size, ArraySizeSelector sel)
          Construct an IntList with the specified initial size and Array Size Selector.
 
Method Summary
 void add(int i)
          Adds an int to the end of the list
 int getIndex(int idx)
          Returns the value of the int located at the specified index.
 int removeIndex(int idx)
          Removes the value at the specified index.
 int size()
          Returns the current number of ints defined within this list
 
Methods inherited from class java.lang.Object
clone, equals, finalize, getClass, hashCode, notify, notifyAll, toString, wait, wait, wait
 

Field Detail

selector

protected final ArraySizeSelector selector

intset

protected int[] intset

size

protected int size
Constructor Detail

IntList

public IntList(int init_size)
Construct an IntList with the specified initial size. The Default Array Size Selector is used.


IntList

public IntList(int init_size,
               ArraySizeSelector sel)
Construct an IntList with the specified initial size and Array Size Selector.

Parameters:
init_size - the initial size for the int list.
sel - the ArraySizeSelector to use for resizing.
Method Detail

add

public void add(int i)
Adds an int to the end of the list


getIndex

public int getIndex(int idx)
Returns the value of the int located at the specified index.

Parameters:
idx - the index of the value in the array to look up
Throws:
IndexOutOfBoundsException - if !(0 <= idx < size())

size

public int size()
Returns the current number of ints defined within this list


removeIndex

public int removeIndex(int idx)
Removes the value at the specified index. The list will shift any and all ints added after this index down to decrement the size, and replace this index with the next higher index.

Parameters:
idx - the index of the value to remove
Returns:
the value of the int removed
Throws:
IndexOutOfBoundsException - if !(0 <= idx < size())