added erase
This commit is contained in:
parent
c60cfaf8e8
commit
09ba7d5783
|
|
@ -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)
|
||||
|
|
|
|||
Loading…
Reference in New Issue