pwxlib
0.8.9
Tools Library for C++ Development
|
Template to build singly linked rings of variable types. More...
#include <pwxTSingleRing.h>
Public Types | |
typedef TSingleList< data_t, elem_t > | base_t |
Base type of the ring. | |
typedef TSingleRing< data_t, elem_t > | list_t |
Type of this ring. | |
Public Member Functions | |
TSingleRing (void(*destroy_)(data_t *data)) noexcept | |
default constructor More... | |
TSingleRing () noexcept | |
empty constructor More... | |
TSingleRing (const list_t &src) noexcept | |
copy constructor More... | |
virtual | ~TSingleRing () noexcept |
default destructor More... | |
virtual uint32_t | delNext (data_t *prev) |
delete the element after the element holding the specified data More... | |
virtual uint32_t | delNextElem (elem_t *prev) |
delete the element after the specified element More... | |
virtual uint32_t | insNext (data_t *prev, data_t *data) |
insert a new data pointer after the specified data More... | |
virtual uint32_t | insNext (data_t *prev, const elem_t &src) |
insert an element copy after the specified data More... | |
virtual uint32_t | insNextElem (elem_t *prev, data_t *data) |
insert a new data pointer after the specified element More... | |
virtual uint32_t | insNextElem (elem_t *prev, const elem_t &src) |
insert an element copy after the specified element More... | |
virtual elem_t * | pop () noexcept |
short alias for pop_front() More... | |
virtual elem_t * | pop_back () noexcept |
alias to remove the last element (tail) More... | |
virtual elem_t * | pop_front () noexcept |
alias to remove the first element (head) More... | |
virtual uint32_t | push (data_t *data) |
short alias for push_back(data_t *data) More... | |
virtual uint32_t | push (const elem_t &src) |
short alias for push_back(const elem_t &src) More... | |
virtual uint32_t | push_back (data_t *data) |
alias to add a data pointer to the end of the ring. More... | |
virtual uint32_t | push_back (const elem_t &src) |
alias to add an element copy to the end of the ring. More... | |
virtual uint32_t | push_front (data_t *data) |
alias to add a data pointer to the head of the ring. More... | |
virtual uint32_t | push_front (const elem_t &src) |
alias to add an element copy to the head of the ring. More... | |
virtual elem_t * | remNext (data_t *prev) noexcept |
remove the element after the element holding the specified data More... | |
virtual elem_t * | remNextElem (elem_t *prev) noexcept |
remove the element after the specified element More... | |
virtual list_t & | operator= (const list_t &rhs) |
assignment operator More... | |
virtual list_t & | operator+= (const list_t &rhs) |
addition assignment operator More... | |
virtual list_t & | operator-= (const list_t &rhs) |
substraction assignment operator More... | |
Template to build singly linked rings of variable types.
The singly linked ring is a singly linked list with a tail having a next pointer to head instead of being a nullptr.
The constructor takes an optional destroy(T*) function pointer that is used to destroy the data when the element is deleted. If no such function was set, the standard delete operator is used instead.
It is recommended that you use the much more advanced std::list unless you need to store a very large number of elements and can not live with the downside of every element having to be copied into the std::list.
|
inlinenoexcept |
default constructor
The default constructor initializes an empty ring.
[in] | destroy_ | A pointer to a function that is to be used to destroy the data |
|
inlinenoexcept |
empty constructor
The empty constructor uses the base constructor to set the data destroy method to the null pointer.
|
inlinenoexcept |
copy constructor
Builds a copy of all elements of src.
[in] | src | reference of the ring to copy. |
|
virtualnoexcept |
default destructor
This destructor will delete all elements currently stored. There is no need to clean up manually before deleting the list.
|
inlinevirtual |
delete the element after the element holding the specified data
This method deletes the element in the ring after the element that holds prev.
If prev is set to nullptr, the root element (aka head) is deleted.
If you intent to work with the element, use remNext instead.
If there is no element behind the element holding prev a pwx::CException with the name "OutOfRange" is thrown.
[in] | prev | the data the element that precedes the element to delete holds |
References PWX_TRY_PWX_FURTHER.
|
inlinevirtual |
delete the element after the specified element
This method deletes the element in the ring after the element prev.
If prev is set to nullptr, the root element (aka head) is deleted.
If you intent to work with the element, use remNextElem instead.
If prev is no element of this list, the wrong ring is updated and both element counts will be wrong then. So please make sure to use the correct element on the correct list!
If there is no element behind the element prev a pwx::CException with the name "OutOfRange" is thrown.
[in] | prev | the element that precedes the element to delete |
References PWX_TRY_PWX_FURTHER.
|
inlinevirtual |
insert a new data pointer after the specified data
This method inserts a new element in the ring after the element holding prev.
If prev is set to nullptr, the new element will become the new head of the list.
If the new element can not be created, a pwx::CException with the name "ElementCreationFailed" is thrown.
[in] | prev | the data the element that should precede the new element holds |
[in] | data | the pointer that is to be added. |
References PWX_TRY_PWX_FURTHER.
|
inlinevirtual |
insert an element copy after the specified data
This method inserts a new element in the ring after the element holding prev that is a copy of src.
If prev is set to nullptr, the new element will become the new head of the list.
If the new element can not be created, a pwx::CException with the name "ElementCreationFailed" is thrown.
[in] | prev | the data the element that should precede the new element holds. |
[in] | src | reference to the element to copy. |
References PWX_TRY_PWX_FURTHER.
|
inlinevirtual |
insert a new data pointer after the specified element
This method inserts a new element in the ring after the element prev.
If prev is set to nullptr, the new element will become the new head of the list.
If prev is no element of this list, the wrong ring is updated and both element counts will be wrong then. So please make sure to use the correct element on the correct list!
If the new element can not be created, a pwx::CException with the name "ElementCreationFailed" is thrown.
[in] | prev | the element that should precede the new element |
[in] | data | the pointer that is to be added. |
References PWX_TRY_PWX_FURTHER.
|
inlinevirtual |
insert an element copy after the specified element
This method inserts a new element in the ring after the element prev that is a copy of src.
If prev is set to nullptr, the new element will become the new head of the list.
If prev is no element of this list, the wrong ring is updated and both element counts will be wrong then. So please make sure to use the correct element on the correct list!
If the new element can not be created, a pwx::CException with the name "ElementCreationFailed" is thrown.
[in] | prev | the element that should precede the new element. |
[in] | src | reference of the element to copy. |
References PWX_TRY_PWX_FURTHER.
|
inlinevirtual |
addition assignment operator
Add all elements from rhs to this list.
[in] | rhs | reference of the list to add. |
References PWX_TRY_PWX_FURTHER.
|
inlinevirtual |
substraction assignment operator
Remove all elements from rhs from this list.
[in] | rhs | reference of the list to substract. |
References PWX_TRY_PWX_FURTHER.
|
inlinevirtual |
assignment operator
Clears this list and copies all elements from rhs into this list.
[in] | rhs | reference of the list to copy. |
References PWX_TRY_PWX_FURTHER.
|
inlinevirtualnoexcept |
short alias for pop_front()
You have to delete the removed element by yourself. If you do not intent to work with the removed element, use delNext instead.
If the ring is empty, nullptr is returned.
|
inlinevirtualnoexcept |
alias to remove the last element (tail)
You have to delete the removed element by yourself. If you do not intent to work with the removed element, use delNext instead.
If the ring is empty, nullptr is returned.
|
inlinevirtualnoexcept |
alias to remove the first element (head)
You have to delete the removed element by yourself. If you do not intent to work with the removed element, use delNext instead.
If the ring is empty, nullptr is returned.
|
inlinevirtual |
short alias for push_back(data_t *data)
If the new element can not be created, a pwx::CException with the name "ElementCreationFailed" is thrown.
[in] | data | the pointer that is to be added. |
References PWX_TRY_PWX_FURTHER.
|
inlinevirtual |
short alias for push_back(const elem_t &src)
If the new element can not be created, a pwx::CException with the name "ElementCreationFailed" is thrown.
[in] | src | reference to the element to copy |
References PWX_TRY_PWX_FURTHER.
|
inlinevirtual |
alias to add a data pointer to the end of the ring.
If the new element can not be created, a pwx::CException with the name "ElementCreationFailed" is thrown.
[in] | data | the pointer that is to be added. |
References PWX_TRY_PWX_FURTHER.
|
inlinevirtual |
alias to add an element copy to the end of the ring.
If the new element can not be created, a pwx::CException with the name "ElementCreationFailed" is thrown.
[in] | src | reference to the element to copy |
References PWX_TRY_PWX_FURTHER.
|
inlinevirtual |
alias to add a data pointer to the head of the ring.
If the new element can not be created, a pwx::CException with the name "ElementCreationFailed" is thrown.
[in] | data | the pointer that is to be added. |
References PWX_TRY_PWX_FURTHER.
|
inlinevirtual |
alias to add an element copy to the head of the ring.
If the new element can not be created, a pwx::CException with the name "ElementCreationFailed" is thrown.
[in] | src | reference to the element to copy |
References PWX_TRY_PWX_FURTHER.
|
inlinevirtualnoexcept |
remove the element after the element holding the specified data
This method removes the element in the ring after the element that holds prev and returns a pointer to the removed element.
If prev is set to nullptr, the root element (aka head) is removed.
You have to delete the removed element by yourself. If you do not intent to work with the removed element, use delNext instead.
If there is no element behind the element prev a nullptr is returned.
[in] | prev | the data the element that precedes the element to remove holds |
|
inlinevirtualnoexcept |
remove the element after the specified element
This method removes the element in the ring after the element prev.
If prev is set to nullptr, the root element (aka head) is removed.
If prev is no element of this list, the wrong ring is updated and both element counts will be wrong then. So please make sure to use the correct element on the correct list!
If there is no element behind the element prev or if the ring is empty, nullptr is returned.
[in] | prev | the element that precedes the element to remove |