move_into() will be used to move data from internal (private)
std::map into other, external std::map, without exposing internal one
to public. New ctor improves moving data from external map to internal
one.
Signed-off-by: Piotr Dałek <piotr.dalek@corp.ovh.com>
};
interval_set() : _size(0) {}
+ interval_set(std::map<T,T>& other) {
+ m.swap(other);
+ _size = 0;
+ for (auto& i : m) {
+ _size += i.second;
+ }
+ }
int num_intervals() const
{
}
}
+ /*
+ * Move contents of m into another std::map<T,T>. Use that instead of
+ * encoding interval_set into bufferlist then decoding it back into std::map.
+ */
+ void move_into(std::map<T,T>& other) {
+ other = std::move(m);
+ }
+
private:
// data
int64_t _size;