From 7331544377ed0cd39d48cda479cab5b4b863e324 Mon Sep 17 00:00:00 2001 From: dehnert Date: Sat, 26 Jan 2013 11:23:20 +0100 Subject: [PATCH] Added output functionality to bit vector and moved test-checking lines in storm.cpp to the right place. --- src/storage/BitVector.h | 22 ++++++++++++++++++---- src/storm.cpp | 8 ++++---- 2 files changed, 22 insertions(+), 8 deletions(-) diff --git a/src/storage/BitVector.h b/src/storage/BitVector.h index 66baf546e..df3f86600 100644 --- a/src/storage/BitVector.h +++ b/src/storage/BitVector.h @@ -387,11 +387,11 @@ public: * Returns the number of bits that are set (to one) in this bit vector. * @return The number of bits that are set (to one) in this bit vector. */ - uint_fast64_t getNumberOfSetBits() { + uint_fast64_t getNumberOfSetBits() const { return getNumberOfSetBitsBeforeIndex(bucketCount << 6); } - uint_fast64_t getNumberOfSetBitsBeforeIndex(uint_fast64_t index) { + uint_fast64_t getNumberOfSetBitsBeforeIndex(uint_fast64_t index) const { uint_fast64_t result = 0; // First, count all full buckets. uint_fast64_t bucket = index >> 6; @@ -437,7 +437,7 @@ public: /*! * Retrieves the number of bits this bit vector can store. */ - uint_fast64_t getSize() { + uint_fast64_t getSize() const { return bitCount; } @@ -445,7 +445,7 @@ public: * Returns the size of the bit vector in memory measured in bytes. * @return The size of the bit vector in memory measured in bytes. */ - uint_fast64_t getSizeInMemory() { + uint_fast64_t getSizeInMemory() const { return sizeof(*this) + sizeof(uint_fast64_t) * bucketCount; } @@ -463,6 +463,20 @@ public: return endIterator; } + /*! + * Returns a string representation of the bit vector. + */ + std::string toString() const { + std::stringstream result; + result << "bit vector(" << this->getNumberOfSetBits() << ") ["; + for (auto index : *this) { + result << index << " "; + } + result << "]"; + + return result.str(); + } + private: /*! diff --git a/src/storm.cpp b/src/storm.cpp index 250163f70..9d2fff6d7 100644 --- a/src/storm.cpp +++ b/src/storm.cpp @@ -216,12 +216,12 @@ void testChecking() { if (parser.getType() == storm::models::DTMC) { std::shared_ptr> dtmc = parser.getModel>(); dtmc->printModelInformationToStream(std::cout); + + // testCheckingDie(*dtmc); + // testCheckingCrowds(*dtmc); + // testCheckingSynchronousLeader(*dtmc, 4); } else std::cout << "Input is not DTMC" << std::endl; - - // testCheckingDie(*dtmc); - // testCheckingCrowds(*dtmc); - // testCheckingSynchronousLeader(*dtmc, 4); } /*!