[util] Add move-assignment operators to node_map, deque

Also add them to wait_queue as a wrapper to calling deque's
move-assignmen operator.
This commit is contained in:
Justin C. Miller
2023-02-26 11:27:30 -08:00
parent 1d7d5e8015
commit 0c777bc62f
4 changed files with 37 additions and 2 deletions

View File

@@ -2,6 +2,7 @@
/// \file linked_list.h
/// A generic templatized linked list.
#include <utility>
#include <assert.h>
#include <string.h>
#include <util/linked_list.h>
@@ -37,9 +38,23 @@ public:
size_t index;
};
deque() : m_first(0), m_next(N) {}
deque() : m_first {0}, m_next {N} {}
deque(deque &&other) :
m_first {other.m_first},
m_next {other.m_next},
m_list {std::move(other.m_list)} {}
~deque() { clear(); }
deque & operator=(deque &&other) {
clear();
m_first = other.m_first;
m_next = other.m_next;
m_list = std::move(other.m_list);
return *this;
}
inline void push_front(const T& item) {
if (!m_first) { // need a new block at the start
node_type *n = new node_type;

View File

@@ -150,7 +150,7 @@ public:
key_type &key_at_slot = get_map_key(node_at_slot);
if (open(key_at_slot)) {
node_at_slot = node;
node_at_slot = std::move(node);
if (!found)
inserted_at = slot;
return m_nodes[inserted_at];