Public Member Functions | Private Attributes | List of all members
cras::SmallSet< K > Class Template Reference

Simple set implemented on top of a std::list. The set is append-only, with lock-free reads and mutex-protected insert. More...

#include <small_map.hpp>

Public Member Functions

bool contains (const K &key) const
 Check whether the given key is stored in this set. More...
 
bool empty () const
 Return whether this map is empty. More...
 
bool insert (const K &key)
 Search this set for the key. If it is not found, store the key. More...
 
size_t size () const
 Return the number of elements of this map. More...
 

Private Attributes

::std::list< K > data
 
::std::mutex mutex
 

Detailed Description

template<typename K>
class cras::SmallSet< K >

Simple set implemented on top of a std::list. The set is append-only, with lock-free reads and mutex-protected insert.

This set is suitable for storing a small number of elements, as it uses non-sorted linear lookup of the values. However, if this condition is met, the set is reasonably fast and efficient.

Template Parameters
KType of the map keys.

Definition at line 129 of file small_map.hpp.

Member Function Documentation

◆ contains()

template<typename K >
bool cras::SmallSet< K >::contains ( const K &  key) const
inline

Check whether the given key is stored in this set.

Parameters
keyThe key to find.
Returns
Whether the key is stored in this set.

Definition at line 137 of file small_map.hpp.

◆ empty()

template<typename K >
bool cras::SmallSet< K >::empty ( ) const
inline

Return whether this map is empty.

Returns
Whether the map is empty.

Definition at line 177 of file small_map.hpp.

◆ insert()

template<typename K >
bool cras::SmallSet< K >::insert ( const K &  key)
inline

Search this set for the key. If it is not found, store the key.

Parameters
keyThe key to find.
Returns
Whether the key was missing and was inserted.

Definition at line 147 of file small_map.hpp.

◆ size()

template<typename K >
size_t cras::SmallSet< K >::size ( ) const
inline

Return the number of elements of this map.

Returns
The number of elements.

Definition at line 168 of file small_map.hpp.

Member Data Documentation

◆ data

template<typename K >
::std::list<K> cras::SmallSet< K >::data
private

Definition at line 183 of file small_map.hpp.

◆ mutex

template<typename K >
::std::mutex cras::SmallSet< K >::mutex
private

Definition at line 184 of file small_map.hpp.


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


cras_cpp_common
Author(s): Martin Pecka
autogenerated on Tue Nov 26 2024 03:49:04