added erase

This commit is contained in:
cyborg1811m 2024-02-04 23:06:45 +01:00
parent c60cfaf8e8
commit 09ba7d5783
1 changed files with 34 additions and 0 deletions

View File

@ -353,6 +353,40 @@ namespace cc {
return it;
}
template<typename Node>
constexpr const_list<Node>::iterator const_list<Node>::erase(const_list::const_iterator pos)
{
auto it = pos._const_cast();
auto next = std::next(it);
it->unlink();
--_size;
return next;
}
template<typename Node>
constexpr const_list<Node>::iterator const_list<Node>::erase(const_list::const_iterator first, const_list::const_iterator last)
{
auto nc_last = last._const_cast();
if (first == last) {
return nc_last;
}
auto next = (last == end() ? end() : std::next(nc_last));
for (auto it = first._const_cast()._node; it != next._node; ) {
auto n = it->_next;
it->unlink();
--_size;
it = n;
}
return next;
}
template<typename D>
constexpr const_list_node<D>::const_list_node(const const_list_node &other) noexcept
: _delete_cb(other._delete_cb)