korat.utils
Class IntList

java.lang.Object
  extended by korat.utils.IntList
All Implemented Interfaces:
IIntList
Direct Known Subclasses:
IntListBS

public class IntList
extends Object
implements IIntList

Slow - use one of its derivatives, BS or AI

Author:
Sasa Misailovic
See Also:
IntListAI, IntListBS

Field Summary
private static int defaultInitSize
           
private  int[] elems
           
private  int initSize
           
private  int lastElementIndex
           
 
Constructor Summary
IntList()
           
 
Method Summary
 boolean add(int elem)
          Adds an element to the end of IIntList.
 void clear()
          Clears all elements from the list.
 boolean contains(int elem)
          Returns whether list contains element elem
 int get(int idx)
          Gets i-th element from the list.
 boolean isEmpty()
          Returns true if there are no elements in the list, false if there is at least one element in the list
 int numberOfElements()
          Returns number of the elements contained in this list.
 int removeLast()
          Removes last element from the IIntList.
 int set(int idx, int elem)
          Sets i-th element of the list to value elem.
 int[] toArray()
          Returns array representation of IntList elements
 
Methods inherited from class java.lang.Object
clone, equals, finalize, getClass, hashCode, notify, notifyAll, toString, wait, wait, wait
 

Field Detail

defaultInitSize

private static final int defaultInitSize
See Also:
Constant Field Values

initSize

private int initSize

elems

private int[] elems

lastElementIndex

private int lastElementIndex
Constructor Detail

IntList

public IntList()
Method Detail

numberOfElements

public int numberOfElements()
Description copied from interface: IIntList
Returns number of the elements contained in this list.

Specified by:
numberOfElements in interface IIntList

isEmpty

public boolean isEmpty()
Description copied from interface: IIntList
Returns true if there are no elements in the list, false if there is at least one element in the list

Specified by:
isEmpty in interface IIntList

contains

public boolean contains(int elem)
Description copied from interface: IIntList
Returns whether list contains element elem

Specified by:
contains in interface IIntList

toArray

public int[] toArray()
Description copied from interface: IIntList
Returns array representation of IntList elements

Specified by:
toArray in interface IIntList

add

public boolean add(int elem)
Description copied from interface: IIntList
Adds an element to the end of IIntList. New elements can always be added to IIntList

Specified by:
add in interface IIntList

removeLast

public int removeLast()
Description copied from interface: IIntList
Removes last element from the IIntList. This operation can be successfully carried out only if the list is not empty.

Specified by:
removeLast in interface IIntList

clear

public void clear()
Description copied from interface: IIntList
Clears all elements from the list.

Specified by:
clear in interface IIntList

get

public int get(int idx)
Description copied from interface: IIntList
Gets i-th element from the list. This operation can be successfully carried out only if the index of the object is smaller then the number of the elements in the list. Otherwise, the results are unpredictable.

Number of elements in the list can be obtained by invoking numberOfElements().

Specified by:
get in interface IIntList

set

public int set(int idx,
               int elem)
Description copied from interface: IIntList
Sets i-th element of the list to value elem. This operation can be successfully carried out only if the index of the object is smaller then the number of the elements in the list. Otherwise, the results are unpredictable.

Number of elements in the list can be obtained by invoking numberOfElements().

Specified by:
set in interface IIntList