const_list: added owner to tail node
This commit is contained in:
parent
cf759983b8
commit
af7a6baaf9
|
|
@ -84,7 +84,7 @@ namespace cc {
|
||||||
using const_reverse_iterator = std::reverse_iterator<const_iterator>;
|
using const_reverse_iterator = std::reverse_iterator<const_iterator>;
|
||||||
|
|
||||||
private:
|
private:
|
||||||
const_list_node<Node> _tail;
|
const_list_node<Node> _tail { this };
|
||||||
|
|
||||||
std::size_t _size = 0;
|
std::size_t _size = 0;
|
||||||
|
|
||||||
|
|
@ -202,6 +202,8 @@ namespace cc {
|
||||||
constexpr void on_delete(void (*cb)()) noexcept;
|
constexpr void on_delete(void (*cb)()) noexcept;
|
||||||
|
|
||||||
private:
|
private:
|
||||||
|
constexpr explicit const_list_node(const_list<D> *owner) : _owner(owner) { asserts(); };
|
||||||
|
|
||||||
constexpr void push_before(const_list_node *node) noexcept;
|
constexpr void push_before(const_list_node *node) noexcept;
|
||||||
constexpr void unlink() noexcept;
|
constexpr void unlink() noexcept;
|
||||||
|
|
||||||
|
|
@ -332,7 +334,6 @@ namespace cc {
|
||||||
for (auto& value : values) {
|
for (auto& value : values) {
|
||||||
// it's operator-> may fail as it could be the tail node
|
// it's operator-> may fail as it could be the tail node
|
||||||
it._node->push_before(std::addressof(value.get()));
|
it._node->push_before(std::addressof(value.get()));
|
||||||
value.get()._owner = this;
|
|
||||||
}
|
}
|
||||||
|
|
||||||
_size += values.size();
|
_size += values.size();
|
||||||
|
|
@ -437,7 +438,6 @@ namespace cc {
|
||||||
if (comp(*first2, *first1)) {
|
if (comp(*first2, *first1)) {
|
||||||
auto next = std::next(first2);
|
auto next = std::next(first2);
|
||||||
|
|
||||||
first2._node->_owner = this;
|
|
||||||
first1._node->push_before(first2._node);
|
first1._node->push_before(first2._node);
|
||||||
|
|
||||||
first2 = next;
|
first2 = next;
|
||||||
|
|
@ -449,7 +449,6 @@ namespace cc {
|
||||||
while (first2 != last2) {
|
while (first2 != last2) {
|
||||||
auto next = std::next(first2);
|
auto next = std::next(first2);
|
||||||
|
|
||||||
first2._node->_owner = this;
|
|
||||||
_tail.push_before(first2._node);
|
_tail.push_before(first2._node);
|
||||||
|
|
||||||
first2 = next;
|
first2 = next;
|
||||||
|
|
@ -475,7 +474,6 @@ namespace cc {
|
||||||
if (comp(*first2, *first1)) {
|
if (comp(*first2, *first1)) {
|
||||||
auto next = std::next(first2);
|
auto next = std::next(first2);
|
||||||
|
|
||||||
first2._node->_owner = this;
|
|
||||||
first1._node->push_before(first2._node);
|
first1._node->push_before(first2._node);
|
||||||
|
|
||||||
first2 = next;
|
first2 = next;
|
||||||
|
|
@ -487,7 +485,6 @@ namespace cc {
|
||||||
while (first2 != last2) {
|
while (first2 != last2) {
|
||||||
auto next = std::next(first2);
|
auto next = std::next(first2);
|
||||||
|
|
||||||
first2._node->_owner = this;
|
|
||||||
_tail.push_before(first2._node);
|
_tail.push_before(first2._node);
|
||||||
|
|
||||||
first2 = next;
|
first2 = next;
|
||||||
|
|
@ -577,6 +574,8 @@ namespace cc {
|
||||||
|
|
||||||
_prev->_next = node;
|
_prev->_next = node;
|
||||||
_prev = node;
|
_prev = node;
|
||||||
|
|
||||||
|
node->_owner = _owner;
|
||||||
}
|
}
|
||||||
|
|
||||||
} // cc
|
} // cc
|
||||||
|
|
|
||||||
Loading…
Reference in New Issue