mCRL2
Loading...
Searching...
No Matches
atermpp::indexed_set< Key, ThreadSafe, Hash, Equals, Allocator, KeyTable > Class Template Reference

A set that assigns each element an unique index, and protects its internal terms en masse. More...

#include <indexed_set.h>

Public Types

using key_type = typename super::key_type
 
using size_type = typename super::size_type
 
using value_type = typename super::value_type
 
using hasher = typename super::hasher
 
using key_equal = typename super::key_equal
 
using iterator = typename super::iterator
 
using const_iterator = typename super::const_iterator
 
using reverse_iterator = typename super::reverse_iterator
 
using const_reverse_iterator = typename super::const_reverse_iterator
 

Public Member Functions

 indexed_set ()=default
 Constructor of an empty indexed set. Starts with a hashtable of size 128.
 
 indexed_set (std::size_t number_of_threads)
 Constructor of an empty indexed set. Starts with a hashtable of size 128.
 
 indexed_set (std::size_t number_of_threads, std::size_t initial_hashtable_size, const typename super::hasher &hash=typename super::hasher(), const typename super::key_equal &equals=typename super::key_equal())
 Constructor of an empty index set. Starts with a hashtable of the indicated size.
 
void clear (std::size_t thread_index=0)
 Clears the indexed set.
 
std::pair< size_type, bool > insert (const Key &key, std::size_t thread_index=0)
 Insert a key in the indexed set and return its index.
 
size_type index (const key_type &key, std::size_t thread_index=0) const
 
bool contains (const key_type &key, std::size_t thread_index=0) const
 
const_iterator find (const key_type &key, std::size_t thread_index=0) const
 
const key_type & at (size_type index) const
 
const key_type & operator[] (size_type index) const
 
size_type size (std::size_t thread_index=0) const
 
iterator begin (std::size_t thread_index=0)
 
iterator end (std::size_t thread_index=0)
 
const_iterator begin (std::size_t thread_index=0) const
 
const_iterator end (std::size_t thread_index=0) const
 
const_iterator cbegin (std::size_t thread_index=0) const
 
const_iterator cend (std::size_t thread_index=0) const
 
reverse_iterator rbegin (std::size_t thread_index=0)
 
reverse_iterator rend (std::size_t thread_index=0)
 
const_reverse_iterator crbegin (std::size_t thread_index=0) const
 
const_reverse_iterator crend (std::size_t thread_index=0) const
 

Static Public Attributes

static constexpr size_type npos = super::npos
 Value returned when an element does not exist in the set.
 

Protected Types

using super = mcrl2::utilities::indexed_set< Key, ThreadSafe, Hash, Equals, Allocator, KeyTable >
 

Protected Attributes

super m_set
 

Detailed Description

template<typename Key, bool ThreadSafe = false, typename Hash = std::hash<Key>, typename Equals = std::equal_to<Key>, typename Allocator = std::allocator<Key>, typename KeyTable = atermpp::deque<Key >>
class atermpp::indexed_set< Key, ThreadSafe, Hash, Equals, Allocator, KeyTable >

A set that assigns each element an unique index, and protects its internal terms en masse.

The API of a mcrl2::utilities::indexed_set is exposed by explicit forwarding (composition) instead of inheritance, such that every operation that touches aterms is guaranteed to acquire the shared lock that keeps the garbage collector out of the underlying key table while it is being accessed.

Definition at line 33 of file indexed_set.h.

Member Typedef Documentation

◆ const_iterator

template<typename Key , bool ThreadSafe = false, typename Hash = std::hash<Key>, typename Equals = std::equal_to<Key>, typename Allocator = std::allocator<Key>, typename KeyTable = atermpp::deque<Key >>
using atermpp::indexed_set< Key, ThreadSafe, Hash, Equals, Allocator, KeyTable >::const_iterator = typename super::const_iterator

Definition at line 47 of file indexed_set.h.

◆ const_reverse_iterator

template<typename Key , bool ThreadSafe = false, typename Hash = std::hash<Key>, typename Equals = std::equal_to<Key>, typename Allocator = std::allocator<Key>, typename KeyTable = atermpp::deque<Key >>
using atermpp::indexed_set< Key, ThreadSafe, Hash, Equals, Allocator, KeyTable >::const_reverse_iterator = typename super::const_reverse_iterator

Definition at line 49 of file indexed_set.h.

◆ hasher

template<typename Key , bool ThreadSafe = false, typename Hash = std::hash<Key>, typename Equals = std::equal_to<Key>, typename Allocator = std::allocator<Key>, typename KeyTable = atermpp::deque<Key >>
using atermpp::indexed_set< Key, ThreadSafe, Hash, Equals, Allocator, KeyTable >::hasher = typename super::hasher

Definition at line 44 of file indexed_set.h.

◆ iterator

template<typename Key , bool ThreadSafe = false, typename Hash = std::hash<Key>, typename Equals = std::equal_to<Key>, typename Allocator = std::allocator<Key>, typename KeyTable = atermpp::deque<Key >>
using atermpp::indexed_set< Key, ThreadSafe, Hash, Equals, Allocator, KeyTable >::iterator = typename super::iterator

Definition at line 46 of file indexed_set.h.

◆ key_equal

template<typename Key , bool ThreadSafe = false, typename Hash = std::hash<Key>, typename Equals = std::equal_to<Key>, typename Allocator = std::allocator<Key>, typename KeyTable = atermpp::deque<Key >>
using atermpp::indexed_set< Key, ThreadSafe, Hash, Equals, Allocator, KeyTable >::key_equal = typename super::key_equal

Definition at line 45 of file indexed_set.h.

◆ key_type

template<typename Key , bool ThreadSafe = false, typename Hash = std::hash<Key>, typename Equals = std::equal_to<Key>, typename Allocator = std::allocator<Key>, typename KeyTable = atermpp::deque<Key >>
using atermpp::indexed_set< Key, ThreadSafe, Hash, Equals, Allocator, KeyTable >::key_type = typename super::key_type

Definition at line 41 of file indexed_set.h.

◆ reverse_iterator

template<typename Key , bool ThreadSafe = false, typename Hash = std::hash<Key>, typename Equals = std::equal_to<Key>, typename Allocator = std::allocator<Key>, typename KeyTable = atermpp::deque<Key >>
using atermpp::indexed_set< Key, ThreadSafe, Hash, Equals, Allocator, KeyTable >::reverse_iterator = typename super::reverse_iterator

Definition at line 48 of file indexed_set.h.

◆ size_type

template<typename Key , bool ThreadSafe = false, typename Hash = std::hash<Key>, typename Equals = std::equal_to<Key>, typename Allocator = std::allocator<Key>, typename KeyTable = atermpp::deque<Key >>
using atermpp::indexed_set< Key, ThreadSafe, Hash, Equals, Allocator, KeyTable >::size_type = typename super::size_type

Definition at line 42 of file indexed_set.h.

◆ super

template<typename Key , bool ThreadSafe = false, typename Hash = std::hash<Key>, typename Equals = std::equal_to<Key>, typename Allocator = std::allocator<Key>, typename KeyTable = atermpp::deque<Key >>
using atermpp::indexed_set< Key, ThreadSafe, Hash, Equals, Allocator, KeyTable >::super = mcrl2::utilities::indexed_set<Key, ThreadSafe, Hash, Equals, Allocator, KeyTable>
protected

Definition at line 36 of file indexed_set.h.

◆ value_type

template<typename Key , bool ThreadSafe = false, typename Hash = std::hash<Key>, typename Equals = std::equal_to<Key>, typename Allocator = std::allocator<Key>, typename KeyTable = atermpp::deque<Key >>
using atermpp::indexed_set< Key, ThreadSafe, Hash, Equals, Allocator, KeyTable >::value_type = typename super::value_type

Definition at line 43 of file indexed_set.h.

Constructor & Destructor Documentation

◆ indexed_set() [1/3]

template<typename Key , bool ThreadSafe = false, typename Hash = std::hash<Key>, typename Equals = std::equal_to<Key>, typename Allocator = std::allocator<Key>, typename KeyTable = atermpp::deque<Key >>
atermpp::indexed_set< Key, ThreadSafe, Hash, Equals, Allocator, KeyTable >::indexed_set ( )
default

Constructor of an empty indexed set. Starts with a hashtable of size 128.

◆ indexed_set() [2/3]

template<typename Key , bool ThreadSafe = false, typename Hash = std::hash<Key>, typename Equals = std::equal_to<Key>, typename Allocator = std::allocator<Key>, typename KeyTable = atermpp::deque<Key >>
atermpp::indexed_set< Key, ThreadSafe, Hash, Equals, Allocator, KeyTable >::indexed_set ( std::size_t  number_of_threads)
inline

Constructor of an empty indexed set. Starts with a hashtable of size 128.

Definition at line 58 of file indexed_set.h.

◆ indexed_set() [3/3]

template<typename Key , bool ThreadSafe = false, typename Hash = std::hash<Key>, typename Equals = std::equal_to<Key>, typename Allocator = std::allocator<Key>, typename KeyTable = atermpp::deque<Key >>
atermpp::indexed_set< Key, ThreadSafe, Hash, Equals, Allocator, KeyTable >::indexed_set ( std::size_t  number_of_threads,
std::size_t  initial_hashtable_size,
const typename super::hasher &  hash = typename super::hasher(),
const typename super::key_equal &  equals = typename super::key_equal() 
)
inline

Constructor of an empty index set. Starts with a hashtable of the indicated size.

Parameters
initial_hashtable_sizeThe initial size of the hashtable.
hashThe hash function.
equalsThe comparison function for its elements.

Definition at line 66 of file indexed_set.h.

Member Function Documentation

◆ at()

template<typename Key , bool ThreadSafe = false, typename Hash = std::hash<Key>, typename Equals = std::equal_to<Key>, typename Allocator = std::allocator<Key>, typename KeyTable = atermpp::deque<Key >>
const key_type & atermpp::indexed_set< Key, ThreadSafe, Hash, Equals, Allocator, KeyTable >::at ( size_type  index) const
inline
Returns
The key at the given index; throws std::out_of_range when absent.

Definition at line 112 of file indexed_set.h.

◆ begin() [1/2]

template<typename Key , bool ThreadSafe = false, typename Hash = std::hash<Key>, typename Equals = std::equal_to<Key>, typename Allocator = std::allocator<Key>, typename KeyTable = atermpp::deque<Key >>
iterator atermpp::indexed_set< Key, ThreadSafe, Hash, Equals, Allocator, KeyTable >::begin ( std::size_t  thread_index = 0)
inline

Definition at line 131 of file indexed_set.h.

◆ begin() [2/2]

template<typename Key , bool ThreadSafe = false, typename Hash = std::hash<Key>, typename Equals = std::equal_to<Key>, typename Allocator = std::allocator<Key>, typename KeyTable = atermpp::deque<Key >>
const_iterator atermpp::indexed_set< Key, ThreadSafe, Hash, Equals, Allocator, KeyTable >::begin ( std::size_t  thread_index = 0) const
inline

Definition at line 134 of file indexed_set.h.

◆ cbegin()

template<typename Key , bool ThreadSafe = false, typename Hash = std::hash<Key>, typename Equals = std::equal_to<Key>, typename Allocator = std::allocator<Key>, typename KeyTable = atermpp::deque<Key >>
const_iterator atermpp::indexed_set< Key, ThreadSafe, Hash, Equals, Allocator, KeyTable >::cbegin ( std::size_t  thread_index = 0) const
inline

Definition at line 137 of file indexed_set.h.

◆ cend()

template<typename Key , bool ThreadSafe = false, typename Hash = std::hash<Key>, typename Equals = std::equal_to<Key>, typename Allocator = std::allocator<Key>, typename KeyTable = atermpp::deque<Key >>
const_iterator atermpp::indexed_set< Key, ThreadSafe, Hash, Equals, Allocator, KeyTable >::cend ( std::size_t  thread_index = 0) const
inline

Definition at line 138 of file indexed_set.h.

◆ clear()

template<typename Key , bool ThreadSafe = false, typename Hash = std::hash<Key>, typename Equals = std::equal_to<Key>, typename Allocator = std::allocator<Key>, typename KeyTable = atermpp::deque<Key >>
void atermpp::indexed_set< Key, ThreadSafe, Hash, Equals, Allocator, KeyTable >::clear ( std::size_t  thread_index = 0)
inline

Clears the indexed set.

Definition at line 74 of file indexed_set.h.

◆ contains()

template<typename Key , bool ThreadSafe = false, typename Hash = std::hash<Key>, typename Equals = std::equal_to<Key>, typename Allocator = std::allocator<Key>, typename KeyTable = atermpp::deque<Key >>
bool atermpp::indexed_set< Key, ThreadSafe, Hash, Equals, Allocator, KeyTable >::contains ( const key_type &  key,
std::size_t  thread_index = 0 
) const
inline
Returns
Whether the given key is present.

Performs the lookup under a single guard such that a concurrent insert cannot invalidate the answer halfway through the check.

Definition at line 98 of file indexed_set.h.

◆ crbegin()

template<typename Key , bool ThreadSafe = false, typename Hash = std::hash<Key>, typename Equals = std::equal_to<Key>, typename Allocator = std::allocator<Key>, typename KeyTable = atermpp::deque<Key >>
const_reverse_iterator atermpp::indexed_set< Key, ThreadSafe, Hash, Equals, Allocator, KeyTable >::crbegin ( std::size_t  thread_index = 0) const
inline

Definition at line 143 of file indexed_set.h.

◆ crend()

template<typename Key , bool ThreadSafe = false, typename Hash = std::hash<Key>, typename Equals = std::equal_to<Key>, typename Allocator = std::allocator<Key>, typename KeyTable = atermpp::deque<Key >>
const_reverse_iterator atermpp::indexed_set< Key, ThreadSafe, Hash, Equals, Allocator, KeyTable >::crend ( std::size_t  thread_index = 0) const
inline

Definition at line 144 of file indexed_set.h.

◆ end() [1/2]

template<typename Key , bool ThreadSafe = false, typename Hash = std::hash<Key>, typename Equals = std::equal_to<Key>, typename Allocator = std::allocator<Key>, typename KeyTable = atermpp::deque<Key >>
iterator atermpp::indexed_set< Key, ThreadSafe, Hash, Equals, Allocator, KeyTable >::end ( std::size_t  thread_index = 0)
inline

Definition at line 132 of file indexed_set.h.

◆ end() [2/2]

template<typename Key , bool ThreadSafe = false, typename Hash = std::hash<Key>, typename Equals = std::equal_to<Key>, typename Allocator = std::allocator<Key>, typename KeyTable = atermpp::deque<Key >>
const_iterator atermpp::indexed_set< Key, ThreadSafe, Hash, Equals, Allocator, KeyTable >::end ( std::size_t  thread_index = 0) const
inline

Definition at line 135 of file indexed_set.h.

◆ find()

template<typename Key , bool ThreadSafe = false, typename Hash = std::hash<Key>, typename Equals = std::equal_to<Key>, typename Allocator = std::allocator<Key>, typename KeyTable = atermpp::deque<Key >>
const_iterator atermpp::indexed_set< Key, ThreadSafe, Hash, Equals, Allocator, KeyTable >::find ( const key_type &  key,
std::size_t  thread_index = 0 
) const
inline
Returns
An iterator to the given key, or end() when the key is not present.

Definition at line 105 of file indexed_set.h.

◆ index()

template<typename Key , bool ThreadSafe = false, typename Hash = std::hash<Key>, typename Equals = std::equal_to<Key>, typename Allocator = std::allocator<Key>, typename KeyTable = atermpp::deque<Key >>
size_type atermpp::indexed_set< Key, ThreadSafe, Hash, Equals, Allocator, KeyTable >::index ( const key_type &  key,
std::size_t  thread_index = 0 
) const
inline
Returns
The index of the given key, or npos when the key is not present.

Definition at line 89 of file indexed_set.h.

◆ insert()

template<typename Key , bool ThreadSafe = false, typename Hash = std::hash<Key>, typename Equals = std::equal_to<Key>, typename Allocator = std::allocator<Key>, typename KeyTable = atermpp::deque<Key >>
std::pair< size_type, bool > atermpp::indexed_set< Key, ThreadSafe, Hash, Equals, Allocator, KeyTable >::insert ( const Key &  key,
std::size_t  thread_index = 0 
)
inline

Insert a key in the indexed set and return its index.

Returns
The index of the key and whether the element was newly inserted.

Definition at line 82 of file indexed_set.h.

◆ operator[]()

template<typename Key , bool ThreadSafe = false, typename Hash = std::hash<Key>, typename Equals = std::equal_to<Key>, typename Allocator = std::allocator<Key>, typename KeyTable = atermpp::deque<Key >>
const key_type & atermpp::indexed_set< Key, ThreadSafe, Hash, Equals, Allocator, KeyTable >::operator[] ( size_type  index) const
inline
Returns
The key at the given index.

Definition at line 119 of file indexed_set.h.

◆ rbegin()

template<typename Key , bool ThreadSafe = false, typename Hash = std::hash<Key>, typename Equals = std::equal_to<Key>, typename Allocator = std::allocator<Key>, typename KeyTable = atermpp::deque<Key >>
reverse_iterator atermpp::indexed_set< Key, ThreadSafe, Hash, Equals, Allocator, KeyTable >::rbegin ( std::size_t  thread_index = 0)
inline

Definition at line 140 of file indexed_set.h.

◆ rend()

template<typename Key , bool ThreadSafe = false, typename Hash = std::hash<Key>, typename Equals = std::equal_to<Key>, typename Allocator = std::allocator<Key>, typename KeyTable = atermpp::deque<Key >>
reverse_iterator atermpp::indexed_set< Key, ThreadSafe, Hash, Equals, Allocator, KeyTable >::rend ( std::size_t  thread_index = 0)
inline

Definition at line 141 of file indexed_set.h.

◆ size()

template<typename Key , bool ThreadSafe = false, typename Hash = std::hash<Key>, typename Equals = std::equal_to<Key>, typename Allocator = std::allocator<Key>, typename KeyTable = atermpp::deque<Key >>
size_type atermpp::indexed_set< Key, ThreadSafe, Hash, Equals, Allocator, KeyTable >::size ( std::size_t  thread_index = 0) const
inline
Returns
The number of elements in the indexed set.

Definition at line 126 of file indexed_set.h.

Member Data Documentation

◆ m_set

template<typename Key , bool ThreadSafe = false, typename Hash = std::hash<Key>, typename Equals = std::equal_to<Key>, typename Allocator = std::allocator<Key>, typename KeyTable = atermpp::deque<Key >>
super atermpp::indexed_set< Key, ThreadSafe, Hash, Equals, Allocator, KeyTable >::m_set
protected

Definition at line 38 of file indexed_set.h.

◆ npos

template<typename Key , bool ThreadSafe = false, typename Hash = std::hash<Key>, typename Equals = std::equal_to<Key>, typename Allocator = std::allocator<Key>, typename KeyTable = atermpp::deque<Key >>
constexpr size_type atermpp::indexed_set< Key, ThreadSafe, Hash, Equals, Allocator, KeyTable >::npos = super::npos
staticconstexpr

Value returned when an element does not exist in the set.

Definition at line 52 of file indexed_set.h.


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