choco.kernel.memory.structure
Class StoredIndexedBipartiteSet

java.lang.Object
  extended by choco.kernel.memory.structure.StoredIndexedBipartiteSet
All Implemented Interfaces:
IStateIntVector
Direct Known Subclasses:
StoredIndexedBipartiteSetWithOffset

public class StoredIndexedBipartiteSet
extends Object
implements IStateIntVector

A stored list dedicated to positive integers and three operations : - iteration - removal of an element - check if an element is or not within the list It only requires a StoredInt to denote the first element of the list and proceeds by swapping element with the first one to remove them and incrementing the index of the first element. IT DOES NOT PRESERVE THE ORDER OF THE LIST


Field Summary
protected  BipartiteSetIterator _iterator
           
protected  IStateInt last
          The first element of the list
protected  int[] list
          The list of values
protected  int[] position
          The position of each element within the list.
 
Fields inherited from interface choco.kernel.memory.IStateIntVector
LOGGER, MIN_CAPACITY
 
Constructor Summary
StoredIndexedBipartiteSet(IEnvironment environment, ArrayList<IndexedObject> values)
           
StoredIndexedBipartiteSet(IEnvironment environment, IndexedObject[] values)
           
StoredIndexedBipartiteSet(IEnvironment environment, int nbValues)
          Create a stored bipartite set with a size.
StoredIndexedBipartiteSet(IEnvironment environment, int[] values)
           
 
Method Summary
 int[] _getStructure()
          DO NOT USE : FOR MEMORY OPTIM ONLY
 void add(int i)
          Adds a new search at the end of the vector.
 void buildList(IEnvironment environment, int[] values)
           
 void clear()
           
 boolean contain(IndexedObject object)
           
 boolean contain(int object)
           
 int findIndexOfInt(int a)
           
 int get(int index)
          Returns the indexth element of the vector.
 DisposableIntIterator getIterator()
           
 IndexedObject getObject(int index)
           
 BipartiteSetIterator getObjectIterator()
           
 void increaseSize(int gap)
          Increase the number of value watched.
 boolean isEmpty()
          Checks if the vector is empty.
 String pretty()
           
 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(IndexedObject object)
           
 void remove(int object)
          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 and returns the old value
 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

list

protected int[] list
The list of values


position

protected int[] position
The position of each element within the list. indexes[3] = k <=> list[k] = 3 we assume that elements ranges from 0 ... list.lenght in other words the elements must be indexed.


last

protected IStateInt last
The first element of the list


_iterator

protected BipartiteSetIterator _iterator
Constructor Detail

StoredIndexedBipartiteSet

public StoredIndexedBipartiteSet(IEnvironment environment,
                                 int[] values)
Parameters:
environment -
values: - a set of DIFFERENT positive integer values !

StoredIndexedBipartiteSet

public StoredIndexedBipartiteSet(IEnvironment environment,
                                 IndexedObject[] values)
Parameters:
environment -
values: - a set of IndexObjects which have different indexes !

StoredIndexedBipartiteSet

public StoredIndexedBipartiteSet(IEnvironment environment,
                                 ArrayList<IndexedObject> values)
Parameters:
environment -
values: - a set of IndexObjects which have different indexes !

StoredIndexedBipartiteSet

public StoredIndexedBipartiteSet(IEnvironment environment,
                                 int nbValues)
Create a stored bipartite set with a size. Thus the value stored will go from 0 to nbValues.

Parameters:
environment -
nbValues -
Method Detail

buildList

public void buildList(IEnvironment environment,
                      int[] values)

increaseSize

public final void increaseSize(int gap)
Increase the number of value watched. BEWARE: be sure your are correctly calling this method. It deletes everything already declared

Parameters:
gap - the gap the reach the expected size

size

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

Specified by:
size in interface IStateIntVector

isEmpty

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

Specified by:
isEmpty in interface IStateIntVector

add

public final void add(int i)
Description copied from interface: IStateIntVector
Adds a new search at the end of the vector.

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

clear

public final void clear()

removeLast

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

Specified by:
removeLast in interface IStateIntVector

remove

public void remove(int object)
Description copied from interface: IStateIntVector
Removes an int.

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

remove

public final void remove(IndexedObject object)

contain

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

contain

public final boolean contain(IndexedObject object)

get

public final int get(int index)
Description copied from interface: IStateIntVector
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:

getObject

public final IndexedObject getObject(int index)

set

public final int set(int index,
                     int val)
Description copied from interface: IStateIntVector
Assigns a new value val to the element index and returns the old value

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

getIterator

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

getObjectIterator

public final BipartiteSetIterator getObjectIterator()

pretty

public final String pretty()

findIndexOfInt

public final int findIndexOfInt(int a)

_getStructure

public final int[] _getStructure()
DO NOT USE : FOR MEMORY OPTIM ONLY



Copyright © 2012. All Rights Reserved.