|
Regina 7.4.1 Calculation Engine
|
A base class that assists with support for tight encodings and corresponding decodings. More...
#include <utilities/tightencoding.h>
Public Member Functions | |
| std::string | tightEncoding () const |
| Returns the tight encoding of this object. | |
| size_t | hash () const |
| Hashes this object to a non-negative integer, allowing it to be used for keys in hash tables. | |
Static Public Member Functions | |
| static T | tightDecoding (const std::string &enc) |
| Reconstructs an object of type T from its given tight encoding. | |
A base class that assists with support for tight encodings and corresponding decodings.
If a class T supports tight encodings, then it may derive from TightEncodable<T>. If it does, then your derived class must provide the following two functions, which implement tight encodings and decodings via input/output streams:
In return, this base class will provide the following three functions, which work with simpler (non-stream) data types, and which are documented in full below:
A class T that supports tight encodings does not need to derive from TightEncodable. However, if it does not then it should implement all five of the above functions itself. Examples of this include the permutation classes (which have optimised implementations due to their very small space requirements), and the arbitrary-precision integer classes (which use the global integer encoding/decoding routines and a simple arithmetic hash).
| T | the type of object being encoded/decoded; this must derive from TightEncodable<T>. |
|
inline |
Hashes this object to a non-negative integer, allowing it to be used for keys in hash tables.
This hash function makes use of Regina's tight encodings. In particular, any two objects with the same tight encoding will have equal hashes. This implementation (and therefore the specific hash value for each object) is subject to change in future versions of Regina.
|
inlinestatic |
Reconstructs an object of type T from its given tight encoding.
See the page on tight encodings for details.
The tight encoding should be given as a string. If this string contains leading whitespace or any trailing characters at all (including trailing whitespace), then it will be treated as an invalid encoding (i.e., this routine will throw an exception).
| InvalidArgument | The given string is not a tight encoding of an object of type T. |
| enc | the tight encoding for an object of type T. |
|
inline |
Returns the tight encoding of this object.
See the page on tight encodings for details.
| FailedPrecondition | This may be thrown for some classes T if the object is in an invalid state. If this is possible, then a more detailed explanation of "invalid" can be found in the class documentation for T, under the member function T::tightEncode(). See FacetPairing::tightEncode() for an example of this. |