Blender V5.0
blender::SimpleSetSlot< Key > Class Template Reference

#include <BLI_set_slots.hh>

Public Member Functions

 SimpleSetSlot ()
 ~SimpleSetSlot ()
 SimpleSetSlot (const SimpleSetSlot &other)
 SimpleSetSlot (SimpleSetSlot &&other) noexcept(std::is_nothrow_move_constructible_v< Key >)
Keykey ()
const Keykey () const
bool is_occupied () const
bool is_empty () const
template<typename Hash>
uint64_t get_hash (const Hash &hash) const
template<typename ForwardKey, typename IsEqual>
bool contains (const ForwardKey &key, const IsEqual &is_equal, uint64_t) const
template<typename ForwardKey>
void occupy (ForwardKey &&key, uint64_t)
void remove ()

Detailed Description

template<typename Key>
class blender::SimpleSetSlot< Key >

The simplest possible set slot. It stores the slot state and the optional key instance in separate variables. Depending on the alignment requirement of the key, many bytes might be wasted.

Definition at line 33 of file BLI_set_slots.hh.

Constructor & Destructor Documentation

◆ SimpleSetSlot() [1/3]

template<typename Key>
blender::SimpleSetSlot< Key >::SimpleSetSlot ( )
inline

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

Definition at line 48 of file BLI_set_slots.hh.

Referenced by SimpleSetSlot(), and SimpleSetSlot().

◆ ~SimpleSetSlot()

template<typename Key>
blender::SimpleSetSlot< Key >::~SimpleSetSlot ( )
inline

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

Definition at line 56 of file BLI_set_slots.hh.

◆ SimpleSetSlot() [2/3]

template<typename Key>
blender::SimpleSetSlot< Key >::SimpleSetSlot ( const SimpleSetSlot< Key > & other)
inline

The copy constructor has to copy the state. If the other slot was occupied, a copy of the key has to be made as well.

Definition at line 67 of file BLI_set_slots.hh.

References SimpleSetSlot().

◆ SimpleSetSlot() [3/3]

template<typename Key>
blender::SimpleSetSlot< Key >::SimpleSetSlot ( SimpleSetSlot< Key > && other)
inlinenoexcept

The move constructor has to copy the state. If the other slot was occupied, the key from the other slot has to be moved as well. The other slot stays in the state it was in before. Its optionally stored key remains in a moved-from state.

Definition at line 80 of file BLI_set_slots.hh.

References SimpleSetSlot().

Member Function Documentation

◆ contains()

template<typename Key>
template<typename ForwardKey, typename IsEqual>
bool blender::SimpleSetSlot< Key >::contains ( const ForwardKey & key,
const IsEqual & is_equal,
uint64_t  ) const
inline

Return true, when this slot is occupied and contains a key that compares equal to the given key. The hash is used by other slot implementations to determine inequality faster.

Definition at line 135 of file BLI_set_slots.hh.

References key().

◆ get_hash()

template<typename Key>
template<typename Hash>
uint64_t blender::SimpleSetSlot< Key >::get_hash ( const Hash & hash) const
inline

Return the hash of the currently stored key. In this simple set slot implementation, we just compute the hash here. Other implementations might store the hash in the slot instead.

Definition at line 124 of file BLI_set_slots.hh.

References BLI_assert, hash, and is_occupied().

◆ is_empty()

template<typename Key>
bool blender::SimpleSetSlot< Key >::is_empty ( ) const
inline

Return true if the slot is empty, i.e. it does not contain a key and is not in removed state.

Definition at line 115 of file BLI_set_slots.hh.

◆ is_occupied()

template<typename Key>
bool blender::SimpleSetSlot< Key >::is_occupied ( ) const
inline

Return true if the slot currently contains a key.

Definition at line 107 of file BLI_set_slots.hh.

Referenced by get_hash(), occupy(), and remove().

◆ key() [1/2]

template<typename Key>
Key * blender::SimpleSetSlot< Key >::key ( )
inline

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

Definition at line 91 of file BLI_set_slots.hh.

Referenced by contains(), and occupy().

◆ key() [2/2]

template<typename Key>
const Key * blender::SimpleSetSlot< Key >::key ( ) const
inline

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

Definition at line 99 of file BLI_set_slots.hh.

◆ occupy()

template<typename Key>
template<typename ForwardKey>
void blender::SimpleSetSlot< Key >::occupy ( ForwardKey && key,
uint64_t  )
inline

Change the state of this slot from empty/removed to occupied. The key has to be constructed by calling the constructor with the given key as parameter.

Definition at line 147 of file BLI_set_slots.hh.

References BLI_assert, is_occupied(), and key().

◆ remove()

template<typename Key>
void blender::SimpleSetSlot< Key >::remove ( )
inline

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

Definition at line 157 of file BLI_set_slots.hh.

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


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