mCRL2
Loading...
Searching...
No Matches
indexed_set.h
Go to the documentation of this file.
1// Author(s): Jan Friso Groote
2// Copyright: see the accompanying file COPYING or copy at
3// https://github.com/mCRL2org/mCRL2/blob/master/COPYING
4//
5// Distributed under the Boost Software License, Version 1.0.
6// (See accompanying file LICENSE_1_0.txt or copy at
7// http://www.boost.org/LICENSE_1_0.txt)
8
9#ifndef MCRL2_ATERMPP_INDEXED_SET_H
10#define MCRL2_ATERMPP_INDEXED_SET_H
11
17
18
19namespace atermpp
20{
21
23template<typename Key,
24 bool ThreadSafe = false,
25 typename Hash = std::hash<Key>,
26 typename Equals = std::equal_to<Key>,
27 typename Allocator = std::allocator<Key>,
28 typename KeyTable = atermpp::deque<Key > >
29class indexed_set: public mcrl2::utilities::indexed_set<Key, ThreadSafe, Hash, Equals, Allocator, KeyTable>
30{
32
33public:
34 typedef typename super::size_type size_type;
35
38 {}
39
41 indexed_set(std::size_t number_of_threads)
42 : super(number_of_threads)
43 {}
44
49
50 indexed_set(std::size_t number_of_threads,
51 std::size_t initial_hashtable_size,
52 const typename super::hasher& hash = typename super::hasher(),
53 const typename super::key_equal& equals = typename super::key_equal())
54 : super(number_of_threads, initial_hashtable_size, hash, equals)
55 {}
56
57 void clear(std::size_t thread_index=0)
58 {
60 super::clear(thread_index);
61 }
62
63 std::pair<size_type, bool> insert(const Key& key, std::size_t thread_index=0)
64 {
66 return super::insert(key, thread_index);
67 }
68};
69
70} // end namespace atermppp
71
72namespace mcrl2 {
73
74namespace utilities {
75
76namespace detail {
77
78// Specialization of a function defined in mcrl2/utilities/detail/container_utility.h.
79// In utilities, atermpp is not known.
80template<typename Key,
81 bool ThreadSafe = false,
82 typename Hash = std::hash<Key>,
83 typename Equals = std::equal_to<Key>,
84 typename Allocator = std::allocator<Key>,
85 typename KeyTable = atermpp::deque<Key > >
88 const std::size_t thread_index=0)
89{
90 return c.find(v, thread_index) != c.end(thread_index);
91}
92
93} // namespace detail
94
95} // namespace utilities
96
97} // namespace mcrl2
98
99
100
101#endif // MCRL2_ATERMPP_INDEXED_SET_H
A deque class in which aterms can be stored.
Definition deque.h:34
mcrl2::utilities::shared_guard lock_shared()
Acquire a shared lock on this thread aterm pool.
A set that assigns each element an unique index, and protects its internal terms en masse.
Definition indexed_set.h:30
super::size_type size_type
Definition indexed_set.h:34
mcrl2::utilities::indexed_set< Key, ThreadSafe, Hash, Equals, Allocator, KeyTable > super
Definition indexed_set.h:31
indexed_set()
Constructor of an empty indexed set. Starts with a hashtable of size 128.
Definition indexed_set.h:37
indexed_set(std::size_t number_of_threads)
Constructor of an empty indexed set. Starts with a hashtable of size 128.
Definition indexed_set.h:41
std::pair< size_type, bool > insert(const Key &key, std::size_t thread_index=0)
Definition indexed_set.h:63
void clear(std::size_t thread_index=0)
Definition indexed_set.h:57
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.
Definition indexed_set.h:50
A set that assigns each element an unique index.
Definition indexed_set.h:33
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.
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...
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.
A shared lock guard for the shared_mutex.
thread_aterm_pool & g_thread_term_pool()
A reference to the thread local term pool storage.
The main namespace for the aterm++ library.
Definition algorithm.h:21
bool contains(const atermpp::indexed_set< Key, ThreadSafe, Hash, Equals, Allocator, KeyTable > &c, const typename atermpp::indexed_set< Key, ThreadSafe, Hash, Equals, Allocator, KeyTable >::key_type &v, const std::size_t thread_index=0)
Definition indexed_set.h:86
A class that takes a linear process specification and checks all tau-summands of that LPS for conflue...
Definition indexed_set.h:72
#define hash(l, r, m)
Definition tree_set.cpp:23