summaryrefslogtreecommitdiff
path: root/src/set.cpp
diff options
context:
space:
mode:
authorRoman Smrž <roman.smrz@seznam.cz>2022-12-18 18:56:19 +0100
committerRoman Smrž <roman.smrz@seznam.cz>2022-12-18 21:37:11 +0100
commit86293ff20d9f8625615e855d98249175e8cd5cd3 (patch)
tree7eb1fe3a34ce1d6a24a9338f3dd3008b500fffe0 /src/set.cpp
parent77fc16d21158c6542addcbaaff47b801d3b5f5c7 (diff)
Contact service and contacts using stored set
Diffstat (limited to 'src/set.cpp')
-rw-r--r--src/set.cpp21
1 files changed, 20 insertions, 1 deletions
diff --git a/src/set.cpp b/src/set.cpp
index 001bce3..d224af3 100644
--- a/src/set.cpp
+++ b/src/set.cpp
@@ -32,7 +32,7 @@ SetBase::SetBase(shared_ptr<const Priv> p_):
{
}
-shared_ptr<const SetBase::Priv> SetBase::add(Storage & st, const vector<Ref> & refs) const
+shared_ptr<const SetBase::Priv> SetBase::add(const Storage & st, const vector<Ref> & refs) const
{
auto item = st.store(SetItem {
.prev = p->items,
@@ -122,6 +122,16 @@ vector<vector<Ref>> SetBase::toList() const
return res;
}
+bool SetBase::operator==(const SetBase & other) const
+{
+ return p->items == other.p->items;
+}
+
+bool SetBase::operator!=(const SetBase & other) const
+{
+ return !(*this == other);
+}
+
vector<Digest> SetBase::digests() const
{
vector<Digest> res;
@@ -131,6 +141,15 @@ vector<Digest> SetBase::digests() const
return res;
}
+vector<Ref> SetBase::store() const
+{
+ vector<Ref> res;
+ res.reserve(p->items.size());
+ for (const auto & i : p->items)
+ res.push_back(i.ref());
+ return res;
+}
+
SetItem SetItem::load(const Ref & ref)
{
if (auto rec = ref->asRecord()) {