choco.kernel.memory.trailing
Class StoredDoubleVector

java.lang.Object
  extended by choco.kernel.memory.trailing.StoredDoubleVector
All Implemented Interfaces:
IStateDoubleVector

public final class StoredDoubleVector
extends Object
implements IStateDoubleVector

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  StoredDoubleVectorTrail 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.IStateDoubleVector
LOGGER
 
Constructor Summary
StoredDoubleVector(EnvironmentTrailing env)
          Constructs an empty stored search vector.
StoredDoubleVector(EnvironmentTrailing env, double[] entries)
           
StoredDoubleVector(EnvironmentTrailing env, int initialSize, double initialValue)
          Constructs a stored search vector with an initial size, and initial values.
 
Method Summary
 double _set(int index, double val, int stamp)
          Sets an element without storing the previous value.
 void add(double i)
          Adds a new search at the end of the vector.
 void ensureCapacity(int minCapacity)
          Checks if the capacity is great enough, else the capacity is extended.
 double get(int index)
          Returns the indexth element of the vector.
 DisposableIntIterator getIterator()
           
 boolean isEmpty()
          Checks if the vector is empty.
 double quickGet(int index)
          return the indexth element of the vector without an bound check.
 double quickSet(int index, double val)
          Unsafe setter => don't do bound verification
 void remove(int i)
          Removes an int.
 void removeLast()
          removes the search at the end of the vector.
 double set(int index, double 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 StoredDoubleVectorTrail myTrail
Constructor Detail

StoredDoubleVector

public StoredDoubleVector(EnvironmentTrailing env,
                          int initialSize,
                          double 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.

StoredDoubleVector

public StoredDoubleVector(EnvironmentTrailing env,
                          double[] entries)

StoredDoubleVector

public StoredDoubleVector(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 IStateDoubleVector

isEmpty

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

Specified by:
isEmpty in interface IStateDoubleVector

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(double i)
Adds a new search at the end of the vector.

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

remove

public void remove(int i)
Removes an int.

Specified by:
remove in interface IStateDoubleVector
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 IStateDoubleVector

get

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

Specified by:
get in interface IStateDoubleVector

quickGet

public double quickGet(int index)
Description copied from interface: IStateDoubleVector
return the indexth element of the vector without an bound check.

Specified by:
quickGet in interface IStateDoubleVector
Parameters:
index - index
Returns:
the element

set

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

Specified by:
set in interface IStateDoubleVector

quickSet

public double quickSet(int index,
                       double val)
Description copied from interface: IStateDoubleVector
Unsafe setter => don't do bound verification

Specified by:
quickSet in interface IStateDoubleVector
Parameters:
index - the index of the replaced value
val - the new value
Returns:
the old value

_set

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

Parameters:
index - Index where to set
val - value to be changed
stamp - world when the modification is done
Returns:
the old value

getIterator

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


Copyright © 2012. All Rights Reserved.