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

#include <rev.h>

Inheritance diagram for operations_research::RevRepository< T >:
operations_research::ReversibleInterface

Public Member Functions

 RevRepository ()
 
void SetLevel (int level) final
 
int Level () const
 
void SaveState (T *object)
 
void SaveStateWithStamp (T *object, int64_t *stamp)
 
- Public Member Functions inherited from operations_research::ReversibleInterface
 ReversibleInterface ()
 
virtual ~ReversibleInterface ()
 

Detailed Description

template<class T>
class operations_research::RevRepository< T >

A repository that maintains a set of reversible objects of type T. This is meant to be used for small types that are efficient to copy, like all the basic types, std::pair and things like this.

Definition at line 48 of file rev.h.

Constructor & Destructor Documentation

◆ RevRepository()

template<class T >
operations_research::RevRepository< T >::RevRepository ( )
inline

Definition at line 50 of file rev.h.

Member Function Documentation

◆ Level()

template<class T >
int operations_research::RevRepository< T >::Level ( ) const
inline

Definition at line 55 of file rev.h.

◆ SaveState()

template<class T >
void operations_research::RevRepository< T >::SaveState ( T * object)
inline

Saves the given object value for the current level. If this is called multiple time by level, only the value of the first call matter. This is NOT optimized for many calls by level and should mainly be used just once for a given level. If a client cannot do that efficiently, it can use the SaveStateWithStamp() function below.

Definition at line 62 of file rev.h.

◆ SaveStateWithStamp()

template<class T >
void operations_research::RevRepository< T >::SaveStateWithStamp ( T * object,
int64_t * stamp )
inline

Calls SaveState() if the given stamp is not the same as the current one. This also sets the given stamp to the current one. The current stamp is maintained by this class and is updated on each level changes. The whole process make sure that only one SaveValue() par level will ever be called, so it is efficient to call this before each update to the object T.

Definition at line 72 of file rev.h.

◆ SetLevel()

template<class T >
void operations_research::RevRepository< T >::SetLevel ( int level)
finalvirtual

This works in O(level_diff) on level increase. For level decrease, it is in O(level_diff + num_restored_states).

Implements operations_research::ReversibleInterface.

Definition at line 135 of file rev.h.


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