util/IntrusiveList: add method insert()
This commit is contained in:
parent
4912466d50
commit
75e8795e3f
@ -317,18 +317,20 @@ public:
|
|||||||
}
|
}
|
||||||
|
|
||||||
void push_front(T &t) noexcept {
|
void push_front(T &t) noexcept {
|
||||||
auto &new_node = ToNode(t);
|
insert(begin(), t);
|
||||||
head.next->prev = &new_node;
|
|
||||||
new_node.next = head.next;
|
|
||||||
head.next = &new_node;
|
|
||||||
new_node.prev = &head;
|
|
||||||
}
|
}
|
||||||
|
|
||||||
void push_back(T &t) noexcept {
|
void push_back(T &t) noexcept {
|
||||||
|
insert(end(), t);
|
||||||
|
}
|
||||||
|
|
||||||
|
void insert(iterator p, T &t) noexcept {
|
||||||
|
auto &existing_node = ToNode(*p);
|
||||||
auto &new_node = ToNode(t);
|
auto &new_node = ToNode(t);
|
||||||
head.prev->next = &new_node;
|
|
||||||
new_node.prev = head.prev;
|
existing_node.prev->next = &new_node;
|
||||||
head.prev = &new_node;
|
new_node.prev = existing_node.prev;
|
||||||
new_node.next = &head;
|
existing_node.prev = &new_node;
|
||||||
|
new_node.next = &existing_node;
|
||||||
}
|
}
|
||||||
};
|
};
|
||||||
|
Loading…
Reference in New Issue
Block a user