Browse Source

Cosmetic changes in BitVector.

Pro: Better documentation, fewer compiler warnings.
Contra: Recompilation of 400 files.
tempestpy_adaptions
Matthias Volk 5 years ago
parent
commit
9fc473383f
  1. 5
      src/storm/storage/BitVector.cpp
  2. 178
      src/storm/storage/BitVector.h

5
src/storm/storage/BitVector.cpp

@ -1,17 +1,14 @@
#include <iostream> #include <iostream>
#include <algorithm> #include <algorithm>
#include <bitset>
#include "storm/storage/BitVector.h" #include "storm/storage/BitVector.h"
#include "storm/exceptions/InvalidArgumentException.h"
#include "storm/exceptions/OutOfRangeException.h"
#include "storm/storage/BoostTypes.h" #include "storm/storage/BoostTypes.h"
#include "storm/utility/OsDetection.h" #include "storm/utility/OsDetection.h"
#include "storm/utility/Hash.h" #include "storm/utility/Hash.h"
#include "storm/utility/macros.h" #include "storm/utility/macros.h"
#include <bitset>
#ifdef STORM_DEV #ifdef STORM_DEV
#define ASSERT_BITVECTOR #define ASSERT_BITVECTOR

178
src/storm/storage/BitVector.h

@ -10,7 +10,7 @@
namespace storm { namespace storm {
namespace storage { namespace storage {
/*! /*!
* A bit vector that is internally represented as a vector of 64-bit values. * A bit vector that is internally represented as a vector of 64-bit values.
*/ */
@ -23,7 +23,7 @@ namespace storm {
class const_iterator : public std::iterator<std::input_iterator_tag, uint_fast64_t> { class const_iterator : public std::iterator<std::input_iterator_tag, uint_fast64_t> {
// Declare the BitVector class as a friend class to access its internal storage. // Declare the BitVector class as a friend class to access its internal storage.
friend class BitVector; friend class BitVector;
public: public:
/*! /*!
* Constructs an iterator over the indices of the set bits in the given bit vector, starting and * Constructs an iterator over the indices of the set bits in the given bit vector, starting and
@ -36,21 +36,21 @@ namespace storm {
* @param endIndex The index at which to abort the iteration process. * @param endIndex The index at which to abort the iteration process.
*/ */
const_iterator(uint64_t const* dataPtr, uint_fast64_t startIndex, uint_fast64_t endIndex, bool setOnFirstBit = true); const_iterator(uint64_t const* dataPtr, uint_fast64_t startIndex, uint_fast64_t endIndex, bool setOnFirstBit = true);
/*! /*!
* Constructs an iterator by copying the given iterator. * Constructs an iterator by copying the given iterator.
* *
* @param other The iterator to copy. * @param other The iterator to copy.
*/ */
const_iterator(const_iterator const& other); const_iterator(const_iterator const& other);
/*! /*!
* Assigns the contents of the given iterator to the current one via copying the former's contents. * Assigns the contents of the given iterator to the current one via copying the former's contents.
* *
* @param other The iterator from which to copy-assign. * @param other The iterator from which to copy-assign.
*/ */
const_iterator& operator=(const_iterator const& other); const_iterator& operator=(const_iterator const& other);
/*! /*!
* Increases the position of the iterator to the position of the next bit that is set to true in the * Increases the position of the iterator to the position of the next bit that is set to true in the
* underlying bit vector. * underlying bit vector.
@ -64,14 +64,14 @@ namespace storm {
* underlying bit vector. * underlying bit vector.
*/ */
const_iterator& operator+=(size_t n); const_iterator& operator+=(size_t n);
/*! /*!
* Returns the index of the current bit to which this iterator points. * Returns the index of the current bit to which this iterator points.
* *
* @return The index of the current bit to which this iterator points. * @return The index of the current bit to which this iterator points.
*/ */
uint_fast64_t operator*() const; uint_fast64_t operator*() const;
/*! /*!
* Compares the iterator with another iterator for inequality. * Compares the iterator with another iterator for inequality.
* *
@ -79,7 +79,7 @@ namespace storm {
* @return True if the two iterators are unequal. * @return True if the two iterators are unequal.
*/ */
bool operator!=(const_iterator const& other) const; bool operator!=(const_iterator const& other) const;
/*! /*!
* Compares the iterator with another iterator for equality. * Compares the iterator with another iterator for equality.
* *
@ -87,28 +87,28 @@ namespace storm {
* @return True if the two iterators are equal. * @return True if the two iterators are equal.
*/ */
bool operator==(const_iterator const& other) const; bool operator==(const_iterator const& other) const;
private: private:
// The underlying bit vector of this iterator. // The underlying bit vector of this iterator.
uint64_t const* dataPtr; uint64_t const* dataPtr;
// The index of the bit this iterator currently points to. // The index of the bit this iterator currently points to.
uint_fast64_t currentIndex; uint_fast64_t currentIndex;
// The index of the bit that is past the end of the range of this iterator. // The index of the bit that is past the end of the range of this iterator.
uint_fast64_t endIndex; uint_fast64_t endIndex;
}; };
/*
/*!
* Constructs an empty bit vector of length 0. * Constructs an empty bit vector of length 0.
*/ */
BitVector(); BitVector();
/*
/*!
* Deconstructs a bit vector by deleting the underlying storage. * Deconstructs a bit vector by deleting the underlying storage.
*/ */
~BitVector(); ~BitVector();
/*! /*!
* Constructs a bit vector which can hold the given number of bits and initializes all bits with the * Constructs a bit vector which can hold the given number of bits and initializes all bits with the
* provided truth value. * provided truth value.
@ -117,7 +117,7 @@ namespace storm {
* @param init The initial value of the first |length| bits. * @param init The initial value of the first |length| bits.
*/ */
explicit BitVector(uint_fast64_t length, bool init = false); explicit BitVector(uint_fast64_t length, bool init = false);
/*! /*!
* Creates a bit vector that has exactly the bits set that are given by the provided input iterator range * Creates a bit vector that has exactly the bits set that are given by the provided input iterator range
* [first, last). * [first, last).
@ -128,26 +128,26 @@ namespace storm {
*/ */
template<typename InputIterator> template<typename InputIterator>
BitVector(uint_fast64_t length, InputIterator first, InputIterator last); BitVector(uint_fast64_t length, InputIterator first, InputIterator last);
/*! /*!
* Creates a bit vector that has exactly the bits set that are given by the vector * Creates a bit vector that has exactly the bits set that are given by the vector
*/ */
BitVector(uint_fast64_t length, std::vector<uint_fast64_t> setEntries); BitVector(uint_fast64_t length, std::vector<uint_fast64_t> setEntries);
/*! /*!
* Performs a deep copy of the given bit vector. * Performs a deep copy of the given bit vector.
* *
* @param other A reference to the bit vector to be copied. * @param other A reference to the bit vector to be copied.
*/ */
BitVector(BitVector const& other); BitVector(BitVector const& other);
/*! /*!
* Move constructs the bit vector from the given bit vector. * Move constructs the bit vector from the given bit vector.
* *
* @param other The bit vector from which to move-construct. * @param other The bit vector from which to move-construct.
*/ */
BitVector(BitVector&& other); BitVector(BitVector&& other);
/*! /*!
* Compares the given bit vector with the current one. * Compares the given bit vector with the current one.
* *
@ -155,7 +155,7 @@ namespace storm {
* @return True iff the other bit vector is semantically the same as the current one. * @return True iff the other bit vector is semantically the same as the current one.
*/ */
bool operator==(BitVector const& other) const; bool operator==(BitVector const& other) const;
/*! /*!
* Compares the given bit vector with the current one. * Compares the given bit vector with the current one.
* *
@ -163,7 +163,7 @@ namespace storm {
* @return True iff the other bit vector is semantically not the same as the current one. * @return True iff the other bit vector is semantically not the same as the current one.
*/ */
bool operator!=(BitVector const& other) const; bool operator!=(BitVector const& other) const;
/*! /*!
* Assigns the contents of the given bit vector to the current bit vector via a deep copy. * Assigns the contents of the given bit vector to the current bit vector via a deep copy.
* *
@ -172,7 +172,7 @@ namespace storm {
* deep copy. * deep copy.
*/ */
BitVector& operator=(BitVector const& other); BitVector& operator=(BitVector const& other);
/*! /*!
* Move assigns the given bit vector to the current bit vector. * Move assigns the given bit vector to the current bit vector.
* *
@ -181,7 +181,7 @@ namespace storm {
* into it. * into it.
*/ */
BitVector& operator=(BitVector&& other); BitVector& operator=(BitVector&& other);
/*! /*!
* Retrieves whether the current bit vector is (in some order) smaller than the given one. * Retrieves whether the current bit vector is (in some order) smaller than the given one.
* *
@ -189,15 +189,15 @@ namespace storm {
* @return True iff the current bit vector is smaller than the given one. * @return True iff the current bit vector is smaller than the given one.
*/ */
bool operator<(BitVector const& other) const; bool operator<(BitVector const& other) const;
/*! /*!
* Sets the given truth value at the given index. * Sets the given truth value at the given index.
* *
* @param index The index where to set the truth value. * @param index The index where to set the truth value.
* @param value The truth value to set. * @param value The truth value to set.
*/ */
void set(const uint_fast64_t index, bool value = true);
void set(uint_fast64_t index, bool value = true);
/*! /*!
* Sets all bits in the given iterator range [first, last). * Sets all bits in the given iterator range [first, last).
* *
@ -206,7 +206,7 @@ namespace storm {
*/ */
template<typename InputIterator> template<typename InputIterator>
void set(InputIterator first, InputIterator last, bool value = true); void set(InputIterator first, InputIterator last, bool value = true);
/*! /*!
* Retrieves the truth value of the bit at the given index. Note: this does not check whether the given * Retrieves the truth value of the bit at the given index. Note: this does not check whether the given
* index is within bounds. * index is within bounds.
@ -215,7 +215,7 @@ namespace storm {
* @return True iff the bit at the given index is set. * @return True iff the bit at the given index is set.
*/ */
bool operator[](uint_fast64_t index) const; bool operator[](uint_fast64_t index) const;
/*! /*!
* Retrieves the truth value of the bit at the given index and performs a bound check. If the access is * Retrieves the truth value of the bit at the given index and performs a bound check. If the access is
* out-of-bounds an OutOfBoundsException is thrown. * out-of-bounds an OutOfBoundsException is thrown.
@ -223,8 +223,8 @@ namespace storm {
* @param index The index of the bit to access. * @param index The index of the bit to access.
* @return True iff the bit at the given index is set. * @return True iff the bit at the given index is set.
*/ */
bool get(const uint_fast64_t index) const;
bool get(uint_fast64_t index) const;
/*! /*!
* Resizes the bit vector to hold the given new number of bits. If the bit vector becomes smaller this way, * Resizes the bit vector to hold the given new number of bits. If the bit vector becomes smaller this way,
* the bits are truncated. Otherwise, the new bits are initialized to the given value. * the bits are truncated. Otherwise, the new bits are initialized to the given value.
@ -233,7 +233,7 @@ namespace storm {
* @param init The truth value to which to initialize newly created bits. * @param init The truth value to which to initialize newly created bits.
*/ */
void resize(uint_fast64_t newLength, bool init = false); void resize(uint_fast64_t newLength, bool init = false);
/*! /*!
* Enlarges the bit vector such that it holds at least the given number of bits (but possibly more). * Enlarges the bit vector such that it holds at least the given number of bits (but possibly more).
* This can be used to diminish reallocations when the final size of the bit vector is not known yet. * This can be used to diminish reallocations when the final size of the bit vector is not known yet.
@ -244,7 +244,7 @@ namespace storm {
* @param init The truth value to which to initialize newly created bits. * @param init The truth value to which to initialize newly created bits.
*/ */
void grow(uint_fast64_t minimumLength, bool init = false); void grow(uint_fast64_t minimumLength, bool init = false);
/*! /*!
* Performs a logical "and" with the given bit vector. In case the sizes of the bit vectors do not match, * Performs a logical "and" with the given bit vector. In case the sizes of the bit vectors do not match,
* only the matching portion is considered and the overlapping bits are set to 0. * only the matching portion is considered and the overlapping bits are set to 0.
@ -253,7 +253,7 @@ namespace storm {
* @return A bit vector corresponding to the logical "and" of the two bit vectors. * @return A bit vector corresponding to the logical "and" of the two bit vectors.
*/ */
BitVector operator&(BitVector const& other) const; BitVector operator&(BitVector const& other) const;
/*! /*!
* Performs a logical "and" with the given bit vector and assigns the result to the current bit vector. * Performs a logical "and" with the given bit vector and assigns the result to the current bit vector.
* In case the sizes of the bit vectors do not match, only the matching portion is considered and the * In case the sizes of the bit vectors do not match, only the matching portion is considered and the
@ -264,7 +264,7 @@ namespace storm {
* of the two bit vectors. * of the two bit vectors.
*/ */
BitVector& operator&=(BitVector const& other); BitVector& operator&=(BitVector const& other);
/*! /*!
* Performs a logical "or" with the given bit vector. In case the sizes of the bit vectors do not match, * Performs a logical "or" with the given bit vector. In case the sizes of the bit vectors do not match,
* only the matching portion is considered and the overlapping bits are set to 0. * only the matching portion is considered and the overlapping bits are set to 0.
@ -273,7 +273,7 @@ namespace storm {
* @return A bit vector corresponding to the logical "or" of the two bit vectors. * @return A bit vector corresponding to the logical "or" of the two bit vectors.
*/ */
BitVector operator|(BitVector const& other) const; BitVector operator|(BitVector const& other) const;
/*! /*!
* Performs a logical "or" with the given bit vector and assigns the result to the current bit vector. * Performs a logical "or" with the given bit vector and assigns the result to the current bit vector.
* In case the sizes of the bit vectors do not match, only the matching portion is considered and the * In case the sizes of the bit vectors do not match, only the matching portion is considered and the
@ -284,7 +284,7 @@ namespace storm {
* of the two bit vectors. * of the two bit vectors.
*/ */
BitVector& operator|=(BitVector const& other); BitVector& operator|=(BitVector const& other);
/*! /*!
* Performs a logical "xor" with the given bit vector. In case the sizes of the bit vectors do not match, * Performs a logical "xor" with the given bit vector. In case the sizes of the bit vectors do not match,
* only the matching portion is considered and the overlapping bits are set to 0. * only the matching portion is considered and the overlapping bits are set to 0.
@ -293,36 +293,39 @@ namespace storm {
* @return A bit vector corresponding to the logical "xor" of the two bit vectors. * @return A bit vector corresponding to the logical "xor" of the two bit vectors.
*/ */
BitVector operator^(BitVector const& other) const; BitVector operator^(BitVector const& other) const;
/*! /*!
* Computes a bit vector that is as long as the number of set bits in the given filter that has bit i is set
* iff the i-th set bit of the current bit vector is set in the filter.
* Computes a bit vector that contains only the values of the bits given by the filter.
* The returned bit vector is as long as the number of set bits in the given filter.
* Bit i is set in the returned bit vector iff the i-th set bit of the current bit vector is set in the filter.
*
* For example: 00100110 % 10101010 returns 0101
* *
* @param filter A reference the bit vector to use as the filter.
* @return A bit vector that is as long as the number of set bits in the given filter that has bit i is set
* iff the i-th set bit of the current bit vector is set in the filter.
* @param filter A reference bit vector to use as the filter.
* @return A bit vector that is as long as the number of set bits in the given filter and
* contains only the values of the bits set in the filter.
*/ */
BitVector operator%(BitVector const& filter) const; BitVector operator%(BitVector const& filter) const;
/*! /*!
* Performs a logical "not" on the bit vector. * Performs a logical "not" on the bit vector.
* *
* @return A bit vector corresponding to the logical "not" of the bit vector. * @return A bit vector corresponding to the logical "not" of the bit vector.
*/ */
BitVector operator~() const; BitVector operator~() const;
/*! /*!
* Negates all bits in the bit vector. * Negates all bits in the bit vector.
*/ */
void complement(); void complement();
/*! /*!
* Increments the (unsigned) number represented by this BitVector by one. * Increments the (unsigned) number represented by this BitVector by one.
* @note Index 0 is assumed to be the least significant bit. * @note Index 0 is assumed to be the least significant bit.
* @note Wraps around, i.e., incrementing 11..1 yields 00..0. * @note Wraps around, i.e., incrementing 11..1 yields 00..0.
*/ */
void increment(); void increment();
/*! /*!
* Performs a logical "implies" with the given bit vector. In case the sizes of the bit vectors do not * Performs a logical "implies" with the given bit vector. In case the sizes of the bit vectors do not
* match, only the matching portion is considered and the overlapping bits are set to 0. * match, only the matching portion is considered and the overlapping bits are set to 0.
@ -331,7 +334,7 @@ namespace storm {
* @return A bit vector corresponding to the logical "implies" of the two bit vectors. * @return A bit vector corresponding to the logical "implies" of the two bit vectors.
*/ */
BitVector implies(BitVector const& other) const; BitVector implies(BitVector const& other) const;
/*! /*!
* Checks whether all bits that are set in the current bit vector are also set in the given bit vector. * Checks whether all bits that are set in the current bit vector are also set in the given bit vector.
* *
@ -341,7 +344,7 @@ namespace storm {
* vector. * vector.
*/ */
bool isSubsetOf(BitVector const& other) const; bool isSubsetOf(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 * Checks whether none of the bits that are set in the current bit vector are also set in the given bit
* vector. * vector.
@ -352,7 +355,7 @@ namespace storm {
* given bit vector. * given bit vector.
*/ */
bool isDisjointFrom(BitVector const& other) const; bool isDisjointFrom(BitVector const& other) const;
/*! /*!
* Checks whether the given bit vector matches the bits starting from the given index in the current bit * Checks whether the given bit vector matches the bits starting from the given index in the current bit
* vector. Note: the given bit vector must be shorter than the current one minus the given index. * vector. Note: the given bit vector must be shorter than the current one minus the given index.
@ -362,7 +365,7 @@ namespace storm {
* @return bool True iff the bits match exactly. * @return bool True iff the bits match exactly.
*/ */
bool matches(uint_fast64_t bitIndex, BitVector const& other) const; bool matches(uint_fast64_t bitIndex, BitVector const& other) const;
/*! /*!
* Sets the exact bit pattern of the given bit vector starting at the given bit index. Note: the given bit * Sets the exact bit pattern of the given bit vector starting at the given bit index. Note: the given bit
* vector must be shorter than the current one minus the given index. * vector must be shorter than the current one minus the given index.
@ -372,7 +375,7 @@ namespace storm {
* @param other The bit vector whose pattern to set. * @param other The bit vector whose pattern to set.
*/ */
void set(uint_fast64_t bitIndex, BitVector const& other); void set(uint_fast64_t bitIndex, BitVector const& other);
/*! /*!
* Retrieves the content of the current bit vector at the given index for the given number of bits as a new * Retrieves the content of the current bit vector at the given index for the given number of bits as a new
* bit vector. * bit vector.
@ -382,7 +385,7 @@ namespace storm {
* @return A new bit vector holding the selected bits. * @return A new bit vector holding the selected bits.
*/ */
storm::storage::BitVector get(uint_fast64_t bitIndex, uint_fast64_t numberOfBits) const; storm::storage::BitVector get(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 * Retrieves the content of the current bit vector at the given index for the given number of bits as an
* unsigned integer value. * unsigned integer value.
@ -391,14 +394,14 @@ namespace storm {
* @param numberOfBits The number of bits to get. This value must be less or equal than 64. * @param numberOfBits The number of bits to get. This value must be less or equal than 64.
*/ */
uint_fast64_t getAsInt(uint_fast64_t bitIndex, uint_fast64_t numberOfBits) const; uint_fast64_t getAsInt(uint_fast64_t bitIndex, uint_fast64_t numberOfBits) const;
/*! /*!
* *
* @param bitIndex The index of the first of the two bits to get * @param bitIndex The index of the first of the two bits to get
* @return A value between 0 and 3, encoded as a byte. * @return A value between 0 and 3, encoded as a byte.
*/ */
uint_fast64_t getTwoBitsAligned(uint_fast64_t bitIndex) const; uint_fast64_t getTwoBitsAligned(uint_fast64_t bitIndex) const;
/*! /*!
* Sets the selected number of lowermost bits of the provided value at the given bit index. * Sets the selected number of lowermost bits of the provided value at the given bit index.
* *
@ -407,14 +410,14 @@ namespace storm {
* @param value The integer whose lowermost bits to set. * @param value The integer whose lowermost bits to set.
*/ */
void setFromInt(uint_fast64_t bitIndex, uint_fast64_t numberOfBits, uint64_t value); void setFromInt(uint_fast64_t bitIndex, uint_fast64_t numberOfBits, uint64_t value);
/*! /*!
* Retrieves whether no bits are set to true in this bit vector. * Retrieves whether no bits are set to true in this bit vector.
* *
* @return False iff there is at least one bit set in this vector. * @return False iff there is at least one bit set in this vector.
*/ */
bool empty() const; bool empty() const;
/*! /*!
* Retrievs whether all bits are set in this bit vector. * Retrievs whether all bits are set in this bit vector.
* If the bit vector has size 0, this method always returns true. * If the bit vector has size 0, this method always returns true.
@ -422,24 +425,24 @@ namespace storm {
* @return True iff all bits in the bit vector are set. * @return True iff all bits in the bit vector are set.
*/ */
bool full() const; bool full() const;
/*! /*!
* Removes all set bits from the bit vector. Calling empty() after this operation will yield true. * Removes all set bits from the bit vector. Calling empty() after this operation will yield true.
*/ */
void clear(); void clear();
/*! /*!
* Sets all bits from the bit vector. Calling full() after this operation will yield true. * Sets all bits from the bit vector. Calling full() after this operation will yield true.
*/ */
void fill(); void fill();
/*! /*!
* Returns the number of bits that are set to true in this bit vector. * Returns the number of bits that are set to true in this bit vector.
* *
* @return The number of bits that are set to true in this bit vector. * @return The number of bits that are set to true in this bit vector.
*/ */
uint_fast64_t getNumberOfSetBits() const; uint_fast64_t getNumberOfSetBits() const;
/*! /*!
* Retrieves the number of bits set in this bit vector with an index strictly smaller than the given one. * Retrieves the number of bits set in this bit vector with an index strictly smaller than the given one.
* *
@ -447,39 +450,39 @@ namespace storm {
* @return The number of bits set in this bit vector with an index strictly smaller than the given one. * @return The number of bits set in this bit vector with an index strictly smaller than the given one.
*/ */
uint_fast64_t getNumberOfSetBitsBeforeIndex(uint_fast64_t index) const; uint_fast64_t getNumberOfSetBitsBeforeIndex(uint_fast64_t index) const;
/*! /*!
* Retrieves a vector that holds at position i the number of bits set before index i. * Retrieves a vector that holds at position i the number of bits set before index i.
* *
* @return The resulting vector of 'offsets'. * @return The resulting vector of 'offsets'.
*/ */
std::vector<uint_fast64_t> getNumberOfSetBitsBeforeIndices() const; std::vector<uint_fast64_t> getNumberOfSetBitsBeforeIndices() const;
/*! /*!
* Retrieves the number of bits this bit vector can store. * Retrieves the number of bits this bit vector can store.
* *
* @return The number of bits this bit vector can hold. * @return The number of bits this bit vector can hold.
*/ */
size_t size() const; size_t size() const;
/*! /*!
* Returns (an approximation of) the size of the bit vector measured in bytes. * Returns (an approximation of) the size of the bit vector measured in bytes.
* *
* @return The size of the bit vector measured in bytes. * @return The size of the bit vector measured in bytes.
*/ */
std::size_t getSizeInBytes() const; std::size_t getSizeInBytes() const;
/*! /*!
* Returns an iterator to the indices of the set bits in the bit vector. * Returns an iterator to the indices of the set bits in the bit vector.
*/ */
const_iterator begin() const; const_iterator begin() const;
/*! /*!
* Returns an iterator pointing at the element past the bit vector. * Returns an iterator pointing at the element past the bit vector.
*/ */
const_iterator end() const; const_iterator end() const;
/*
/*!
* Retrieves the index of the bit that is the next bit set to true in the bit vector. If there is none, * Retrieves the index of the bit that is the next bit set to true in the bit vector. If there is none,
* this function returns the number of bits this vector holds in total. Put differently, if the return * this function returns the number of bits this vector holds in total. Put differently, if the return
* value is equal to a call to size(), then there is no bit set after the specified position. * value is equal to a call to size(), then there is no bit set after the specified position.
@ -489,8 +492,8 @@ namespace storm {
* @return The index of the next bit that is set after the given index. * @return The index of the next bit that is set after the given index.
*/ */
uint_fast64_t getNextSetIndex(uint_fast64_t startingIndex) const; uint_fast64_t getNextSetIndex(uint_fast64_t startingIndex) const;
/*
/*!
* Retrieves the index of the bit that is the next bit set to false in the bit vector. If there is none, * Retrieves the index of the bit that is the next bit set to false in the bit vector. If there is none,
* this function returns the number of bits this vector holds in total. Put differently, if the return * this function returns the number of bits this vector holds in total. Put differently, if the return
* value is equal to a call to size(), then there is no unset bit after the specified position. * value is equal to a call to size(), then there is no unset bit after the specified position.
@ -500,8 +503,8 @@ namespace storm {
* @return The index of the next bit that is set after the given index. * @return The index of the next bit that is set after the given index.
*/ */
uint_fast64_t getNextUnsetIndex(uint_fast64_t startingIndex) const; uint_fast64_t getNextUnsetIndex(uint_fast64_t startingIndex) const;
/*
/*!
* Compare two intervals [start1, start1+length] and [start2, start2+length] and swap them if the second * Compare two intervals [start1, start1+length] and [start2, start2+length] and swap them if the second
* one is larger than the first one. After the method the intervals are sorted in decreasing order. * one is larger than the first one. After the method the intervals are sorted in decreasing order.
* *
@ -511,14 +514,15 @@ namespace storm {
* @return True, if the intervals were swapped, false if nothing changed. * @return True, if the intervals were swapped, false if nothing changed.
*/ */
bool compareAndSwap(uint_fast64_t start1, uint_fast64_t start2, uint_fast64_t length); bool compareAndSwap(uint_fast64_t start1, uint_fast64_t start2, uint_fast64_t length);
friend std::ostream& operator<<(std::ostream& out, BitVector const& bitVector); friend std::ostream& operator<<(std::ostream& out, BitVector const& bitVector);
friend struct std::hash<storm::storage::BitVector>; friend struct std::hash<storm::storage::BitVector>;
friend struct FNV1aBitVectorHash; friend struct FNV1aBitVectorHash;
template<typename StateType> template<typename StateType>
friend struct Murmur3BitVectorHash; friend struct Murmur3BitVectorHash;
private: private:
/*! /*!
* Creates an empty bit vector with the given number of buckets. * Creates an empty bit vector with the given number of buckets.
@ -527,7 +531,7 @@ namespace storm {
* @param bitCount This must be the number of buckets times 64. * @param bitCount This must be the number of buckets times 64.
*/ */
BitVector(uint_fast64_t bucketCount, uint_fast64_t bitCount); BitVector(uint_fast64_t bucketCount, uint_fast64_t bitCount);
/*! /*!
* Retrieves the index of the next bit that is set to the given value after (and including) the given starting index. * Retrieves the index of the next bit that is set to the given value after (and including) the given starting index.
* *
@ -539,12 +543,12 @@ namespace storm {
* in the given bit vector or endIndex in case the end index was reached. * in the given bit vector or endIndex in case the end index was reached.
*/ */
static uint_fast64_t getNextIndexWithValue(bool value, uint64_t const* dataPtr, uint_fast64_t startingIndex, uint_fast64_t endIndex); static uint_fast64_t getNextIndexWithValue(bool value, uint64_t const* dataPtr, uint_fast64_t startingIndex, uint_fast64_t endIndex);
/*! /*!
* Truncate the last bucket so that no bits are set starting from bitCount. * Truncate the last bucket so that no bits are set starting from bitCount.
*/ */
void truncateLastBucket(); void truncateLastBucket();
/*! Retrieves the content of the current bit vector at the given index for the given number of bits as a new /*! Retrieves the content of the current bit vector at the given index for the given number of bits as a new
* bit vector. * bit vector.
* *
@ -553,7 +557,7 @@ namespace storm {
* @return A new bit vector holding the selected bits. * @return A new bit vector holding the selected bits.
*/ */
BitVector getAsBitVector(uint_fast64_t start, uint_fast64_t length) const; BitVector getAsBitVector(uint_fast64_t start, uint_fast64_t length) const;
/*! /*!
* Sets the exact bit pattern of the given bit vector starting at the given bit index. Note: the given bit * Sets the exact bit pattern of the given bit vector starting at the given bit index. Note: the given bit
* vector must be shorter than the current one minus the given index. * vector must be shorter than the current one minus the given index.
@ -562,31 +566,31 @@ namespace storm {
* @param other The bit vector whose pattern to set. * @param other The bit vector whose pattern to set.
*/ */
void setFromBitVector(uint_fast64_t start, BitVector const& other); void setFromBitVector(uint_fast64_t start, BitVector const& other);
/*! /*!
* Print bit vector and display all bits. * Print bit vector and display all bits.
* *
* @param out Stream to print to. * @param out Stream to print to.
*/ */
void printBits(std::ostream& out) const; void printBits(std::ostream& out) const;
/*! /*!
* Retrieves the number of buckets of the underlying storage. * Retrieves the number of buckets of the underlying storage.
* *
* @return The number of buckets of the underlying storage. * @return The number of buckets of the underlying storage.
*/ */
size_t bucketCount() const; size_t bucketCount() const;
// The number of bits that this bit vector can hold. // The number of bits that this bit vector can hold.
uint_fast64_t bitCount; uint_fast64_t bitCount;
// The underlying storage of 64-bit buckets for all bits of this bit vector. // The underlying storage of 64-bit buckets for all bits of this bit vector.
uint64_t* buckets; uint64_t* buckets;
// A bit mask that can be used to reduce a modulo 64 operation to a logical "and". // A bit mask that can be used to reduce a modulo 64 operation to a logical "and".
static const uint_fast64_t mod64mask = (1 << 6) - 1; static const uint_fast64_t mod64mask = (1 << 6) - 1;
}; };
struct FNV1aBitVectorHash { struct FNV1aBitVectorHash {
std::size_t operator()(storm::storage::BitVector const& bv) const; std::size_t operator()(storm::storage::BitVector const& bv) const;
}; };
@ -600,7 +604,7 @@ namespace storm {
} // namespace storm } // namespace storm
namespace std { namespace std {
template <>
template<>
struct hash<storm::storage::BitVector> { struct hash<storm::storage::BitVector> {
std::size_t operator()(storm::storage::BitVector const& bv) const; std::size_t operator()(storm::storage::BitVector const& bv) const;
}; };

Loading…
Cancel
Save