1 2 3 4 5 6 7 8 9 10 11 12 13 14 15 16 17 18 19 20 21 22 23 24 25 26 27 28 29 30 31 32 33 34 35 36 37 38 39 40 41 42 43 44 45 46 47 48 49 50 51 52 53 54 55 56 57 58 59 60 61 62 63 64 65 66 67 68 69 70 71 72 73 74 75 76 77 78 79 80 81 82 83 84 85 86 87 88 89 90 91 92 93 94 95 96 97 98 99
|
## type_hash
### Synopsis
Defined in <boost/openmethod/policies/basic_policy.hpp>.
```c++
namespace boost::openmethod::policies {
struct type_hash : policy {};
} // boost::openmethod::policies
```
### Description
`type_hash` is a policy that provides a hash function for a fixed set of
`type_id`{empty}s.
### Requirements
### hash_type_id
```c++
static auto hash_type_id(type_id type) -> type_id;
```
Returns the hash of `type`.
#### hash_initialize
```c++
template<typename ForwardIterator>
static auto hash_initialize(ForwardIterator first, ForwardIterator last)
-> Report;
```
Finds a hash function for the `type_id`{empty}s in the range `[first, last)`.
`ForwardIterator` is the same as in `vptr_vector::register_vptrs`.
`hash_initialize` returns a `Report` object which is required to have two
members, `first` and `last`, which define the range `[first, last)` of the
possible output values of the hash function.
## fast_perfect_hash
### Synopsis
Defined in <boost/openmethod/policies/fast_perfect_hash.hpp>.
```c++
class fast_perfect_hash : type_hash
{
public:
static auto hash_type_id(type_id type) -> type_id;
template<typename ForwardIterator>
static auto hash_initialize(ForwardIterator first, ForwardIterator last) -> Report;
};
```
### Description
`fast_perfect_hash` implements a very fast, perfect (but not minimal) hash
function for `type_id`{empty}s.
### Members
Find two factors
#### hash_type_id
```c++
static auto hash_type_id(type_id type) -> type_id;
```
Returns `(type * M) >> S`, where `M` and `S` are factors found by
`hash_initialize`.
If the policy has a `runtime_checks` policy, `hash_type_id` checks that `type`
corresponds to a registered class. If not, it reports a `unknown_class_error`
using the policy's error_handler policy, if present, then calls `abort`.
#### hash_initialize
```c++
template<typename ForwardIterator>
auto hash_initialize(ForwardIterator first, ForwardIterator last) -> Report;
```
Finds factors `M` and `S` such that `hash_type_id` is a collision-free hash
function.
If no such factors cannot be found, `hash_initialize` reports a
`hash_search_error` using the policy's error_handler policy, if present, the
calls `abort`.
If the policy has a `trace` policy, `hash_initialize` uses it to write a
summary of the search.
|