odtone::list_node
// In header: </home/carlos/Projectos/odtone/inc/odtone/list_node.hpp> class list_node { public: // public member functions void init(); void push_front(list_node *); void push_back(list_node *); list_node * pop_front(); list_node * pop_back(); list_node * front(); list_node * back(); const list_node * front() const; const list_node * back() const; void swap(list_node &); void reverse(); void remove(); bool empty() const; };
Double linked list, which provides operations to add or remove elements, to get and swap elements and to reverse the elements order. Each node contains, besides the next-node link, a second link field pointing to the previous node in the sequence.
list_node
public member functionsvoid init();
Initialize the double linked list with a single element.
void push_front(list_node * node);
Insert a new element in the first position of the double linked list.
Parameters: |
|
void push_back(list_node * node);
Insert a new element in the last position of the double linked list.
Parameters: |
|
list_node * pop_front();
Remove and return the first element of the double linked list.
Returns: |
The first element of the double linked list. |
list_node * pop_back();
Remove and return the last element of the double linked list.
Returns: |
The last element of the double linked list. |
list_node * front();
Return the first element of the double linked list without removing it.
Returns: |
The first element of the double linked list. |
list_node * back();
Return the last element of the double linked list without removing it.
Returns: |
The last element of the double linked list. |
const list_node * front() const;
Return the first element of the double linked list without removing it.
Returns: |
The first element of the double linked list. |
const list_node * back() const;
Return the last element of the double linked list without removing it.
Returns: |
The last element of the double linked list without removing it. |
void swap(list_node & y);
Swap the position of two elements of the double linked list.
Parameters: |
|
void reverse();
Reverse the element order in the double linked list. In other words, it exchange the previous element with the next element of the checkpoint that calls this method.
void remove();
Remove an element from the double linked list.
bool empty() const;
Check if the element is the single one in the double linked list.
Returns: |
True if the element is the single one in the double linked list or false otherwise. |