choco.kernel.memory.trailing
Class StoredIntVector

java.lang.Object
  extended by choco.kernel.memory.trailing.StoredIntVector
All Implemented Interfaces:
IStateIntVector

public final class StoredIntVector
extends Object
implements IStateIntVector

Implements a backtrackable search vector.

Cette classe permet de stocker facilment des entiers dans un tableau backtrackable d'entiers.


Field Summary
static int MIN_CAPACITY
          Minimal capacity of a vector
protected  StoredIntVectorTrail myTrail
           
 int[] worldStamps
          Contains time stamps for all entries (the world index of the last update for each entry)
 
Fields inherited from interface choco.kernel.memory.IStateIntVector
LOGGER
 
Constructor Summary
StoredIntVector(EnvironmentTrailing env)
          Constructs an empty stored search vector.
StoredIntVector(EnvironmentTrailing env, int[] entries)
           
StoredIntVector(EnvironmentTrailing env, int initialSize, int initialValue)
          Constructs a stored search vector with an initial size, and initial values.
 
Method Summary
 int _set(int index, int val, int stamp)
          Sets an element without storing the previous value.
 void add(int i)
          Adds a new search at the end of the vector.
 boolean contain(int val)
           
 void ensureCapacity(int minCapacity)
          Checks if the capacity is great enough, else the capacity is extended.
 int get(int index)
          Returns the indexth element of the vector.
 DisposableIntIterator getIterator()
           
 boolean isEmpty()
          Checks if the vector is empty.
 int quickGet(int index)
          access an element without any bound check
 int quickSet(int index, int val)
          Assigns a new value val to the element indexth and return the old value without bound check
 void remove(int i)
          Removes an int.
 void removeLast()
          removes the search at the end of the vector.
 int set(int index, int val)
          Assigns a new value val to the element index.
 int size()
          Returns the current size of the stored search vector.
 
Methods inherited from class java.lang.Object
clone, equals, finalize, getClass, hashCode, notify, notifyAll, toString, wait, wait, wait
 

Field Detail

MIN_CAPACITY

public static final int MIN_CAPACITY
Minimal capacity of a vector

See Also:
Constant Field Values

worldStamps

public int[] worldStamps
Contains time stamps for all entries (the world index of the last update for each entry)


myTrail

protected final StoredIntVectorTrail myTrail
Constructor Detail

StoredIntVector

public StoredIntVector(EnvironmentTrailing env,
                       int initialSize,
                       int initialValue)
Constructs a stored search vector with an initial size, and initial values.

Parameters:
env - The current environment.
initialSize - The initial size.
initialValue - The initial common value.

StoredIntVector

public StoredIntVector(EnvironmentTrailing env,
                       int[] entries)

StoredIntVector

public StoredIntVector(EnvironmentTrailing env)
Constructs an empty stored search vector.

Parameters:
env - The current environment.
Method Detail

size

public int size()
Returns the current size of the stored search vector.

Specified by:
size in interface IStateIntVector

isEmpty

public boolean isEmpty()
Checks if the vector is empty.

Specified by:
isEmpty in interface IStateIntVector

ensureCapacity

public void ensureCapacity(int minCapacity)
Checks if the capacity is great enough, else the capacity is extended.

Parameters:
minCapacity - the necessary capacity.

add

public void add(int i)
Adds a new search at the end of the vector.

Specified by:
add in interface IStateIntVector
Parameters:
i - The search to add.

remove

public void remove(int i)
Removes an int.

Specified by:
remove in interface IStateIntVector
Parameters:
i - The search to remove.

removeLast

public void removeLast()
removes the search at the end of the vector. does nothing when called on an empty vector

Specified by:
removeLast in interface IStateIntVector

get

public int get(int index)
Returns the indexth element of the vector.

Specified by:
get in interface IStateIntVector

quickGet

public final int quickGet(int index)
Description copied from interface: IStateIntVector
access an element without any bound check

Specified by:
quickGet in interface IStateIntVector
Returns:

contain

public boolean contain(int val)
Specified by:
contain in interface IStateIntVector

set

public int set(int index,
               int val)
Assigns a new value val to the element index.

Specified by:
set in interface IStateIntVector

quickSet

public final int quickSet(int index,
                          int val)
Description copied from interface: IStateIntVector
Assigns a new value val to the element indexth and return the old value without bound check

Specified by:
quickSet in interface IStateIntVector
Parameters:
index - the index where the value is modified
val - the new value
Returns:
the old value

_set

public int _set(int index,
                int val,
                int stamp)
Sets an element without storing the previous value.


getIterator

public DisposableIntIterator getIterator()
Specified by:
getIterator in interface IStateIntVector


Copyright © 2012. All Rights Reserved.