Static class allowing to compress expressions given a boolean predicate. More...
#include <lock.h>
Public Types | |
| using | ID_t = int |
| Typedef for lock id. | |
| using | predicate = std::function< bool(Expr const &)> |
| Typedef for the boolean predicate. | |
Static Public Member Functions | |
| static void | lock (Expr &init, int lockId, predicate const &f) |
| Abbreviates all parts of an expression depending on a condition. More... | |
| static void | lock (Expr &init, predicate const &f) |
| Abbreviates all parts of an expression depending on a condition. More... | |
| static void | unlock (Expr &init, int lockId) |
| Expand abbreviations from a previous lock. The lock id should be the same. More... | |
| static void | unlock (Expr &init) |
| Expand abbreviations from a previous lock. The lock id should be the same. More... | |
| static std::string | lockNameOf (ID_t id) |
| Returns the generic abbreviation name of a lock given its id. More... | |
Static class allowing to compress expressions given a boolean predicate.
When doing heavy calculations, many sub expressions are not needed and just slow down (while taking memory) the calculation. This class can, given a boolean predicate, abbreviate all these expressions (lock()). After the calculation, you may re-expand the abbreviations (unlock()).
Abbreviates all parts of an expression depending on a condition.
Any sub expression sub in expr such that f(sub) == false is abbreviated. This allows to compress all the information that is not needed when performing a given calculation. Large parts of expressions may be totally useless and must be abbreviated in order to minimize their impact on memory and computation time. To be clear, f should return true on objects that are important for the calculation, i.e. that must not be abbreviated.
| init | Expression to lock. |
| lockID | Lock id, allows to differentiate different locks when unlocking. |
| f | Boolean predicate. |
Abbreviates all parts of an expression depending on a condition.
Any sub expression sub in expr such that f(sub) == false is abbreviated. This allows to compress all the information that is not needed when performing a given calculation. Large parts of expressions may be totally useless and must be abbreviated in order to minimize their impact on memory and computation time. To be clear, f should return true on objects that are important for the calculation, i.e. that must not be abbreviated.
| init | Expression to lock. |
| f | Boolean predicate. |
|
static |
Returns the generic abbreviation name of a lock given its id.
| lockID | Id of the lock. |
|
static |
Expand abbreviations from a previous lock. The lock id should be the same.
| init | Expression to unlock. |
| lockID | Lock id, allows to differentiate different locks when unlocking. |
|
static |
Expand abbreviations from a previous lock. The lock id should be the same.
| init | Expression to unlock. |
1.8.13