mirror of
https://github.com/libretro/scummvm.git
synced 2025-01-25 04:01:03 +00:00
HPL1: implement copy and move for Hpl1::Std::Tree
This commit is contained in:
parent
185ac140f0
commit
901b9dcc57
@ -23,6 +23,7 @@
|
||||
#define HPL1_TREE_H
|
||||
|
||||
#include "common/func.h"
|
||||
#include "common/util.h"
|
||||
#include "hpl1/std/pair.h"
|
||||
|
||||
namespace Hpl1 {
|
||||
@ -91,6 +92,34 @@ public:
|
||||
using BasicIterator = Iterator<ValueType &, ValueType *>;
|
||||
using ConstIterator = Iterator<const ValueType &, const ValueType *>;
|
||||
|
||||
Tree(KeyComp comp = {}) : _comp(Common::move(comp)) {
|
||||
}
|
||||
|
||||
Tree(const Tree &other) : _comp(other._comp) {
|
||||
for (const auto &val : other)
|
||||
insert(val);
|
||||
}
|
||||
|
||||
Tree(Tree &&other) : _root(other._root), _leftmost(other._leftmost), _size(other._size), _comp(Common::move(other._comp)) {
|
||||
}
|
||||
|
||||
Tree &operator=(const Tree &rhs) {
|
||||
*this = Tree(rhs);
|
||||
return *this;
|
||||
}
|
||||
|
||||
Tree &operator=(Tree &&rhs) {
|
||||
clear();
|
||||
_root = rhs._root;
|
||||
_leftmost = rhs._leftmost;
|
||||
_size = rhs._size;
|
||||
_comp = Common::move(rhs._comp);
|
||||
rhs._root = nullptr;
|
||||
rhs._leftmost = nullptr;
|
||||
rhs._size = 0;
|
||||
return *this;
|
||||
}
|
||||
|
||||
void clear() {
|
||||
erase(begin(), end());
|
||||
_size = 0;
|
||||
|
Loading…
x
Reference in New Issue
Block a user