choco.kernel.memory.structure
Class APartiallyStoredCstrList<C extends SConstraint>

java.lang.Object
  extended by choco.kernel.memory.structure.APartiallyStoredCstrList<C>
Direct Known Subclasses:
PartiallyStoredIntCstrList, PartiallyStoredRealCstrList, PartiallyStoredSetCstrList, PartiallyStoredTaskCstrList

public abstract class APartiallyStoredCstrList<C extends SConstraint>
extends Object


Field Summary
protected  PartiallyStoredVector<C> elements
           
protected  PartiallyStoredIntVector indices
           
protected  IStateInt priority
           
 
Constructor Summary
protected APartiallyStoredCstrList(IEnvironment env)
           
 
Method Summary
 int addConstraint(SConstraint c, int varIdx, boolean dynamicAddition)
          Adds a new constraints on the stack of constraints the addition can be dynamic (undone upon backtracking) or not.
protected  void computePriority(SConstraint c)
          Compute the priotity of the variable
 int eraseConstraint(SConstraint c)
          Removes (permanently) a constraint from the list of constraints connected to the variable.
 C getConstraint(int i)
          Retrieve the C element i
 int getConstraintIndex(int constraintIndex)
          Returns the index of the constraint.
 DisposableIterator<SConstraint> getConstraintsIterator()
          This methods should be used if one want to access the different constraints stored.
 PartiallyStoredVector<C> getConstraintVector()
          Access the data structure storing constraints
 PartiallyStoredIntVector getIndexVector()
          Access the data structure storing indices associated to constraints .
 int getNbConstraints()
          Returns the number of constraints
 int getPriority()
          Return the minimum priority of the constraints in this
 
Methods inherited from class java.lang.Object
clone, equals, finalize, getClass, hashCode, notify, notifyAll, toString, wait, wait, wait
 

Field Detail

elements

protected final PartiallyStoredVector<C extends SConstraint> elements

indices

protected final PartiallyStoredIntVector indices

priority

protected final IStateInt priority
Constructor Detail

APartiallyStoredCstrList

protected APartiallyStoredCstrList(IEnvironment env)
Method Detail

getConstraint

public final C getConstraint(int i)
Retrieve the C element i

Parameters:
i - index of the constraint
Returns:
the ith constraint

getConstraintIndex

public final int getConstraintIndex(int constraintIndex)
Returns the index of the constraint.

Parameters:
constraintIndex - the index of the constraint
Returns:
the index

getNbConstraints

public final int getNbConstraints()
Returns the number of constraints

Returns:
the number of constraints

getConstraintVector

public final PartiallyStoredVector<C> getConstraintVector()
Access the data structure storing constraints

Returns:
the backtrackable structure containing the constraints

getIndexVector

public final PartiallyStoredIntVector getIndexVector()
Access the data structure storing indices associated to constraints .

Returns:
the indices associated to this variable in each constraint

eraseConstraint

public int eraseConstraint(SConstraint c)
Removes (permanently) a constraint from the list of constraints connected to the variable.

Parameters:
c - the constraint that should be removed from the list this variable maintains.
Returns:
index of the deleted constraint

addConstraint

public int addConstraint(SConstraint c,
                         int varIdx,
                         boolean dynamicAddition)
Adds a new constraints on the stack of constraints the addition can be dynamic (undone upon backtracking) or not.

Parameters:
c - the constraint to add
varIdx - the variable index accrding to the added constraint
dynamicAddition - states if the addition is definitic (cut) or subject to backtracking (standard constraint)
Returns:
the index affected to the constraint according to this variable

computePriority

protected void computePriority(SConstraint c)
Compute the priotity of the variable

Parameters:
c - the new constraint

getConstraintsIterator

public final DisposableIterator<SConstraint> getConstraintsIterator()
This methods should be used if one want to access the different constraints stored. Indeed, since indices are not always consecutive, it is the only simple way to achieve this. Warning ! this iterator should not be used to remove elements. The remove method throws an UnsupportedOperationException.

Returns:
an iterator over all constraints involving this variable

getPriority

public final int getPriority()
Return the minimum priority of the constraints in this

Returns:
priority


Copyright © 2012. All Rights Reserved.