Generated on: Thu Mar 29 07:46:58 PDT 2012 for custom file set | ||
|
||
#include <monoid_operation_tree.h>
Public Member Functions | |
MonoidOperationTree (int size) | |
Constructs a MonoidOperationTree able to store 'size' operands. | |
virtual | ~MonoidOperationTree () |
const T & | result () const |
Returns the root of the tree, containing the result of the operation. | |
void | Reset (int argument_index) |
Resets the argument of given index. | |
void | Set (int argument_index, const T &argument) |
Sets the argument of given index. | |
void | Clear () |
Resets all arguments. | |
const T & | GetOperand (int argument_index) const |
Returns the leaf node corresponding to the given argument index. | |
template<class Diver> | |
void | DiveInTree (Diver *diver) const |
Dive down a branch of the operation tree, and then come back up. | |
string | DebugString () const |
Associative means a*(b*c) = (a*b)*c for all a,b,c in S. An identity element is an element e in S such that for all a in S, e*a = a*e = a. See http://en.wikipedia.org/wiki/Monoid for more details.
A MonoidOperationTree is a data structure that maintains a product a_1 * a_2 * ... * a_n for a given (fixed) n, and that supports the following functions:
Note that the monoid is not required to be commutative.
The parameter class T represents an element of the set S. It must: Have a public no-argument constructor producing the identity element. Have a Set(const T& value) method that sets its value to the given one. Have a Compute(const T& left, const T& right) method that sets its value to the result of the binary operation for the two given operands. Have a string DebugString() const method.
Possible use cases are: Maintain a sum or a product of doubles, with a guarantee that the queried result is independent of the order of past numerical issues Maintain a product of identically sized square matrices, which is an example of use with non-commutative operations.
Definition at line 57 of file monoid_operation_tree.h.
operations_research::MonoidOperationTree< T >::MonoidOperationTree | ( | int | size | ) | [inline, explicit] |
Constructs a MonoidOperationTree able to store 'size' operands.
Definition at line 168 of file monoid_operation_tree.h.
virtual operations_research::MonoidOperationTree< T >::~MonoidOperationTree | ( | ) | [inline, virtual] |
Definition at line 61 of file monoid_operation_tree.h.
const T& operations_research::MonoidOperationTree< T >::result | ( | ) | const [inline] |
Returns the root of the tree, containing the result of the operation.
Definition at line 64 of file monoid_operation_tree.h.
void operations_research::MonoidOperationTree< T >::Reset | ( | int | argument_index | ) | [inline] |
void operations_research::MonoidOperationTree< T >::Set | ( | int | argument_index, | |
const T & | argument | |||
) | [inline] |
void operations_research::MonoidOperationTree< T >::Clear | ( | ) | [inline] |
const T& operations_research::MonoidOperationTree< T >::GetOperand | ( | int | argument_index | ) | const [inline] |
Returns the leaf node corresponding to the given argument index.
Definition at line 76 of file monoid_operation_tree.h.
void operations_research::MonoidOperationTree< T >::DiveInTree | ( | Diver * | diver | ) | const [inline] |
Dive down a branch of the operation tree, and then come back up.
Definition at line 82 of file monoid_operation_tree.h.
string operations_research::MonoidOperationTree< T >::DebugString | ( | ) | const [inline] |
Definition at line 222 of file monoid_operation_tree.h.