From 86293ff20d9f8625615e855d98249175e8cd5cd3 Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?Roman=20Smr=C5=BE?= Date: Sun, 18 Dec 2022 18:56:19 +0100 Subject: Contact service and contacts using stored set --- src/set.cpp | 21 ++++++++++++++++++++- 1 file changed, 20 insertions(+), 1 deletion(-) (limited to 'src/set.cpp') 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 p_): { } -shared_ptr SetBase::add(Storage & st, const vector & refs) const +shared_ptr SetBase::add(const Storage & st, const vector & refs) const { auto item = st.store(SetItem { .prev = p->items, @@ -122,6 +122,16 @@ vector> 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 SetBase::digests() const { vector res; @@ -131,6 +141,15 @@ vector SetBase::digests() const return res; } +vector SetBase::store() const +{ + vector 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()) { -- cgit v1.2.3