This is an old version of the documentation. View the latest version here.
Control Surface  1.0.0
MIDI Control Surface library for Arduino
Classes | Public Types | Public Member Functions | Private Attributes | List of all members
DoublyLinkedList< Node > Class Template Reference

A class for doubly linked lists. More...

#include <LinkedList.hpp>

Collaboration diagram for DoublyLinkedList< Node >:

Classes

class  node_iterator
 Forward bidirectional doubly linked list iterator. More...
 
class  node_iterator_base
 Base class for doubly linked list iterators. More...
 
class  reverse_node_iterator
 Reverse bidirectional doubly linked list iterator. More...
 

Public Types

using iterator = node_iterator< Node >
 
using const_iterator = node_iterator< const Node >
 
using reverse_iterator = reverse_node_iterator< Node >
 
using const_reverse_iterator = reverse_node_iterator< const Node >
 

Public Member Functions

void append (Node *node)
 Append a node to a linked list. More...
 
void append (Node &node)
 Append a node to a linked list. More...
 
void insertBefore (Node *toBeInserted, Node *before)
 Insert a node before another node. More...
 
void insertBefore (Node &toBeInserted, Node &before)
 
template<class Compare >
void insertSorted (Node *node, Compare cmp)
 Insert a new node at the correct location into a sorted list. More...
 
void insertSorted (Node *node)
 Insert a new node at the correct location into a sorted list, using operator<. More...
 
void remove (Node *node)
 Remove a node from the linked list. More...
 
void remove (Node &node)
 Remove a node from the linked list. More...
 
void moveDown (Node *node)
 Move down the given node in the linked list. More...
 
bool couldContain (Node *node)
 Check if the linked list could contain the given node. More...
 
iterator begin ()
 
iterator end ()
 
const_iterator begin () const
 
const_iterator end () const
 
reverse_iterator rbegin ()
 
reverse_iterator rend ()
 
const_reverse_iterator rbegin () const
 
const_reverse_iterator rend () const
 
Node * getFirst () const
 Get a pointer to the first node. More...
 
Node * getLast () const
 Get a pointer to the last node. More...
 

Private Attributes

Node * first = nullptr
 
Node * last = nullptr
 

Detailed Description

template<class Node>
class DoublyLinkedList< Node >

A class for doubly linked lists.

Template Parameters
NodeThe type of the nodes of the list.

Definition at line 23 of file LinkedList.hpp.

Member Typedef Documentation

◆ iterator

template<class Node>
using DoublyLinkedList< Node >::iterator = node_iterator<Node>

Definition at line 102 of file LinkedList.hpp.

◆ const_iterator

template<class Node>
using DoublyLinkedList< Node >::const_iterator = node_iterator<const Node>

Definition at line 103 of file LinkedList.hpp.

◆ reverse_iterator

template<class Node>
using DoublyLinkedList< Node >::reverse_iterator = reverse_node_iterator<Node>

Definition at line 104 of file LinkedList.hpp.

◆ const_reverse_iterator

template<class Node>
using DoublyLinkedList< Node >::const_reverse_iterator = reverse_node_iterator<const Node>

Definition at line 105 of file LinkedList.hpp.

Member Function Documentation

◆ append() [1/2]

template<class Node>
void DoublyLinkedList< Node >::append ( Node *  node)
inline

Append a node to a linked list.

Parameters
nodeA pointer to the node to be appended.

Definition at line 113 of file LinkedList.hpp.

◆ append() [2/2]

template<class Node>
void DoublyLinkedList< Node >::append ( Node &  node)
inline

Append a node to a linked list.

Parameters
nodeA reference to the node to be appended.

Definition at line 129 of file LinkedList.hpp.

◆ insertBefore() [1/2]

template<class Node>
void DoublyLinkedList< Node >::insertBefore ( Node *  toBeInserted,
Node *  before 
)
inline

Insert a node before another node.

Parameters
toBeInsertedThe new node to be inserted.
beforeThe node to insert the new node before. It must be in the list already.

Definition at line 140 of file LinkedList.hpp.

◆ insertBefore() [2/2]

template<class Node>
void DoublyLinkedList< Node >::insertBefore ( Node &  toBeInserted,
Node &  before 
)
inline
See also
insertBefore(Node *, Node *)

Definition at line 151 of file LinkedList.hpp.

◆ insertSorted() [1/2]

template<class Node>
template<class Compare >
void DoublyLinkedList< Node >::insertSorted ( Node *  node,
Compare  cmp 
)
inline

Insert a new node at the correct location into a sorted list.

Parameters
nodeThe new node to be inserted.
cmpThe function to order the nodes.
Template Parameters
CompareA functor that compares two Nodes and returns a boolean.

Definition at line 166 of file LinkedList.hpp.

◆ insertSorted() [2/2]

template<class Node>
void DoublyLinkedList< Node >::insertSorted ( Node *  node)
inline

Insert a new node at the correct location into a sorted list, using operator<.

Parameters
nodeThe new node to be inserted.

Definition at line 186 of file LinkedList.hpp.

◆ remove() [1/2]

template<class Node>
void DoublyLinkedList< Node >::remove ( Node *  node)
inline

Remove a node from the linked list.

Parameters
nodeA pointer to the node to be removed.

Definition at line 196 of file LinkedList.hpp.

◆ remove() [2/2]

template<class Node>
void DoublyLinkedList< Node >::remove ( Node &  node)
inline

Remove a node from the linked list.

Parameters
nodeA reference to the node to be removed.

Definition at line 215 of file LinkedList.hpp.

◆ moveDown()

template<class Node>
void DoublyLinkedList< Node >::moveDown ( Node *  node)
inline

Move down the given node in the linked list.

For example: moving down node C:

Before: ... → ABCD → ...
After: ... → ACBD → ...
Parameters
nodeA pointer to the node to be moved down.

Definition at line 228 of file LinkedList.hpp.

◆ couldContain()

template<class Node>
bool DoublyLinkedList< Node >::couldContain ( Node *  node)
inline

Check if the linked list could contain the given node.

Return values
trueThe given node is part of some linked list or it is the first node of the given linked list.
It could be that the node is part of a different linked list if it was ever added to a different list. However, if this function returns true and the node was never added to another linked list, it means that this linked list contains the given node.
falseThe given node is not part of any linked list, or it is the only element of a different linked list.

Definition at line 264 of file LinkedList.hpp.

◆ begin() [1/2]

template<class Node>
iterator DoublyLinkedList< Node >::begin ( )
inline

Definition at line 269 of file LinkedList.hpp.

◆ end() [1/2]

template<class Node>
iterator DoublyLinkedList< Node >::end ( )
inline

Definition at line 270 of file LinkedList.hpp.

◆ begin() [2/2]

template<class Node>
const_iterator DoublyLinkedList< Node >::begin ( ) const
inline

Definition at line 272 of file LinkedList.hpp.

◆ end() [2/2]

template<class Node>
const_iterator DoublyLinkedList< Node >::end ( ) const
inline

Definition at line 273 of file LinkedList.hpp.

◆ rbegin() [1/2]

template<class Node>
reverse_iterator DoublyLinkedList< Node >::rbegin ( )
inline

Definition at line 275 of file LinkedList.hpp.

◆ rend() [1/2]

template<class Node>
reverse_iterator DoublyLinkedList< Node >::rend ( )
inline

Definition at line 276 of file LinkedList.hpp.

◆ rbegin() [2/2]

template<class Node>
const_reverse_iterator DoublyLinkedList< Node >::rbegin ( ) const
inline

Definition at line 278 of file LinkedList.hpp.

◆ rend() [2/2]

template<class Node>
const_reverse_iterator DoublyLinkedList< Node >::rend ( ) const
inline

Definition at line 279 of file LinkedList.hpp.

◆ getFirst()

template<class Node>
Node* DoublyLinkedList< Node >::getFirst ( ) const
inline

Get a pointer to the first node.

Definition at line 282 of file LinkedList.hpp.

◆ getLast()

template<class Node>
Node* DoublyLinkedList< Node >::getLast ( ) const
inline

Get a pointer to the last node.

Definition at line 284 of file LinkedList.hpp.

Member Data Documentation

◆ first

template<class Node>
Node* DoublyLinkedList< Node >::first = nullptr
private

Definition at line 287 of file LinkedList.hpp.

◆ last

template<class Node>
Node* DoublyLinkedList< Node >::last = nullptr
private

Definition at line 288 of file LinkedList.hpp.


The documentation for this class was generated from the following file:
MIDI_Notes::A
constexpr int8_t A
Definition: Notes.hpp:27
MIDI_Notes::D
constexpr int8_t D
Definition: Notes.hpp:20
MIDI_Notes::B
constexpr int8_t B
Definition: Notes.hpp:29
MIDI_Notes::C
constexpr int8_t C
Definition: Notes.hpp:18