Horizon Official Technical Documentation
Horizon::Structures::LinkedList::Element Class Reference

This class is used to manage a linked list of Elements. It is not intended to be used directly. It is used as a base class for other classes that need to manage a linked list. The Head class is a friend of this class to allow it to access the private members of this class. More...

#include <Element.hpp>

+ Inheritance diagram for Horizon::Structures::LinkedList::Element:
+ Collaboration diagram for Horizon::Structures::LinkedList::Element:

Public Member Functions

 Element ()
 
bool has_next () const
 Returns true if this Element has a next Element in the list. More...
 
bool has_prev () const
 Returns true if this Element has a previous Element in the list. More...
 
bool is_in_list () const
 Returns true if this Element is in a list. More...
 
Elementnext ()
 Returns the next Element in the list. More...
 
Element const * next () const
 
Elementprev ()
 Returns the previous Element in the list. More...
 
Element const * prev () const
 
Elementnocheck_next ()
 Returns the next Element in the list without checking if it exists. More...
 
Element const * nocheck_next () const
 
Elementnocheck_prev ()
 Returns the previous Element in the list without checking if it exists. More...
 
Element const * nocheck_prev () const
 
void delink ()
 Removes this Element from the list. More...
 
void push_before (Element *pElem)
 Pushes this Element before the given Element. More...
 
void push_after (Element *pElem)
 Pushes this Element after the given Element. More...
 

Protected Member Functions

 ~Element ()
 

Private Member Functions

 Element (Element const &)=delete
 
Elementoperator= (Element const &)=delete
 

Private Attributes

Element_next
 
Element_prev
 

Friends

class Head
 

Detailed Description

This class is used to manage a linked list of Elements. It is not intended to be used directly. It is used as a base class for other classes that need to manage a linked list. The Head class is a friend of this class to allow it to access the private members of this class.

Parameters
_nextThe next Element in the list.
_prevThe previous Element in the list.

Constructor & Destructor Documentation

◆ Element() [1/2]

Horizon::Structures::LinkedList::Element::Element ( )
inline
26: _next(nullptr), _prev(nullptr) { }
Element * _next
Definition: Element.hpp:22
Element * _prev
Definition: Element.hpp:23

◆ Element() [2/2]

Horizon::Structures::LinkedList::Element::Element ( Element const &  )
privatedelete

◆ ~Element()

Horizon::Structures::LinkedList::Element::~Element ( )
inlineprotected
92 {
93 delink();
94 }
void delink()
Removes this Element from the list.
Definition: Element.hpp:50

References delink().

+ Here is the call graph for this function:

Member Function Documentation

◆ delink()

void Horizon::Structures::LinkedList::Element::delink ( )
inline

Removes this Element from the list.

51 {
52 if (!is_in_list())
53 return;
54
55 _next->_prev = _prev;
56 _prev->_next = _next;
57 _next = nullptr;
58 _prev = nullptr;
59 }
bool is_in_list() const
Returns true if this Element is in a list.
Definition: Element.hpp:33

References _next, _prev, and is_in_list().

Referenced by Horizon::Structures::LinkedList::Reference< TO, FROM >::invalidate(), Horizon::Structures::LinkedList::Reference< TO, FROM >::remove(), and ~Element().

+ Here is the call graph for this function:
+ Here is the caller graph for this function:

◆ has_next()

bool Horizon::Structures::LinkedList::Element::has_next ( ) const
inline

Returns true if this Element has a next Element in the list.

29{ return (_next && _next->_next != nullptr); }

References _next.

Referenced by next().

+ Here is the caller graph for this function:

◆ has_prev()

bool Horizon::Structures::LinkedList::Element::has_prev ( ) const
inline

Returns true if this Element has a previous Element in the list.

31{ return (_prev && _prev->_prev != nullptr); }

References _prev.

Referenced by prev().

+ Here is the caller graph for this function:

◆ is_in_list()

bool Horizon::Structures::LinkedList::Element::is_in_list ( ) const
inline

Returns true if this Element is in a list.

33{ return (_next != nullptr && _prev != nullptr); }

References _next, and _prev.

Referenced by delink().

+ Here is the caller graph for this function:

◆ next() [1/2]

Element * Horizon::Structures::LinkedList::Element::next ( )
inline

Returns the next Element in the list.

36{ return has_next() ? _next : nullptr; }
bool has_next() const
Returns true if this Element has a next Element in the list.
Definition: Element.hpp:29

References _next, and has_next().

Referenced by BOOST_AUTO_TEST_CASE(), Horizon::Structures::LinkedList::Head::get_size(), and Horizon::Structures::LinkedList::Reference< TO, FROM >::next().

+ Here is the call graph for this function:
+ Here is the caller graph for this function:

◆ next() [2/2]

Element const * Horizon::Structures::LinkedList::Element::next ( ) const
inline
37{ return has_next() ? _next : nullptr; }

References _next, and has_next().

+ Here is the call graph for this function:

◆ nocheck_next() [1/2]

Element * Horizon::Structures::LinkedList::Element::nocheck_next ( )
inline

Returns the next Element in the list without checking if it exists.

43{ return _next; }

References _next.

Referenced by Horizon::Structures::LinkedList::Reference< TO, FROM >::nocheck_next().

+ Here is the caller graph for this function:

◆ nocheck_next() [2/2]

Element const * Horizon::Structures::LinkedList::Element::nocheck_next ( ) const
inline
44{ return _next; }

References _next.

◆ nocheck_prev() [1/2]

Element * Horizon::Structures::LinkedList::Element::nocheck_prev ( )
inline

Returns the previous Element in the list without checking if it exists.

46{ return _prev; }

References _prev.

Referenced by Horizon::Structures::LinkedList::Reference< TO, FROM >::nocheck_prev().

+ Here is the caller graph for this function:

◆ nocheck_prev() [2/2]

Element const * Horizon::Structures::LinkedList::Element::nocheck_prev ( ) const
inline
47{ return _prev; }

References _prev.

◆ operator=()

Element & Horizon::Structures::LinkedList::Element::operator= ( Element const &  )
privatedelete

◆ prev() [1/2]

Element * Horizon::Structures::LinkedList::Element::prev ( )
inline

Returns the previous Element in the list.

39{ return has_prev() ? _prev : nullptr; }
bool has_prev() const
Returns true if this Element has a previous Element in the list.
Definition: Element.hpp:31

References _prev, and has_prev().

Referenced by Horizon::Structures::LinkedList::Reference< TO, FROM >::prev().

+ Here is the call graph for this function:
+ Here is the caller graph for this function:

◆ prev() [2/2]

Element const * Horizon::Structures::LinkedList::Element::prev ( ) const
inline
40{ return has_prev() ? _prev : nullptr; }

References _prev, and has_prev().

+ Here is the call graph for this function:

◆ push_after()

void Horizon::Structures::LinkedList::Element::push_after ( Element pElem)
inline

Pushes this Element after the given Element.

Parameters
pElemThe Element to push this Element after.
Note
This Element must not be in a list.
76 {
77 pElem->_prev = this;
78 pElem->_next = _next;
79 _next->_prev = pElem;
80 _next = pElem;
81 }

References _next, and _prev.

Referenced by Horizon::Structures::LinkedList::Head::push_front().

+ Here is the caller graph for this function:

◆ push_before()

void Horizon::Structures::LinkedList::Element::push_before ( Element pElem)
inline

Pushes this Element before the given Element.

Parameters
pElemThe Element to push this Element before.
Note
This Element must not be in a list.
65 {
66 pElem->_next = this;
67 pElem->_prev = _prev;
68 _prev->_next = pElem;
69 _prev = pElem;
70 }

References _next, and _prev.

Referenced by Horizon::Structures::LinkedList::Head::push_back().

+ Here is the caller graph for this function:

Friends And Related Function Documentation

◆ Head

friend class Head
friend

Member Data Documentation

◆ _next

◆ _prev


The documentation for this class was generated from the following file: