emilib
Public Member Functions | Friends | List of all members
emilib::HashCache< T > Class Template Reference

#include <hash_cache.hpp>

Public Member Functions

 HashCache (T value) noexcept
 
 HashCache (const HashCache &other)
 
const HashCacheoperator= (const HashCache &other)
 
 HashCache (HashCache &&other) noexcept
 
void operator= (HashCache &&other) noexcept
 
void swap (HashCache &other) noexcept
 
const T & value () const
 
std::size_t hash () const
 
 operator T ()
 

Friends

bool operator== (const HashCache &a, const HashCache &b)
 
bool operator!= (const HashCache &a, const HashCache &b)
 

Detailed Description

template<typename T>
class emilib::HashCache< T >

Wraps a value and memoizes the hash of that value. This can be used to speed up std::unoredred_set/unoredred_map or emilib::HashSet/HashMap when calculating the hash of the key is expensive. Example: HashMap<Key, Value> -> HashMap<HashCache<Key>, Value> Example: HashSet<Key, KeyHasher> -> HashSet<HashCache<Key>, HashCacheHasher<KeyHasher>>


The documentation for this class was generated from the following file: