Browse Source

lowlevel storing/loading bitvectors from a string (without any error handling, that is). Helpful to store bitvecots in python

tempestpy_adaptions
Sebastian Junges 5 years ago
parent
commit
0a5717aee7
  1. 30
      src/storm/storage/BitVector.cpp
  2. 3
      src/storm/storage/BitVector.h

30
src/storm/storage/BitVector.cpp

@ -1240,6 +1240,36 @@ namespace storm {
return h1 ^ h2;
}
void BitVector::store(std::ostream& os) const {
os << bitCount;
for (uint64_t i = 0; i < bucketCount(); ++i) {
os << " " << buckets[i];
}
}
BitVector BitVector::load(std::string const& description) {
std::vector<std::string> splitted;
std::stringstream ss(description);
ss >> std::noskipws;
std::string field;
char ws_delim;
while(true) {
if( ss >> field )
splitted.push_back(field);
else if (ss.eof())
break;
else
splitted.push_back(std::string());
ss.clear();
ss >> ws_delim;
}
BitVector bv(std::stoul(splitted[0]));
for(uint64_t i = 0; i < splitted.size()-1; ++i) {
bv.buckets[i] = std::stoul(splitted[i+1]);
}
return bv;
}
// All necessary explicit template instantiations.
template BitVector::BitVector(uint_fast64_t length, std::vector<uint_fast64_t>::iterator begin, std::vector<uint_fast64_t>::iterator end);

3
src/storm/storage/BitVector.h

@ -538,6 +538,9 @@ namespace storm {
friend std::ostream& operator<<(std::ostream& out, BitVector const& bitVector);
void store(std::ostream&) const;
static BitVector load(std::string const& description);
friend struct std::hash<storm::storage::BitVector>;
friend struct FNV1aBitVectorHash;

Loading…
Cancel
Save