diff --git a/src/storage/BitVector.cpp b/src/storage/BitVector.cpp index 9835c54dc..3e1e9bb5b 100644 --- a/src/storage/BitVector.cpp +++ b/src/storage/BitVector.cpp @@ -78,6 +78,11 @@ namespace storm { set(begin, end); } + BitVector::BitVector(uint_fast64_t length, std::vector setEntries) : BitVector(length, setEntries.begin(), setEntries.end()) + { + // Intentionally left empty. + } + BitVector::BitVector(uint_fast64_t bucketCount, uint_fast64_t bitCount) : bitCount(bitCount), bucketVector(bucketCount) { STORM_LOG_ASSERT((bucketCount << 6) == bitCount, "Bit count does not match number of buckets."); } diff --git a/src/storage/BitVector.h b/src/storage/BitVector.h index ec4cce693..4c5e64352 100644 --- a/src/storage/BitVector.h +++ b/src/storage/BitVector.h @@ -118,6 +118,11 @@ namespace storm { template 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 + */ + BitVector(uint_fast64_t length, std::vector setEntries); + /*! * Performs a deep copy of the given bit vector. * diff --git a/test/functional/storage/BitVectorTest.cpp b/test/functional/storage/BitVectorTest.cpp index 88715dff7..3dc139fa7 100644 --- a/test/functional/storage/BitVectorTest.cpp +++ b/test/functional/storage/BitVectorTest.cpp @@ -39,6 +39,21 @@ TEST(BitVectorTest, InitFromIterator) { } } +TEST(BitVectorTest, InitFromIntVector) { + std::vector valueVector = {0, 4, 10}; + storm::storage::BitVector vector(32, valueVector); + + ASSERT_EQ(32ul, vector.size()); + + for (uint_fast64_t i = 0; i < 32; ++i) { + if (i == 0 || i == 4 || i == 10) { + ASSERT_TRUE(vector.get(i)); + } else { + ASSERT_FALSE(vector.get(i)); + } + } +} + TEST(BitVectorTest, GetSet) { storm::storage::BitVector vector(32);