korat.utils
Class IntListAI

java.lang.Object
  extended by korat.utils.IntListAI
All Implemented Interfaces:
IIntList

public class IntListAI
extends Object
implements IIntList

List of integers with stack policy Different mechanism for checking if the field index is already contained in the accessed field list. This implementation should work faster than IntListBS, which uses java.util.BitSet to check for presence of value inside the list.

Author:
Sasa Misailovic

Field Summary
(package private)  int cnt
           
(package private)  int[] cvelems
           
protected  int[] elems
           
protected  int lastElementIndex
           
 
Constructor Summary
IntListAI(int candidateVectorSize)
           
 
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
 String toString()
           
 
Methods inherited from class java.lang.Object
clone, equals, finalize, getClass, hashCode, notify, notifyAll, wait, wait, wait
 

Field Detail

elems

protected int[] elems

lastElementIndex

protected int lastElementIndex

cvelems

int[] cvelems

cnt

int cnt
Constructor Detail

IntListAI

public IntListAI(int candidateVectorSize)
Method Detail

contains

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

Specified by:
contains 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

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

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

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

toArray

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

Specified by:
toArray in interface IIntList

toString

public String toString()
Overrides:
toString in class Object