de.jstacs.utils
Class IntList

java.lang.Object
  extended by de.jstacs.utils.IntList

public final class IntList
extends Object

A simple list of primitive type int.

Author:
Jens Keilwagen

Constructor Summary
IntList()
          This is the default constructor that creates an IntList with initial length 10.
IntList(int size)
          This is the default constructor that creates an IntList with initial length size.
 
Method Summary
 void add(int val)
          Adds the element val at the end of the list.
 void clear()
          Removes all elements from the list.
 int get(int index)
          Returns the element with the specified index.
 int length()
          Returns the number of inserted elements.
 int[] toArray()
          This method returns an int array containing all elements of the list.
 
Methods inherited from class java.lang.Object
clone, equals, finalize, getClass, hashCode, notify, notifyAll, toString, wait, wait, wait
 

Constructor Detail

IntList

public IntList()
This is the default constructor that creates an IntList with initial length 10.


IntList

public IntList(int size)
        throws IllegalArgumentException
This is the default constructor that creates an IntList with initial length size.

Parameters:
size - the initial size; has to be positive
Throws:
IllegalArgumentException - if the size is less than 1.
Method Detail

add

public final void add(int val)
Adds the element val at the end of the list.

Parameters:
val - the element that should be inserted.

clear

public final void clear()
Removes all elements from the list.


get

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

Parameters:
index - the specified index
Returns:
the corresponding element

length

public final int length()
Returns the number of inserted elements.

Returns:
the number of inserted elements

toArray

public final int[] toArray()
This method returns an int array containing all elements of the list.

Returns:
an int array containing all elements of the list.