Add more documentation

This commit is contained in:
Tessil 2017-08-20 19:21:00 +02:00
parent 05ba965518
commit 3cd984323d
4 changed files with 17 additions and 7 deletions

View File

@ -893,6 +893,7 @@ EXCLUDE_PATTERNS =
EXCLUDE_SYMBOLS = \
tsl::detail_robin_hash::has_is_transparent* \
tsl::detail_robin_hash::make_void* \
tsl::detail_robin_hash::is_power_of_two_policy* \
tsl::detail_robin_hash::bucket_entry*
# The EXAMPLE_PATH tag can be used to specify one or more files or directories

View File

@ -227,8 +227,9 @@ static constexpr const std::array<std::size_t(*)(std::size_t), 39> MOD_PRIME = {
* but will probably distribute the values around better in the buckets with a poor hash function.
*
* To allow the compiler to optimize the modulo operation, a lookup table is used with constant primes numbers.
* With a switch the code would look like:
*
* With a switch the code would look like:
* \code
* switch(iprime) { // iprime is the current prime of the hash table
* case 0: hash % 5ul;
* break;
@ -238,10 +239,12 @@ static constexpr const std::array<std::size_t(*)(std::size_t), 39> MOD_PRIME = {
* break;
* ...
* }
* \endcode
*
* Due to the constant variable in the modulo the compiler is able to optimize the operation
* by a serie of multiplications, substractions and shifts.
* The 'hash % 5' could become something like 'hash - (hash * 0xCCCCCCCD) >> 34)*5' in a 64 bits environement.
* by a series of multiplications, substractions and shifts.
*
* The 'hash % 5' could become something like 'hash - (hash * 0xCCCCCCCD) >> 34) * 5' in a 64 bits environement.
*/
class prime_growth_policy_rh {
public:

View File

@ -38,7 +38,7 @@ namespace tsl {
/**
* Implementation of a hash map using open-adressing and the robin hood hashing algorithm.
* Implementation of a hash map using open-adressing and the robin hood hashing algorithm with backward shift deletion.
*
* For operations modifying the hash map (insert, erase, rehash, ...), the strong exception guarantee
* is only guaranteed when the expression 'std::is_nothrow_swappable<std::pair<Key, T>>::value &&
@ -48,7 +48,7 @@ namespace tsl {
* 'std::is_nothrow_move_constructible<std::pair<Key, T>>::value' criterion (and will thus guarantee the
* strong exception for the map).
*
* When StoreHash is true, 32 bits of the hash is stored alongside the values. It can improve
* When StoreHash is true, 32 bits of the hash are stored alongside the values. It can improve
* the performance during lookups if the KeyEqual function takes time (or engenders a cache-miss for example)
* as we then compare the stored hashes before comparing the keys. When tsl::power_of_two_growth_policy_rh is used
* as GrowthPolicy, it may also speed-up the rehash process as we can avoid to recalculate the hash.
@ -652,6 +652,9 @@ private:
};
/**
* Same as tsl::robin_map<Key, T, Hash, KeyEqual, Allocator, StoreHash, tsl::prime_growth_policy_rh>.
*/
template<class Key,
class T,
class Hash = std::hash<Key>,

View File

@ -38,7 +38,7 @@ namespace tsl {
/**
* Implementation of a hash set using open-adressing and the robin hood hashing algorithm.
* Implementation of a hash set using open-adressing and the robin hood hashing algorithm with backward shift deletion.
*
* For operations modifying the hash set (insert, erase, rehash, ...), the strong exception guarantee
* is only guaranteed when the expression 'std::is_nothrow_swappable<Key>::value &&
@ -48,7 +48,7 @@ namespace tsl {
* 'std::is_nothrow_move_constructible<Key>::value' criterion (and will thus guarantee the
* strong exception for the set).
*
* When StoreHash is true, 32 bits of the hash is stored alongside the values. It can improve
* When StoreHash is true, 32 bits of the hash are stored alongside the values. It can improve
* the performance during lookups if the KeyEqual function takes time (or engenders a cache-miss for example)
* as we then compare the stored hashes before comparing the keys. When tsl::power_of_two_growth_policy_rh is used
* as GrowthPolicy, it may also speed-up the rehash process as we can avoid to recalculate the hash.
@ -519,6 +519,9 @@ private:
};
/**
* Same as tsl::robin_set<Key, Hash, KeyEqual, Allocator, StoreHash, tsl::prime_growth_policy_rh>.
*/
template<class Key,
class Hash = std::hash<Key>,
class KeyEqual = std::equal_to<Key>,