7 #ifndef JLM_UTIL_INTRUSIVE_LIST_HPP
8 #define JLM_UTIL_INTRUSIVE_LIST_HPP
88 template<
typename ElementType,
typename Accessor>
92 static_assert(noexcept(Accessor().get_prev(
nullptr)),
"require noexcept get_prev");
93 static_assert(noexcept(Accessor().get_next(
nullptr)),
"require noexcept get_next");
94 static_assert(noexcept(Accessor().set_prev(
nullptr,
nullptr)),
"require noexcept set_prev");
95 static_assert(noexcept(Accessor().set_next(
nullptr,
nullptr)),
"require noexcept set_next");
204 :
list_(other.list_),
255 inline const ElementType &
261 inline const ElementType *
279 inline const ElementType *
319 std::swap(
first_, other.first_);
320 std::swap(
last_, other.last_);
358 ElementType * next = i.
ptr();
382 erase(ElementType * element) noexcept
384 ElementType * prev =
accessor_.get_prev(element);
385 ElementType * next =
accessor_.get_next(element);
407 auto element = i.
ptr();
418 ElementType * element =
begin.
ptr();
427 splice(position, other, other.begin(), other.end());
435 splice(position, other, i, j);
448 ElementType * after =
end.
ptr();
449 ElementType *
last = after ?
accessor_.get_prev(after) : other.last_;
458 other.first_ = after;
466 other.last_ = before;
470 ElementType * dst_next = position.ptr();
471 ElementType * dst_prev = dst_next ?
accessor_.get_prev(dst_next) :
last_;
549 return iterator(
this, element);
556 return const_iterator(
this, element);
578 template<
typename ElementType>
586 template<
typename ElementType, IntrusiveListAnchor<ElementType> ElementType::*anchor_member>
591 get_prev(
const ElementType * element)
const noexcept
593 return (element->*anchor_member).prev;
597 set_prev(ElementType * element, ElementType * prev)
const noexcept
599 (element->*anchor_member).prev = prev;
603 get_next(
const ElementType * element)
const noexcept
605 return (element->*anchor_member).next;
609 set_next(ElementType * element, ElementType * next)
const noexcept
611 (element->*anchor_member).next = next;
615 template<
typename ElementType,
typename Accessor>
622 noexcept(std::declval<ElementType &>().~ElementType()),
623 "Require noexcept destructor for ElementType");
652 ElementType * element =
begin().
ptr();
665 push_back(std::unique_ptr<ElementType> element) noexcept
682 inline std::unique_ptr<ElementType>
685 ElementType * element = i.ptr();
687 return std::unique_ptr<ElementType>(element);
691 erase(ElementType * element) noexcept
707 ElementType * element =
begin.
ptr();
716 splice(position, other, other.begin(), other.end());
724 splice(position, other, i, j);
ElementType * get_prev(const ElementType *element) const noexcept
ElementType * get_next(const ElementType *element) const noexcept
void set_next(ElementType *element, ElementType *next) const noexcept
void set_prev(ElementType *element, ElementType *prev) const noexcept
const ElementType & reference
bool operator!=(const ConstIterator &other) const noexcept
constexpr ConstIterator() noexcept
std::bidirectional_iterator_tag iterator_category
ConstIterator operator++(int) noexcept
ConstIterator operator--(int) noexcept
const IntrusiveList * list_
const ElementType * ptr() const noexcept
const ElementType & operator*() const noexcept
const ElementType * operator->() const noexcept
const ElementType * pointer
constexpr ConstIterator(const Iterator &other) noexcept
const ConstIterator & operator--() noexcept
const ConstIterator & operator++() noexcept
constexpr ConstIterator(const IntrusiveList *list, const ElementType *object)
constexpr ConstIterator(const ConstIterator &other) noexcept=default
bool operator==(const ConstIterator &other) const noexcept
const ElementType value_type
const ElementType * element_
ElementType * ptr() const noexcept
bool operator==(const Iterator &other) const noexcept
constexpr Iterator(const IntrusiveList *list, ElementType *object)
const IntrusiveList * list_
ElementType * operator->() const noexcept
Iterator operator++(int) noexcept
Iterator operator--(int) noexcept
constexpr Iterator() noexcept
const Iterator & operator--() noexcept
const Iterator & operator++() noexcept
ElementType & operator*() const noexcept
std::bidirectional_iterator_tag iterator_category
bool operator!=(const Iterator &other) const noexcept
IntrusiveList(IntrusiveList &&other) noexcept
bool empty() const noexcept
ConstIterator end() const noexcept
void erase(ElementType *element) noexcept
void splice(Iterator position, IntrusiveList &other) noexcept
size_type size() const noexcept
ConstIterator cend() const noexcept
void swap(IntrusiveList &other) noexcept
ConstIterator cbegin() const noexcept
ElementType * last() const noexcept
void push_front(ElementType *element) noexcept
ConstIterator make_element_iterator(const ElementType *element) const noexcept
IntrusiveList(const IntrusiveList &other)=delete
Iterator insert(Iterator i, ElementType *element) noexcept
void erase(Iterator begin, Iterator end) noexcept
void splice(Iterator position, IntrusiveList &other, Iterator i) noexcept
void operator=(const IntrusiveList &other)=delete
Iterator erase(Iterator i) noexcept
void splice(Iterator position, IntrusiveList &other, Iterator begin, Iterator end) noexcept
ConstIterator begin() const noexcept
Iterator begin() noexcept
Iterator make_element_iterator(ElementType *element) const noexcept
ElementType * first() const noexcept
constexpr IntrusiveList() noexcept
void push_back(ElementType *element) noexcept
Iterator begin() noexcept
OwnerIntrusiveList(OwnerIntrusiveList &&other) noexcept
void splice(Iterator position, OwnerIntrusiveList &other) noexcept
void swap(OwnerIntrusiveList &other) noexcept
void splice(Iterator position, OwnerIntrusiveList &other, Iterator i) noexcept
internal_list_type internal_list_
internal_list_type::ConstIterator ConstIterator
internal_list_type::size_type size_type
std::unique_ptr< ElementType > unlink(Iterator i) noexcept
ConstIterator make_element_iterator(const ElementType *element) const noexcept
ConstIterator cend() const noexcept
internal_list_type::value_type value_type
void erase(ElementType *element) noexcept
ConstIterator end() const noexcept
bool empty() const noexcept
OwnerIntrusiveList(const OwnerIntrusiveList &other)=delete
Iterator insert(Iterator i, std::unique_ptr< ElementType > element) noexcept
ConstIterator cbegin() const noexcept
void push_back(std::unique_ptr< ElementType > element) noexcept
void erase(Iterator begin, Iterator end) noexcept
size_type size() const noexcept
void splice(Iterator position, OwnerIntrusiveList &other, Iterator begin, Iterator end) noexcept
internal_list_type::Iterator Iterator
void operator=(const OwnerIntrusiveList &other)=delete
void erase(Iterator i) noexcept
Iterator make_element_iterator(ElementType *element) const noexcept
void push_front(std::unique_ptr< ElementType > element) noexcept
IntrusiveList< ElementType, Accessor > internal_list_type
~OwnerIntrusiveList() noexcept
ConstIterator begin() const noexcept