Storm
A Modern Probabilistic Model Checker
All Classes Namespaces Files Functions Variables Typedefs Enumerations Enumerator Friends Macros Pages
BitVectorHashMap.h
Go to the documentation of this file.
1#ifndef STORM_STORAGE_BITVECTORHASHMAP_H_
2#define STORM_STORAGE_BITVECTORHASHMAP_H_
3
4#include <cstdint>
5#include <functional>
6
8
9namespace storm {
10namespace storage {
11
17// template<typename ValueType, typename Hash = std::hash<storm::storage::BitVector>>
18// template<typename ValueType, typename Hash = FNV1aBitVectorHash>
19template<typename ValueType, typename Hash = Murmur3BitVectorHash<ValueType>>
21 public:
23 public:
30
31 // Methods to compare two iterators.
32 bool operator==(BitVectorHashMapIterator const& other);
33 bool operator!=(BitVectorHashMapIterator const& other);
34
35 // Methods to move iterator forward.
38
39 // Method to retrieve the currently pointed-to bit vector and its mapped-to value.
40 std::pair<storm::storage::BitVector, ValueType> operator*() const;
41
42 private:
43 // The map this iterator refers to.
44 BitVectorHashMap const& map;
45
46 // An iterator to the bucket this iterator points to.
48 };
49
51
60 BitVectorHashMap(uint64_t bucketSize, uint64_t initialSize = 1000, double loadFactor = 0.75);
61
66
75 ValueType findOrAdd(storm::storage::BitVector const& key, ValueType const& value);
76
87 std::pair<ValueType, uint64_t> findOrAddAndGetBucket(storm::storage::BitVector const& key, ValueType const& value);
88
95 std::pair<storm::storage::BitVector, ValueType> getBucketAndValue(uint64_t bucket) const;
96
103 ValueType getValue(storm::storage::BitVector const& key) const;
104
110 ValueType getValue(uint64_t bucket) const;
111
118 bool contains(storm::storage::BitVector const& key) const;
119
125 const_iterator begin() const;
126
132 const_iterator end() const;
133
139 uint64_t size() const;
140
146 uint64_t capacity() const;
147
153 void remap(std::function<ValueType(ValueType const&)> const& remapping);
154
155 private:
162 bool isBucketOccupied(uint_fast64_t bucket) const;
163
171 std::pair<bool, uint64_t> findBucket(storm::storage::BitVector const& key) const;
172
181 bool insertWithoutIncreasingSize(storm::storage::BitVector const& key, ValueType const& value);
182
186 void increaseSize();
187
193 bool checkIncreaseSize();
194
198 uint64_t getCurrentShiftWidth() const;
199
200 // The load factor determining when the size of the map is increased.
201 double loadFactor;
202
203 // The size of one bucket.
204 uint64_t bucketSize;
205
206 // The number of buckets is 2^currentSize.
207 uint64_t currentSize;
208
209 // The buckets that hold the elements of the map.
211
212 // A bit vector that stores which buckets actually hold a value.
214
215 // A vector of the mapped-to values. The entry at position i is the "target" of the key in bucket i.
216 std::vector<ValueType> values;
217
218 // The number of elements in this map.
219 uint64_t numberOfElements;
220
221 // Functor object that are used to perform the actual hashing.
222 Hash hasher;
223};
224
225} // namespace storage
226} // namespace storm
227
228#endif /* STORM_STORAGE_BITVECTORHASHMAP_H_ */
A class that enables iterating over the indices of the bit vector whose corresponding bits are set to...
Definition BitVector.h:25
bool operator==(BitVectorHashMapIterator const &other)
std::pair< storm::storage::BitVector, ValueType > operator*() const
bool operator!=(BitVectorHashMapIterator const &other)
This class represents a hash-map whose keys are bit vectors.
BitVectorHashMap(BitVectorHashMap &&)=default
BitVectorHashMap(BitVectorHashMap const &)=default
std::pair< ValueType, uint64_t > findOrAddAndGetBucket(storm::storage::BitVector const &key, ValueType const &value)
Searches for the given key in the map.
ValueType findOrAdd(storm::storage::BitVector const &key, ValueType const &value)
Searches for the given key in the map.
std::pair< storm::storage::BitVector, ValueType > getBucketAndValue(uint64_t bucket) const
Retrieves the key stored in the given bucket (if any) and the value it is mapped to.
BitVectorHashMap & operator=(BitVectorHashMap &&)=default
ValueType getValue(storm::storage::BitVector const &key) const
Retrieves the value associated with the given key (if any).
const_iterator begin() const
Retrieves an iterator to the elements of the map.
uint64_t capacity() const
Retrieves the capacity of the underlying container.
BitVectorHashMapIterator const_iterator
const_iterator end() const
Retrieves an iterator that points one past the elements of the map.
bool contains(storm::storage::BitVector const &key) const
Checks if the given key is already contained in the map.
void remap(std::function< ValueType(ValueType const &)> const &remapping)
Performs a remapping of all values stored by applying the given remapping.
BitVectorHashMap & operator=(BitVectorHashMap const &)=default
uint64_t size() const
Retrieves the size of the map in terms of the number of key-value pairs it stores.
A bit vector that is internally represented as a vector of 64-bit values.
Definition BitVector.h:18
LabParser.cpp.
Definition cli.cpp:18