mirror of
https://github.com/panda3d/panda3d.git
synced 2025-09-27 15:25:54 -04:00
putil: make LinkedListNode moveable
This commit is contained in:
parent
9441c28f61
commit
f5a78d599d
@ -33,6 +33,25 @@ LinkedListNode(bool) {
|
|||||||
_prev = this;
|
_prev = this;
|
||||||
}
|
}
|
||||||
|
|
||||||
|
/**
|
||||||
|
* This move constructor replaces the other link with this one.
|
||||||
|
*/
|
||||||
|
INLINE LinkedListNode::
|
||||||
|
LinkedListNode(LinkedListNode &&from) noexcept {
|
||||||
|
if (from._prev != nullptr) {
|
||||||
|
nassertv(from._prev->_next == &from);
|
||||||
|
from._prev->_next = this;
|
||||||
|
}
|
||||||
|
_prev = from._prev;
|
||||||
|
if (from._next != nullptr) {
|
||||||
|
nassertv(from._next->_prev == &from);
|
||||||
|
from._next->_prev = this;
|
||||||
|
}
|
||||||
|
_next = from._next;
|
||||||
|
from._next = nullptr;
|
||||||
|
from._prev = nullptr;
|
||||||
|
}
|
||||||
|
|
||||||
/**
|
/**
|
||||||
*
|
*
|
||||||
*/
|
*/
|
||||||
@ -41,6 +60,23 @@ INLINE LinkedListNode::
|
|||||||
nassertv((_next == nullptr && _prev == nullptr) || (_next == this && _prev == this));
|
nassertv((_next == nullptr && _prev == nullptr) || (_next == this && _prev == this));
|
||||||
}
|
}
|
||||||
|
|
||||||
|
/**
|
||||||
|
* Replaces the given other node with this node.
|
||||||
|
*/
|
||||||
|
INLINE LinkedListNode &LinkedListNode::
|
||||||
|
operator = (LinkedListNode &&from) {
|
||||||
|
nassertr((_next == nullptr && _prev == nullptr) || (_next == this && _prev == this), *this);
|
||||||
|
nassertr(from._prev != nullptr && from._next != nullptr, *this);
|
||||||
|
nassertr(from._prev->_next == &from && from._next->_prev == &from, *this);
|
||||||
|
from._prev->_next = this;
|
||||||
|
from._next->_prev = this;
|
||||||
|
_prev = from._prev;
|
||||||
|
_next = from._next;
|
||||||
|
from._next = nullptr;
|
||||||
|
from._prev = nullptr;
|
||||||
|
return *this;
|
||||||
|
}
|
||||||
|
|
||||||
/**
|
/**
|
||||||
* Returns true if the node is member of any list, false if it has been
|
* Returns true if the node is member of any list, false if it has been
|
||||||
* removed or never added. The head of a list generally appears to to always
|
* removed or never added. The head of a list generally appears to to always
|
||||||
|
@ -32,8 +32,11 @@ class EXPCL_PANDA_PUTIL LinkedListNode {
|
|||||||
protected:
|
protected:
|
||||||
INLINE LinkedListNode();
|
INLINE LinkedListNode();
|
||||||
INLINE LinkedListNode(bool);
|
INLINE LinkedListNode(bool);
|
||||||
|
INLINE LinkedListNode(LinkedListNode &&from) noexcept;
|
||||||
INLINE ~LinkedListNode();
|
INLINE ~LinkedListNode();
|
||||||
|
|
||||||
|
INLINE LinkedListNode &operator = (LinkedListNode &&from);
|
||||||
|
|
||||||
INLINE bool is_on_list() const;
|
INLINE bool is_on_list() const;
|
||||||
INLINE void remove_from_list();
|
INLINE void remove_from_list();
|
||||||
INLINE void insert_before(LinkedListNode *node);
|
INLINE void insert_before(LinkedListNode *node);
|
||||||
|
Loading…
x
Reference in New Issue
Block a user