1#ifndef STORM_STORAGE_BITVECTOR_H_
2#define STORM_STORAGE_BITVECTOR_H_
49 const_iterator(uint64_t
const* dataPtr, uint_fast64_t startIndex, uint_fast64_t endIndex,
bool setOnFirstBit =
true);
112 uint64_t
const* dataPtr;
115 uint_fast64_t currentIndex;
118 uint_fast64_t endIndex;
148 const_reverse_iterator(uint64_t
const* dataPtr, uint64_t upperBound, uint64_t lowerBound = 0ull,
bool setOnFirstBit =
true);
194 uint64_t
const* dataPtr;
197 uint64_t currentIndex;
220 explicit BitVector(uint_fast64_t length,
bool init =
false);
230 template<
typename InputIterator>
231 BitVector(uint_fast64_t length, InputIterator first, InputIterator last);
236 BitVector(uint_fast64_t length, std::vector<uint_fast64_t> setEntries);
300 void set(uint_fast64_t index,
bool value =
true);
308 template<
typename InputIterator>
309 void set(InputIterator first, InputIterator last,
bool value =
true);
327 bool get(uint_fast64_t index)
const;
336 void resize(uint_fast64_t newLength,
bool init =
false);
360 void grow(uint_fast64_t minimumLength,
bool init =
false);
491 void set(uint_fast64_t bitIndex,
BitVector const& other);
496 void setMultiple(uint64_t bitIndex, uint64_t nrOfBits,
bool newValue =
true);
531 uint_fast64_t
getAsInt(uint_fast64_t bitIndex, uint_fast64_t numberOfBits)
const;
547 void setFromInt(uint_fast64_t bitIndex, uint_fast64_t numberOfBits, uint64_t value);
697 bool compareAndSwap(uint_fast64_t start1, uint_fast64_t start2, uint_fast64_t length);
701 void store(std::ostream&)
const;
707 template<typename StateType>
717 BitVector(uint_fast64_t bucketCount, uint_fast64_t bitCount);
732 template<bool Value, bool Backward = false>
733 static uint_fast64_t getNextIndexWithValue(uint64_t const* dataPtr, uint_fast64_t startingIndex, uint_fast64_t endIndex);
738 void truncateLastBucket();
747 BitVector getAsBitVector(uint_fast64_t start, uint_fast64_t length) const;
756 void setFromBitVector(uint_fast64_t start, BitVector const& other);
763 void printBits(std::ostream& out) const;
770 size_t bucketCount() const;
773 uint_fast64_t bitCount;
779 static const uint_fast64_t mod64mask = (1 << 6) - 1;
782static_assert(std::ranges::forward_range<BitVector>);
784struct FNV1aBitVectorHash {
785 std::size_t operator()(storm::storage::BitVector const& bv) const;
788template<typename StateType>
789struct Murmur3BitVectorHash {
790 StateType operator()(storm::storage::BitVector const& bv) const;
798struct hash<storm::storage::BitVector> {
799 std::size_t operator()(storm::storage::BitVector const& bv) const;
A class that enables iterating over the indices of the bit vector whose corresponding bits are set to...
uint_fast64_t operator*() const
Returns the index of the current bit to which this iterator points.
const_iterator & operator++()
Increases the position of the iterator to the position of the next bit that is set to true in the und...
bool operator==(const_iterator const &other) const
Compares the iterator with another iterator for equality.
std::ptrdiff_t difference_type
const_iterator & operator+=(size_t n)
Increases the position of the iterator to the position of the n'th next bit that is set to true in th...
const_iterator & operator=(const_iterator const &other)
Assigns the contents of the given iterator to the current one via copying the former's contents.
std::forward_iterator_tag iterator_category
bool operator!=(const_iterator const &other) const
Compares the iterator with another iterator for inequality.
uint_fast64_t & reference
A class that enables iterating over the indices of the bit vector whose corresponding bits are set to...
uint_fast64_t & reference
bool operator==(const_reverse_iterator const &other) const
Compares the iterator with another iterator for equality.
const_reverse_iterator()
Constructs a reverse iterator over the indices of the set bits in the given bit vector,...
const_reverse_iterator & operator+=(size_t n)
Lets the iterator point to the n'th previous bit with value 1.
std::forward_iterator_tag iterator_category
const_reverse_iterator & operator++()
Lets the iterator point to the previous bit with value 1.
const_reverse_iterator & operator=(const_reverse_iterator const &other)
std::ptrdiff_t difference_type
uint_fast64_t operator*() const
Returns the index of the current bit to which this iterator points.
bool operator!=(const_reverse_iterator const &other) const
Compares the iterator with another iterator for inequality.
A bit vector that is internally represented as a vector of 64-bit values.
~BitVector()
Deconstructs a bit vector by deleting the underlying storage.
void complement()
Negates all bits in the bit vector.
BitVector & operator|=(BitVector const &other)
Performs a logical "or" with the given bit vector and assigns the result to the current bit vector.
bool compareAndSwap(uint_fast64_t start1, uint_fast64_t start2, uint_fast64_t length)
Compare two intervals [start1, start1+length] and [start2, start2+length] and swap them if the second...
BitVector operator^(BitVector const &other) const
Performs a logical "xor" with the given bit vector.
void setMultiple(uint64_t bitIndex, uint64_t nrOfBits, bool newValue=true)
Sets multiple bits to the given value.
bool operator<(BitVector const &other) const
Retrieves whether the current bit vector is (in some order) smaller than the given one.
const_reverse_iterator rbegin() const
Returns a reverse iterator to the indices of the set bits in the bit vector.
void fill()
Sets all bits from the bit vector.
bool operator[](uint_fast64_t index) const
Retrieves the truth value of the bit at the given index.
bool matches(uint_fast64_t bitIndex, BitVector const &other) const
Checks whether the given bit vector matches the bits starting from the given index in the current bit...
bool isDisjointFrom(BitVector const &other) const
Checks whether none of the bits that are set in the current bit vector are also set in the given bit ...
uint_fast64_t getTwoBitsAligned(uint_fast64_t bitIndex) const
bool full() const
Retrieves whether all bits are set in this bit vector.
const_reverse_iterator rend() const
Returns a reverse iterator pointing at the element past the front of the bit vector.
BitVector()
Constructs an empty bit vector of length 0.
const_iterator end() const
Returns an iterator pointing at the element past the back of the bit vector.
uint_fast64_t getNextSetIndex(uint_fast64_t startingIndex) const
Retrieves the index of the bit that is the next bit set to true in the bit vector.
void store(std::ostream &) const
void setFromInt(uint_fast64_t bitIndex, uint_fast64_t numberOfBits, uint64_t value)
Sets the selected number of lowermost bits of the provided value at the given bit index.
BitVector operator%(BitVector const &filter) const
Computes a bit vector that contains only the values of the bits given by the filter.
BitVector operator|(BitVector const &other) const
Performs a logical "or" with the given bit vector.
bool empty() const
Retrieves whether no bits are set to true in this bit vector.
std::size_t getSizeInBytes() const
Returns (an approximation of) the size of the bit vector measured in bytes.
void clear()
Removes all set bits from the bit vector.
bool isSubsetOf(BitVector const &other) const
Checks whether all bits that are set in the current bit vector are also set in the given bit vector.
BitVector implies(BitVector const &other) const
Performs a logical "implies" with the given bit vector.
BitVector & operator=(BitVector const &other)
Assigns the contents of the given bit vector to the current bit vector via a deep copy.
BitVector operator&(BitVector const &other) const
Performs a logical "and" with the given bit vector.
void resize(uint_fast64_t newLength, bool init=false)
Resizes the bit vector to hold the given new number of bits.
BitVector permute(std::vector< uint64_t > const &inversePermutation) const
Apply a permutation of entries.
void increment()
Increments the (unsigned) number represented by this BitVector by one.
const_iterator begin() const
Returns an iterator to the indices of the set bits in the bit vector.
uint64_t getStartOfZeroSequenceBefore(uint64_t endIndex) const
Retrieves the smallest index i such that all bits in the range [i,endIndex) are 0.
friend std::ostream & operator<<(std::ostream &out, BitVector const &bitVector)
BitVector operator~() const
Performs a logical "not" on the bit vector.
bool operator!=(BitVector const &other) const
Compares the given bit vector with the current one.
void set(uint_fast64_t index, bool value=true)
Sets the given truth value at the given index.
size_t size() const
Retrieves the number of bits this bit vector can store.
uint_fast64_t getNextUnsetIndex(uint_fast64_t startingIndex) const
Retrieves the index of the bit that is the next bit set to false in the bit vector.
BitVector & operator&=(BitVector const &other)
Performs a logical "and" with the given bit vector and assigns the result to the current bit vector.
uint_fast64_t getNumberOfSetBits() const
Returns the number of bits that are set to true in this bit vector.
void grow(uint_fast64_t minimumLength, bool init=false)
Enlarges the bit vector such that it holds at least the given number of bits (but possibly more).
uint_fast64_t getAsInt(uint_fast64_t bitIndex, uint_fast64_t numberOfBits) const
Retrieves the content of the current bit vector at the given index for the given number of bits as an...
static BitVector load(std::string const &description)
std::vector< uint_fast64_t > getNumberOfSetBitsBeforeIndices() const
Retrieves a vector that holds at position i the number of bits set before index i.
void expandSize(bool init=false)
bool get(uint_fast64_t index) const
Retrieves the truth value of the bit at the given index and performs a bound check.
bool operator==(BitVector const &other) const
Compares the given bit vector with the current one.
BitVector permuteGroupedVector(std::vector< uint64_t > const &inversePermutation, std::vector< uint64_t > const &rowGroupIndices) const
Apply a permutation of entries assuming a grouped vector.
uint_fast64_t getNumberOfSetBitsBeforeIndex(uint_fast64_t index) const
Retrieves the number of bits set in this bit vector with an index strictly smaller than the given one...
uint64_t getStartOfOneSequenceBefore(uint64_t endIndex) const
Retrieves the smallest index i such that all bits in the range [i,endIndex) are 1.
void concat(BitVector const &extension)
Concatenate this bitvector with another bitvector.