choco.kernel.memory.structure
Class PartiallyStoredVector<E>

java.lang.Object
  extended by choco.kernel.memory.structure.PartiallyStoredVector<E>

public final class PartiallyStoredVector<E>
extends Object

A class implementing a vector with two kind of storage: standard static storage in an array, and backtrackable storage. By convention, objects with small indices (0 .. 999999) are statically managed as if they were in a standard array. And objects with large indices (1000000 ... ) are "stored" in a backtrackable manner, as if they were in a StoredIntVector


Constructor Summary
PartiallyStoredVector(IEnvironment env)
          Constructor
 
Method Summary
 int add(E o)
          Add an stored object
 void clear()
          Clear datastructures for safe reuses
 boolean contains(Object o)
          Check wether an object is stored.
 E get(int index)
          Get the index th stored object
static int getFirstStaticIndex()
          Return the indice of the first static object
static int getGlobalIndex(int idx, boolean isStatic)
           
 DisposableIntIterator getIndexIterator()
           
 DisposableIterator getIterator()
           
 int getLastStaticIndex()
          Return the indice of the last static object
 int getLastStoredIndex()
          Return the indice of the last stored object
static int getSmallIndex(int idx)
          Return the indexe of an object minus the stored offset
 int insert(int ind, E o)
          Insert an stored object
 boolean isEmpty()
          Check wether the structure is empty
static boolean isStaticIndex(int idx)
          Check wether the indice idx define a static object
 int remove(Object o)
          Remove an object
 int size()
          Return the number of static and stored objects contained in the structure
 int staticAdd(E o)
          Add a object in the array of static object
 int staticInsert(int ind, E o)
          Insert an object in the array of static object.
 
Methods inherited from class java.lang.Object
clone, equals, finalize, getClass, hashCode, notify, notifyAll, toString, wait, wait, wait
 

Constructor Detail

PartiallyStoredVector

public PartiallyStoredVector(IEnvironment env)
Constructor

Parameters:
env - environment where the data structure should be created
Method Detail

clear

public void clear()
Clear datastructures for safe reuses


contains

public boolean contains(Object o)
Check wether an object is stored. First, try in the array of static objects, then in the array of stored objects. Return true if the PartiallyStoredVector contains the object.

Parameters:
o - the object to look for
Returns:
true if it is contained

staticAdd

public int staticAdd(E o)
Add a object in the array of static object

Parameters:
o - the object to add
Returns:
the indice of this object in the structure

staticInsert

public int staticInsert(int ind,
                        E o)
Insert an object in the array of static object.

Parameters:
ind - indice to insert in
o - object to insert
Returns:
the indice of the last object in the array of static objects

remove

public int remove(Object o)
Remove an object

Parameters:
o - object to remove
Returns:
indice of the object
Throws:
MemoryException - when trying to remove unknown object or stored object

add

public int add(E o)
Add an stored object

Parameters:
o - the object to add
Returns:
indice of the object in the structure

insert

public int insert(int ind,
                  E o)
Insert an stored object

Parameters:
ind - indice where to add object
o - object to insert
Returns:
the size of stored structure

get

public E get(int index)
Get the index th stored object

Parameters:
index - the indice of the required object
Returns:
the 'index'th object

isEmpty

public boolean isEmpty()
Check wether the structure is empty

Returns:
true if the structure is empty

size

public int size()
Return the number of static and stored objects contained in the structure

Returns:
int

getIndexIterator

public DisposableIntIterator getIndexIterator()

getIterator

public DisposableIterator getIterator()

isStaticIndex

public static boolean isStaticIndex(int idx)
Check wether the indice idx define a static object

Parameters:
idx -
Returns:

getSmallIndex

public static int getSmallIndex(int idx)
Return the indexe of an object minus the stored offset

Parameters:
idx -
Returns:

getGlobalIndex

public static int getGlobalIndex(int idx,
                                 boolean isStatic)

getLastStaticIndex

public int getLastStaticIndex()
Return the indice of the last static object

Returns:

getFirstStaticIndex

public static int getFirstStaticIndex()
Return the indice of the first static object

Returns:

getLastStoredIndex

public int getLastStoredIndex()
Return the indice of the last stored object

Returns:


Copyright © 2012. All Rights Reserved.