Turi Create
4.0
|
#include <core/generics/value_container_mapper.hpp>
Public Member Functions | |
void | reserve (size_t n) |
size_t | size () const |
void | clear () |
void | insert (const hashkey_and_value &hv, ValueContainer *v_ptr) GL_HOT_INLINE_FLATTEN |
void | insert (const hashkey &hk, ValueContainer *v_ptr) GL_HOT_INLINE_FLATTEN |
ValueContainer * | find (const hashkey_and_value &hv) GL_HOT_INLINE_FLATTEN |
ValueContainer * | find (const hashkey &key, const Value &t) GL_HOT_INLINE_FLATTEN |
const ValueContainer * | find (const hashkey_and_value &hv) const GL_HOT_INLINE_FLATTEN |
const ValueContainer * | find (const hashkey &key, const Value &t) const GL_HOT_INLINE_FLATTEN |
void | invalidate (const hashkey_and_value &hv, ValueContainer *v_ptr) GL_HOT_INLINE_FLATTEN |
void | invalidate (const hashkey &hk, ValueContainer *v_ptr) GL_HOT_INLINE_FLATTEN |
A fast, specialized container to track lookups from a Value to a container holding that value (plus other things). Essentially, this is very optimized version of std::map<Value, ValueContainer*>, which adds the following assumptions on the API and the ValueContainer type in order to be really fast.
For a usage example, see ml/sketches/space_saving.hpp.
The value_container_mapper::hashkey class is initializable by value:
struct hashkey { hashkey(); hashkey(const Value& v);
// A bunch of internal methods... };
The value_container_mapper::hashkey_and_value is initializable either by value (in which case the hashkey is created from a hash of the value), or by hashkey and value pair. It also implements key() and value() methods to return the hashkey() and value() respectively:
struct hashkey_and_value { hashkey_and_value(); hashkey_and_value(const Value& v); hashkey_and_value(const hashkey& hk, const Value& v);
hashkey key() const; const Value& value() const;
// A bunch of internal methods... };
Definition at line 76 of file value_container_mapper.hpp.
|
inline |
Clears the hash table.
Definition at line 98 of file value_container_mapper.hpp.
|
inline |
Returns the container associated with this key and value. If it's not present or has been invalidated, returns nullptr.
Definition at line 121 of file value_container_mapper.hpp.
|
inline |
Same as above, but avoids a potential copy operation of the value if it is not stored in a hashkey_and_value instance already. This is an overloaded member function, provided for convenience. It differs from the above function only in what argument(s) it accepts.
Definition at line 130 of file value_container_mapper.hpp.
|
inline |
Returns the container associated with this (key, value). If it's not present, returns nullptr. Const overload. This is an overloaded member function, provided for convenience. It differs from the above function only in what argument(s) it accepts.
Definition at line 138 of file value_container_mapper.hpp.
|
inline |
Same as above, but avoids a potential copy operation of the value if it is not stored in a hashkey_and_value instance already. Const overload. This is an overloaded member function, provided for convenience. It differs from the above function only in what argument(s) it accepts.
Definition at line 147 of file value_container_mapper.hpp.
|
inline |
Inserts a lookup index into the hash mapping.
Definition at line 104 of file value_container_mapper.hpp.
|
inline |
Inserts a lookup index into the hash mapping. Overload that pulls the value from v_ptr. This is an overloaded member function, provided for convenience. It differs from the above function only in what argument(s) it accepts.
Definition at line 114 of file value_container_mapper.hpp.
|
inline |
Marks a particular value_container as invalid. It is assumed, however, that as long as ValueContainer* holds the value, it is a valid key; otherwise it is not. This function does some lazy cleanup, but may not erase the key.
Definition at line 156 of file value_container_mapper.hpp.
|
inline |
Marks a particular value_container as invalid. It is assumed, however, that as long as ValueContainer* holds the value, it is a valid key; otherwise it is not. This function does some lazy cleanup, but may not erase the key.
Overload that pulls the value from v_ptr. This is an overloaded member function, provided for convenience. It differs from the above function only in what argument(s) it accepts.
Definition at line 170 of file value_container_mapper.hpp.
|
inline |
Reserves internal storage for n elements.
Definition at line 88 of file value_container_mapper.hpp.
|
inline |
Returns the current size of the hash table.
Definition at line 92 of file value_container_mapper.hpp.