'ODTONE - Open Dot Twenty One'

PrevUpHomeNext

Class list_node

odtone::list_node

Synopsis

// 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;
};

Description

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 functions

  1. void init();

    Initialize the double linked list with a single element.

  2. void push_front(list_node * node);

    Insert a new element in the first position of the double linked list.

    Parameters:

    node

    The element to insert in the double linked list.

  3. void push_back(list_node * node);

    Insert a new element in the last position of the double linked list.

    Parameters:

    node

    The element to insert in the double linked list.

  4. list_node * pop_front();

    Remove and return the first element of the double linked list.

    Returns:

    The first element of the double linked list.

  5. list_node * pop_back();

    Remove and return the last element of the double linked list.

    Returns:

    The last element of the double linked list.

  6. list_node * front();

    Return the first element of the double linked list without removing it.

    Returns:

    The first element of the double linked list.

  7. list_node * back();

    Return the last element of the double linked list without removing it.

    Returns:

    The last element of the double linked list.

  8. 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.

  9. 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.

  10. void swap(list_node & y);

    Swap the position of two elements of the double linked list.

    Parameters:

    y

    The element with which will exchange the position.

  11. 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.

  12. void remove();

    Remove an element from the double linked list.

  13. 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.


PrevUpHomeNext