Skip to content

Commit

Permalink
Add JSON output to DenseSet
Browse files Browse the repository at this point in the history
  • Loading branch information
simondsmart committed Jan 18, 2024
1 parent 57dea7c commit 1e188aa
Showing 1 changed file with 15 additions and 0 deletions.
15 changes: 15 additions & 0 deletions src/eckit/container/DenseSet.h
Original file line number Diff line number Diff line change
Expand Up @@ -18,6 +18,7 @@
#include <utility>
#include <vector>

#include "eckit/log/JSON.h"
#include "eckit/exception/Exceptions.h"


Expand Down Expand Up @@ -130,6 +131,15 @@ class DenseSet {
}
}

void json(JSON& s) const {
s.startList();
const_iterator it = cbegin();
for (; it != cend(); ++it) {
s << *it;
}
s.endList();
}

bool operator==(const DenseSet& rhs) const { return !operator!=(rhs); }

bool operator!=(const DenseSet& rhs) const { return values_ != rhs.values_; }
Expand All @@ -139,6 +149,11 @@ class DenseSet {
return s;
}

friend JSON& operator<<(JSON& s, const DenseSet& m) {
m.json(s);
return s;
}

void merge(const DenseSet& other) {

if (other.empty()) return;
Expand Down

0 comments on commit 1e188aa

Please sign in to comment.