Blender V4.3
blender::SimpleMapSlot< Key, Value > Class Template Reference

#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 >)
 
Keykey ()
 
const Keykey () 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 ()
 

Detailed Description

template<typename Key, typename Value>
class blender::SimpleMapSlot< Key, Value >

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 47 of file BLI_map_slots.hh.

Constructor & Destructor Documentation

◆ SimpleMapSlot() [1/3]

template<typename Key , typename Value >
blender::SimpleMapSlot< Key, Value >::SimpleMapSlot ( )
inline

After the default constructor has run, the slot has to be in the empty state.

Definition at line 63 of file BLI_map_slots.hh.

◆ ~SimpleMapSlot()

template<typename Key , typename Value >
blender::SimpleMapSlot< Key, Value >::~SimpleMapSlot ( )
inline

The destructor also has to destruct the key and value, if the slot is currently occupied.

Definition at line 71 of file BLI_map_slots.hh.

References blender::TypedBuffer< T, Size >::ref().

◆ SimpleMapSlot() [2/3]

template<typename Key , typename Value >
blender::SimpleMapSlot< Key, Value >::SimpleMapSlot ( const SimpleMapSlot< Key, Value > & other)
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 83 of file BLI_map_slots.hh.

References blender::initialize_pointer_pair(), and blender::TypedBuffer< T, Size >::ptr().

◆ SimpleMapSlot() [3/3]

template<typename Key , typename Value >
blender::SimpleMapSlot< Key, Value >::SimpleMapSlot ( SimpleMapSlot< Key, Value > && other)
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 99 of file BLI_map_slots.hh.

References blender::initialize_pointer_pair(), and blender::TypedBuffer< T, Size >::ptr().

Member Function Documentation

◆ contains()

template<typename Key , typename Value >
template<typename ForwardKey , typename IsEqual >
bool blender::SimpleMapSlot< Key, Value >::contains ( const ForwardKey & key,
const IsEqual & is_equal,
uint64_t  ) const
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 174 of file BLI_map_slots.hh.

References blender::SimpleMapSlot< Key, Value >::key().

◆ get_hash()

template<typename Key , typename Value >
template<typename Hash >
uint64_t blender::SimpleMapSlot< Key, Value >::get_hash ( const Hash & hash)
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 163 of file BLI_map_slots.hh.

References BLI_assert, hash, and blender::SimpleMapSlot< Key, Value >::is_occupied().

◆ is_empty()

template<typename Key , typename Value >
bool blender::SimpleMapSlot< Key, Value >::is_empty ( ) const
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 154 of file BLI_map_slots.hh.

◆ is_occupied()

template<typename Key , typename Value >
bool blender::SimpleMapSlot< Key, Value >::is_occupied ( ) const
inline

◆ key() [1/2]

template<typename Key , typename Value >
Key * blender::SimpleMapSlot< Key, Value >::key ( )
inline

Returns a non-const pointer to the position where the key is stored.

Definition at line 114 of file BLI_map_slots.hh.

Referenced by blender::SimpleMapSlot< Key, Value >::contains(), blender::SimpleMapSlot< Key, Value >::occupy(), and blender::SimpleMapSlot< Key, Value >::occupy_no_value().

◆ key() [2/2]

template<typename Key , typename Value >
const Key * blender::SimpleMapSlot< Key, Value >::key ( ) const
inline

Returns a const pointer to the position where the key is stored.

Definition at line 122 of file BLI_map_slots.hh.

◆ occupy()

template<typename Key , typename Value >
template<typename ForwardKey , typename... ForwardValue>
void blender::SimpleMapSlot< Key, Value >::occupy ( ForwardKey && key,
uint64_t hash,
ForwardValue &&... value )
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 187 of file BLI_map_slots.hh.

References BLI_assert, hash, blender::SimpleMapSlot< Key, Value >::is_occupied(), blender::SimpleMapSlot< Key, Value >::key(), blender::SimpleMapSlot< Key, Value >::occupy_no_value(), and Value.

◆ occupy_no_value()

template<typename Key , typename Value >
template<typename ForwardKey >
void blender::SimpleMapSlot< Key, Value >::occupy_no_value ( ForwardKey && key,
uint64_t  )
inline

Change the state of this slot from empty/removed to occupied. The value is assumed to be constructed already.

Definition at line 199 of file BLI_map_slots.hh.

References BLI_assert, blender::SimpleMapSlot< Key, Value >::is_occupied(), blender::SimpleMapSlot< Key, Value >::key(), and blender::TypedBuffer< T, Size >::ref().

Referenced by blender::SimpleMapSlot< Key, Value >::occupy().

◆ remove()

template<typename Key , typename Value >
void blender::SimpleMapSlot< Key, Value >::remove ( )
inline

Change the state of this slot from occupied to removed. The key and value have to be destructed as well.

Definition at line 217 of file BLI_map_slots.hh.

References BLI_assert, blender::SimpleMapSlot< Key, Value >::is_occupied(), and blender::TypedBuffer< T, Size >::ref().

◆ value() [1/2]

template<typename Key , typename Value >
Value * blender::SimpleMapSlot< Key, Value >::value ( )
inline

Returns a non-const pointer to the position where the value is stored.

Definition at line 130 of file BLI_map_slots.hh.

◆ value() [2/2]

template<typename Key , typename Value >
const Value * blender::SimpleMapSlot< Key, Value >::value ( ) const
inline

Returns a const pointer to the position where the value is stored.

Definition at line 138 of file BLI_map_slots.hh.


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