Google OR-Tools v9.11
a fast and portable software suite for combinatorial optimization
Loading...
Searching...
No Matches
operations_research::bop::BacktrackableIntegerSet< IntType > Class Template Reference

#include <bop_ls.h>

Public Member Functions

 BacktrackableIntegerSet ()=default
 
void ClearAndResize (IntType n)
 
void ChangeState (IntType i, bool should_be_inside)
 
int size () const
 
const std::vector< IntType > & Superset () const
 Returns a superset of the current set of integers.
 
void AddBacktrackingLevel ()
 
void BacktrackOneLevel ()
 
void BacktrackAll ()
 

Detailed Description

template<typename IntType>
class operations_research::bop::BacktrackableIntegerSet< IntType >

Implementation details. The declarations of those utility classes are in the .h for testing reasons. Maintains some information on a sparse set of integers in [0, n). More specifically this class:

  • Allows to dynamically add/remove element from the set.
  • Has a backtracking support.
  • Maintains the number of elements in the set.
  • Maintains a superset of the elements of the set that contains all the modified elements.

Definition at line 177 of file bop_ls.h.

Constructor & Destructor Documentation

◆ BacktrackableIntegerSet()

template<typename IntType >
operations_research::bop::BacktrackableIntegerSet< IntType >::BacktrackableIntegerSet ( )
default

Member Function Documentation

◆ AddBacktrackingLevel()

template<typename IntType >
void operations_research::bop::BacktrackableIntegerSet< IntType >::AddBacktrackingLevel ( )

BacktrackOneLevel() backtracks to the state the class was in when the last AddBacktrackingLevel() was called. BacktrackAll() just restore the class to its state just after the last ClearAndResize().

Definition at line 170 of file bop_ls.cc.

◆ BacktrackAll()

template<typename IntType >
void operations_research::bop::BacktrackableIntegerSet< IntType >::BacktrackAll ( )

Definition at line 191 of file bop_ls.cc.

◆ BacktrackOneLevel()

template<typename IntType >
void operations_research::bop::BacktrackableIntegerSet< IntType >::BacktrackOneLevel ( )

Definition at line 176 of file bop_ls.cc.

◆ ChangeState()

template<typename IntType >
void operations_research::bop::BacktrackableIntegerSet< IntType >::ChangeState ( IntType i,
bool should_be_inside )

Changes the state of the given integer i to be either inside or outside the set. Important: this should only be called with the opposite state of the current one, otherwise size() will not be correct.

Definition at line 160 of file bop_ls.cc.

◆ ClearAndResize()

template<typename IntType >
void operations_research::bop::BacktrackableIntegerSet< IntType >::ClearAndResize ( IntType n)

Prepares the class for integers in [0, n) and initializes the set to the empty one. Note that this run in O(n). Once resized, it is better to call BacktrackAll() instead of this to clear the set.

BacktrackableIntegerSet

Definition at line 151 of file bop_ls.cc.

◆ size()

template<typename IntType >
int operations_research::bop::BacktrackableIntegerSet< IntType >::size ( ) const
inline

Returns the current number of elements in the set.

Note
this is not its maximum size n.

Definition at line 193 of file bop_ls.h.

◆ Superset()

template<typename IntType >
const std::vector< IntType > & operations_research::bop::BacktrackableIntegerSet< IntType >::Superset ( ) const
inline

Returns a superset of the current set of integers.

Definition at line 196 of file bop_ls.h.


The documentation for this class was generated from the following files: