Blender  V3.3
Public Member Functions | List of all members
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 UNUSED(hash)) const
 
template<typename ForwardKey >
void occupy (ForwardKey &&key, uint64_t UNUSED(hash))
 
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 30 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 45 of file BLI_set_slots.hh.

◆ ~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 53 of file BLI_set_slots.hh.

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

◆ 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 64 of file BLI_set_slots.hh.

◆ 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 77 of file BLI_set_slots.hh.

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   UNUSEDhash 
) 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 132 of file BLI_set_slots.hh.

References blender::SimpleSetSlot< Key >::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 121 of file BLI_set_slots.hh.

References BLI_assert, hash, and blender::SimpleSetSlot< Key >::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 112 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 104 of file BLI_set_slots.hh.

Referenced by blender::SimpleSetSlot< Key >::get_hash(), blender::SimpleSetSlot< Key >::occupy(), and blender::SimpleSetSlot< Key >::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 88 of file BLI_set_slots.hh.

Referenced by blender::SimpleSetSlot< Key >::contains(), and blender::SimpleSetSlot< Key >::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 96 of file BLI_set_slots.hh.

◆ occupy()

template<typename Key >
template<typename ForwardKey >
void blender::SimpleSetSlot< Key >::occupy ( ForwardKey &&  key,
uint64_t   UNUSEDhash 
)
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 144 of file BLI_set_slots.hh.

References BLI_assert, blender::SimpleSetSlot< Key >::is_occupied(), and blender::SimpleSetSlot< Key >::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 154 of file BLI_set_slots.hh.

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


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