choco.kernel.memory.trailing
Class StoredVector<E>

java.lang.Object
  extended by choco.kernel.memory.trailing.StoredVector<E>
All Implemented Interfaces:
IStateVector<E>

public final class StoredVector<E>
extends Object
implements IStateVector<E>

Implements a backtrackable search vector.


Field Summary
protected  StoredVectorTrail 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.IStateVector
MIN_CAPACITY
 
Constructor Summary
StoredVector(EnvironmentTrailing env)
          Constructs a stored search vector with an initial size, and initial values.
StoredVector(int[] entries)
           
 
Method Summary
 E _set(int index, Object val, int stamp)
          Sets an element without storing the previous value.
 boolean add(E 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.
 E get(int index)
          Returns the indexth element of the vector.
 boolean isEmpty()
          Checks if the vector is empty.
 void removeLast()
          removes the search at the end of the vector.
 E set(int index, E 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

worldStamps

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


myTrail

protected final StoredVectorTrail myTrail
Constructor Detail

StoredVector

public StoredVector(EnvironmentTrailing env)
Constructs a stored search vector with an initial size, and initial values.

Parameters:
env - The current environment.

StoredVector

public StoredVector(int[] entries)
Method Detail

size

public int size()
Description copied from interface: IStateVector
Returns the current size of the stored search vector.

Specified by:
size in interface IStateVector<E>

isEmpty

public boolean isEmpty()
Description copied from interface: IStateVector
Checks if the vector is empty.

Specified by:
isEmpty in interface IStateVector<E>

ensureCapacity

public void ensureCapacity(int minCapacity)
Description copied from interface: IStateVector
Checks if the capacity is great enough, else the capacity is extended.

Specified by:
ensureCapacity in interface IStateVector<E>
Parameters:
minCapacity - the necessary capacity.

add

public boolean add(E i)
Description copied from interface: IStateVector
Adds a new search at the end of the vector.

Specified by:
add in interface IStateVector<E>
Parameters:
i - The search to add.

removeLast

public void removeLast()
Description copied from interface: IStateVector
removes the search at the end of the vector. does nothing when called on an empty vector

Specified by:
removeLast in interface IStateVector<E>

get

public E get(int index)
Description copied from interface: IStateVector
Returns the indexth element of the vector.

Specified by:
get in interface IStateVector<E>

set

public E set(int index,
             E val)
Description copied from interface: IStateVector
Assigns a new value val to the element index.

Specified by:
set in interface IStateVector<E>

_set

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



Copyright © 2012. All Rights Reserved.