Class intrusive_sdlist

Synopsis

#include <include/EASTL/bonus/intrusive_sdlist.h>

template <typename T = intrusive_sdlist_node>
class intrusive_sdlist : public intrusive_sdlist_base

Description

intrusive_sdlist

Mentioned in

Inheritance

Ancestors: intrusive_sdlist_base

Methods

intrusive_sdlist overloadCreates an empty list.
intrusive_sdlist overloadCreates an empty list; ignores the argument.
begin overloadReturns an iterator pointing to the first element in the list.
begin overloadReturns a const_iterator pointing to the first element in the list.
cbeginReturns a const_iterator pointing to the first element in the list.
cendReturns a const_iterator pointing one-after the last element in the list.
containsReturns true if the given element is in the list; O(n). Equivalent to (locate(x) != end()).
end overloadReturns an iterator pointing one-after the last element in the list.
end overloadReturns a const_iterator pointing one-after the last element in the list.
erase overloadErases the element pointed to by the iterator. O(1)
erase overloadErases elements within the iterator range [first, last). O(1).
front overloadReturns a reference to the first element. The list must be empty.
front overloadReturns a const reference to the first element. The list must be empty.
insertInserts an element before the element pointed to by the iterator. O(1)
locate overloadConverts a reference to an object in the list back to an iterator, or returns end() if it is not part of the list. O(n)
locate overloadConverts a const reference to an object in the list back to a const iterator, or returns end() if it is not part of the list. O(n)
operator=Clears the list; ignores the argument.
pop_backRemoves an element from the back of the list; O(N). The element must be present, but is not deallocated.
push_backAdds an element to the back of the list; O(N). The element is not copied. The element must not be in any other list.
push_frontAdds an element to the front of the list; O(1). The element is not copied. The element must not be in any other list.
removeErases an element from a list; O(1). Note that this is static so you don't need to know which list the element, although it must be in some list.
splice overloadTo do: Complete these splice functions. Might want to look at intrusive_sdlist for help.
splice overloadMoves the contents of a list into this list before the element pointed to by position; O(1)
splice overloadMoves the given element pointed to i within the list x into the current list before the element pointed to by position; O(1).
splice overloadMoves the range of elements [first, last) from list x into the current list before the element pointed to by position; O(1)
swapSwaps the contents of two intrusive lists; O(1).
validate
validate_iterator

Source

Lines 144-210 in include/EASTL/bonus/intrusive_sdlist.h.

template <typename T = intrusive_sdlist_node>
class intrusive_sdlist : public intrusive_sdlist_base
{
public:
    typedef intrusive_sdlist<T>                             this_type;
    typedef intrusive_sdlist_base                           base_type;
    typedef T                                               node_type;
    typedef T                                               value_type;
    typedef typename base_type::size_type                   size_type;
    typedef typename base_type::difference_type             difference_type;
    typedef T&                                              reference;
    typedef const T&                                        const_reference;
    typedef T*                                              pointer;
    typedef const T*                                        const_pointer;
    typedef IntrusiveSDListIterator<T, T*, T&>              iterator;
    typedef IntrusiveSDListIterator<T, const T*, const T&>  const_iterator;
    typedef eastl::reverse_iterator<iterator>               reverse_iterator;
    typedef eastl::reverse_iterator<const_iterator>         const_reverse_iterator;
public:
    intrusive_sdlist();                       ///< Creates an empty list.
    intrusive_sdlist(const this_type& x);     ///< Creates an empty list; ignores the argument.
    this_type& operator=(const this_type& x); ///< Clears the list; ignores the argument.
    iterator         begin();                 ///< Returns an iterator pointing to the first element in the list.
    const_iterator   begin() const;           ///< Returns a const_iterator pointing to the first element in the list.
    const_iterator   cbegin() const;          ///< Returns a const_iterator pointing to the first element in the list.
    iterator         end();                   ///< Returns an iterator pointing one-after the last element in the list.
    const_iterator   end() const;             ///< Returns a const_iterator pointing one-after the last element in the list.
    const_iterator   cend() const;            ///< Returns a const_iterator pointing one-after the last element in the list.
    reference        front();                 ///< Returns a reference to the first element. The list must be empty.
    const_reference  front() const;           ///< Returns a const reference to the first element. The list must be empty.
    void             push_front(value_type& value);                  ///< Adds an element to the front of the list; O(1). The element is not copied. The element must not be in any other list.
    void             push_back(value_type& value);                   ///< Adds an element to the back of the list; O(N). The element is not copied. The element must not be in any other list.
    void             pop_back();                                     ///< Removes an element from the back of the list; O(N). The element must be present, but is not deallocated.
    bool             contains(const value_type& value) const;        ///< Returns true if the given element is in the list; O(n). Equivalent to (locate(x) != end()).
    iterator         locate(value_type& value);                      ///< Converts a reference to an object in the list back to an iterator, or returns end() if it is not part of the list. O(n)
    const_iterator   locate(const value_type& value) const;          ///< Converts a const reference to an object in the list back to a const iterator, or returns end() if it is not part of the list. O(n)
    iterator         insert(iterator position, value_type& value);   ///< Inserts an element before the element pointed to by the iterator. O(1)
    iterator         erase(iterator position);                       ///< Erases the element pointed to by the iterator. O(1)
    iterator         erase(iterator first, iterator last);           ///< Erases elements within the iterator range [first, last). O(1).
    void             swap(intrusive_sdlist& x);                      ///< Swaps the contents of two intrusive lists; O(1).
    static void      remove(value_type& value);                      ///< Erases an element from a list; O(1). Note that this is static so you don't need to know which list the element, although it must be in some list.
    void  splice(iterator position, value_type& value);              ///< Moves the given element into this list before the element pointed to by position; O(1).
                                                                     ///< Required: x must be in some list or have first/next pointers that point it itself.
    void  splice(iterator position, this_type& x);                   ///< Moves the contents of a list into this list before the element pointed to by position; O(1).
                                                                     ///< Required: &x != this (same as std::list).
    void  splice(iterator position, this_type& x, iterator xPosition);      ///< Moves the given element pointed to i within the list x into the current list before
                                                                            ///< the element pointed to by position; O(1).
    void  splice(iterator position, this_type& x, iterator first, iterator last);   ///< Moves the range of elements [first, last) from list x into the current list before
                                                                                    ///< the element pointed to by position; O(1).
                                                                                    ///< Required: position must not be in [first, last). (same as std::list).
    bool validate() const;
    int  validate_iterator(const_iterator i) const;
}; // intrusive_sdlist





Add Discussion as Guest

Log in