9#ifndef MCRL2_UTILITIES_INDEXED_SET_H
10#define MCRL2_UTILITIES_INDEXED_SET_H
27 bool ThreadSafe =
false,
28 typename Hash = std::hash<Key>,
29 typename Equals = std::equal_to<Key>,
30 typename Allocator = std::allocator<Key>,
31 typename KeyTable = std::deque< Key, Allocator > >
39 mutable std::shared_ptr<std::mutex>
m_mutex;
57 std::size_t
put_in_hashtable(
const Key& key, std::size_t value, std::size_t& new_position);
84 static constexpr size_type npos = std::numeric_limits<std::size_t>::max();
109 std::size_t number_of_threads,
110 std::size_t initial_hashtable_size,
213 void clear(std::size_t thread_index=0);
221 std::pair<size_type, bool>
insert(
const key_type& key, std::size_t thread_index = 0);
A set that assigns each element an unique index.
void resize_hashtable()
Resizes the hash table to twice its current size.
const key_type & operator[](const size_type index) const
Operator that provides a const reference at the position indicated by index.
std::vector< shared_mutex > m_shared_mutexes
indexed_set()
Constructor of an empty indexed set. Starts with a hashtable of size 128 and assumes one single threa...
std::vector< detail::atomic_wrapper< std::size_t > > m_hashtable
iterator end(std::size_t thread_index=0)
End of the forward iterator.
std::pair< size_type, bool > insert(const key_type &key, std::size_t thread_index=0)
Insert a key in the indexed set and return its index.
detail::atomic_wrapper< size_t > m_next_index
m_next_index indicates the next index that
reverse_iterator rbegin(std::size_t thread_index=0)
Reverse iterator going through the elements in the set from the largest to the smallest index.
const_reverse_iterator crbegin(std::size_t thread_index=0) const
Reverse const_iterator going through the elements from the highest to the lowest numbered element.
const_reverse_iterator crend(std::size_t thread_index=0) const
End of the reverse const_iterator.
const_iterator begin(std::size_t thread_index=0) const
Forward iterator which runs through the elements from the lowest to the largest number.
std::shared_ptr< std::mutex > m_mutex
Mutex for the m_hashtable and m_keys data structures.
void clear(std::size_t thread_index=0)
Clears the indexed set by removing all its elements. It is not guaranteed that the memory is released...
KeyTable::reverse_iterator reverse_iterator
iterator begin(std::size_t thread_index=0)
Forward iterator which runs through the elements from the lowest to the largest number.
const_iterator cbegin(std::size_t thread_index=0) const
const_iterator going through the elements in the set numbered from zero upwards.
std::pair< const key_type, size_type > value_type
const value_type & const_reference
indexed_set(std::size_t number_of_threads, std::size_t initial_hashtable_size, const hasher &hash=hasher(), const key_equal &equals=key_equal())
Constructor of an empty index set. Starts with a hashtable of the indicated size.
const_iterator find(const key_type &key, std::size_t thread_index=0) const
Provides an iterator to the stored key in the indexed set.
size_type index(const key_type &key, std::size_t thread_index=0) const
Returns a reference to the mapped value.
KeyTable::const_iterator const_iterator
reverse_iterator rend(std::size_t thread_index=0)
End of the reverse iterator.
void reserve_indices(std::size_t thread_index)
Reserve indices that can be used. Doing this infrequently prevents obtaining an exclusive lock for th...
const_iterator end(std::size_t thread_index=0) const
End of the forward iterator.
std::size_t put_in_hashtable(const Key &key, std::size_t value, std::size_t &new_position)
Inserts the given (key, n) pair into the indexed set.
size_type size(std::size_t thread_index=0) const
The number of elements in the indexed set.
indexed_set(std::size_t number_of_threads)
Constructor of an empty indexed set.
KeyTable::iterator iterator
static constexpr size_type npos
Value returned when an element does not exist in the set.
const key_type & at(const size_type index) const
Returns a reference to the mapped value.
const value_type * const_pointer
KeyTable::const_reverse_iterator const_reverse_iterator
const_iterator cend(std::size_t thread_index=0) const
End of the forward const_iterator.
std::ptrdiff_t difference_type
A shared lock guard for the shared_mutex.
A class that takes a linear process specification and checks all tau-summands of that LPS for conflue...
add your file description here.