Blender  V3.3
Public Member Functions | List of all members
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 UNUSED(hash)) 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 UNUSED(hash))
 
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 45 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 61 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 69 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 81 of file BLI_map_slots.hh.

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

◆ 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 97 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   UNUSEDhash 
) 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 172 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 161 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 152 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 112 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 120 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 185 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(), blender::SimpleMapSlot< Key, Value >::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   UNUSEDhash 
)
inline

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

Definition at line 197 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 215 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 128 of file BLI_map_slots.hh.

References Value.

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

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

References Value.


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