|
Blender V5.0
|
#include <BLI_map_slots.hh>
Public Member Functions | |
| SimpleMapSlot () | |
| ~SimpleMapSlot () | |
| SimpleMapSlot (const SimpleMapSlot &other) | |
| SimpleMapSlot (SimpleMapSlot &&other) noexcept(std::is_nothrow_move_constructible_v< Key > &&std::is_nothrow_move_constructible_v< Value >) | |
| Key * | key () |
| const Key * | key () const |
| Value * | value () |
| const Value * | value () const |
| bool | is_occupied () const |
| bool | is_empty () const |
| template<typename Hash> | |
| uint64_t | get_hash (const Hash &hash) |
| template<typename ForwardKey, typename IsEqual> | |
| bool | contains (const ForwardKey &key, const IsEqual &is_equal, uint64_t) const |
| template<typename ForwardKey, typename... ForwardValue> | |
| void | occupy (ForwardKey &&key, uint64_t hash, ForwardValue &&...value) |
| template<typename ForwardKey> | |
| void | occupy_no_value (ForwardKey &&key, uint64_t) |
| void | remove () |
The simplest possible map slot. It stores the slot state and the optional key and value instances in separate variables. Depending on the alignment requirement of the key and value, many bytes might be wasted.
Definition at line 48 of file BLI_map_slots.hh.
|
inline |
After the default constructor has run, the slot has to be in the empty state.
Definition at line 64 of file BLI_map_slots.hh.
Referenced by SimpleMapSlot(), and SimpleMapSlot().
|
inline |
The destructor also has to destruct the key and value, if the slot is currently occupied.
Definition at line 72 of file BLI_map_slots.hh.
|
inline |
The copy constructor has to copy the state. If the other slot was occupied, a copy of the key and value have to be made as well.
Definition at line 84 of file BLI_map_slots.hh.
References blender::initialize_pointer_pair(), blender::TypedBuffer< T, Size >::ref(), and SimpleMapSlot().
|
inlinenoexcept |
The move constructor has to copy the state. If the other slot was occupied, the key and value from the other have to moved as well. The other slot stays in the state it was in before. Its optionally stored key and value remain in a moved-from state.
Definition at line 100 of file BLI_map_slots.hh.
References blender::initialize_pointer_pair(), and SimpleMapSlot().
|
inline |
Returns true, when this slot is occupied and contains a key that compares equal to the given key. The hash can be used by other slot implementations to determine inequality faster.
Definition at line 175 of file BLI_map_slots.hh.
References key().
|
inline |
Returns the hash of the currently stored key. In this simple map slot implementation, we just computed the hash here. Other implementations might store the hash in the slot instead.
Definition at line 164 of file BLI_map_slots.hh.
References BLI_assert, hash, and is_occupied().
|
inline |
Returns true if the slot is empty, i.e. it does not contain a key and is not in removed state.
Definition at line 155 of file BLI_map_slots.hh.
|
inline |
Returns true if the slot currently contains a key and a value.
Definition at line 147 of file BLI_map_slots.hh.
Referenced by get_hash(), occupy(), occupy_no_value(), and remove().
|
inline |
Returns a non-const pointer to the position where the key is stored.
Definition at line 115 of file BLI_map_slots.hh.
Referenced by contains(), occupy(), and occupy_no_value().
|
inline |
Returns a const pointer to the position where the key is stored.
Definition at line 123 of file BLI_map_slots.hh.
|
inline |
Change the state of this slot from empty/removed to occupied. The key/value has to be constructed by calling the constructor with the given key/value as parameter.
Definition at line 188 of file BLI_map_slots.hh.
References BLI_assert, hash, is_occupied(), key(), occupy_no_value(), and value().
|
inline |
Change the state of this slot from empty/removed to occupied. The value is assumed to be constructed already.
Definition at line 200 of file BLI_map_slots.hh.
References BLI_assert, is_occupied(), and key().
Referenced by occupy().
|
inline |
Change the state of this slot from occupied to removed. The key and value have to be destructed as well.
Definition at line 218 of file BLI_map_slots.hh.
References BLI_assert, is_occupied(), and blender::TypedBuffer< T, Size >::ref().
|
inline |
Returns a non-const pointer to the position where the value is stored.
Definition at line 131 of file BLI_map_slots.hh.
Referenced by occupy().
|
inline |
Returns a const pointer to the position where the value is stored.
Definition at line 139 of file BLI_map_slots.hh.