qb  2.0.0.0
C++17 Actor Framework
qb Issue Watch Star Fork Follow @isndev
Loading...
Searching...
No Matches
qb::CoreIdBitSet Class Reference

Efficient representation of a set of core IDs using a bitset. More...

#include <ActorId.h>

Classes

class  iterator
 Iterator for traversing set bits in a CoreIdBitSet. More...

Public Member Functions

 CoreIdBitSet ()=default
 Default constructor - creates an empty set.
 CoreIdBitSet (const qb::unordered_set< CoreId > &coreIds)
 Constructor from a set of core IDs.
 CoreIdBitSet (std::initializer_list< CoreId > ids)
 Constructor from an initializer list.
const std::bitset< MaxCores > & bits () const noexcept
 Get the raw bitset.
bool contains (CoreId id) const noexcept
 Check if a core ID is in the set.
void insert (CoreId id) noexcept
 Add a core ID to the set.
void emplace (CoreId id) noexcept
 Add a core ID to the set (emplace version)
void remove (CoreId id) noexcept
 Remove a core ID from the set.
void clear () noexcept
 Clear all core IDs from the set.
bool empty () const noexcept
 Check if the set is empty.
size_t size () const noexcept
 Get the number of core IDs in the set.
std::vector< CoreIdto_vector () const
 Convert the set to a vector of core IDs.
qb::unordered_set< CoreIdto_unordered_set () const
 Get an unordered_set of the core IDs.
qb::unordered_set< CoreIdraw () const
 Get a reference to the raw set for internal use.
iterator begin () const
 Get an iterator to the beginning of the set.
iterator end () const
 Get an iterator to the end of the set.

Detailed Description

Efficient representation of a set of core IDs using a bitset.

This class provides bitset-based storage for core IDs, which is more memory efficient and provides faster set operations than unordered_set.

Member Function Documentation

◆ bits()

const std::bitset< MaxCores > & qb::CoreIdBitSet::bits ( ) const
inlinenodiscardnoexcept

Get the raw bitset.

Returns
Reference to the underlying bitset

◆ contains()

bool qb::CoreIdBitSet::contains ( CoreId id) const
inlinenodiscardnoexcept

Check if a core ID is in the set.

Parameters
idCore ID to check
Returns
true if the ID is in the set, false otherwise

◆ insert()

void qb::CoreIdBitSet::insert ( CoreId id)
inlinenoexcept

Add a core ID to the set.

Parameters
idCore ID to add

◆ emplace()

void qb::CoreIdBitSet::emplace ( CoreId id)
inlinenoexcept

Add a core ID to the set (emplace version)

Parameters
idCore ID to add

◆ remove()

void qb::CoreIdBitSet::remove ( CoreId id)
inlinenoexcept

Remove a core ID from the set.

Parameters
idCore ID to remove

◆ empty()

bool qb::CoreIdBitSet::empty ( ) const
inlinenodiscardnoexcept

Check if the set is empty.

Returns
true if the set is empty, false otherwise

◆ size()

size_t qb::CoreIdBitSet::size ( ) const
inlinenodiscardnoexcept

Get the number of core IDs in the set.

Returns
Count of core IDs

◆ to_vector()

std::vector< CoreId > qb::CoreIdBitSet::to_vector ( ) const
inlinenodiscard

Convert the set to a vector of core IDs.

Returns
Vector containing all core IDs in the set

◆ to_unordered_set()

qb::unordered_set< CoreId > qb::CoreIdBitSet::to_unordered_set ( ) const
inlinenodiscard

Get an unordered_set of the core IDs.

Returns
Unordered set containing all core IDs

◆ raw()

qb::unordered_set< CoreId > qb::CoreIdBitSet::raw ( ) const
inlinenodiscard

Get a reference to the raw set for internal use.

Returns
Reference to the unordered_set for internal use

◆ begin()

iterator qb::CoreIdBitSet::begin ( ) const
inlinenodiscard

Get an iterator to the beginning of the set.

Returns
Iterator to the first core ID

◆ end()

iterator qb::CoreIdBitSet::end ( ) const
inlinenodiscard

Get an iterator to the end of the set.

Returns
Iterator representing the end of the set