Class VariableConstraints
Defined in File variable_constraints.hpp
Class Documentation
-
class VariableConstraints
Holds the per-variable constraint list.
Each variable is represented by a unique index. The indices are expected to be “small and
compact”, i.e. sequentially numbered starting from zero. Failure to meet this expectation will result in excess memory allocation.
Public Functions
-
void reserve(const size_t variable_count)
Pre-allocate enough memory to hold a specified number of variables.
-
bool empty() const
Return true if no variables or constraints have been added.
-
size_t size() const
The total number of unique (variable id, constraint id) pairs.
-
unsigned int nextVariableIndex() const
The next available variable index.
This is one larger than the current maximum variable index
-
void insert(const unsigned int constraint, const unsigned int variable)
Add this constraint to a single variable.
-
void insert(const unsigned int constraint, std::initializer_list<unsigned int> variable_list)
Add this constraint to all variables in the provided list.
-
template<typename VariableIndexIterator>
void insert(const unsigned int constraint, VariableIndexIterator first, VariableIndexIterator last) Add this constraint to all variables in the provided range.
-
void insert(const unsigned int variable)
Add a single orphan variable, i.e. a variable without constraints.
-
template<typename OutputIterator>
OutputIterator getConstraints(const unsigned int variable_id, OutputIterator result) const Insert all of the constraints connected to the requested variable into the provided container.
Accessing a variable id that is not part of this container results in undefined behavior
-
void print(std::ostream &stream = std::cout) const
Print a human-readable description of the variable constraints to the provided stream.
- Parameters:
stream – [out] The stream to write to. Defaults to stdout.
-
void reserve(const size_t variable_count)