modm API documentation
modm::LinkedList< T, Allocator > Class Template Reference

Singly-linked list. More...

#include <modm/container/linked_list.hpp>

Classes

struct  Node
 
class  const_iterator
 Forward const iterator More...
 
class  iterator
 Forward iterator More...
 

Public Typedefs

typedef std::size_t Size
 

Public Member Functions

 LinkedList (const Allocator &allocator=Allocator ())
 
bool isEmpty () const
 check if there are any nodes in the list
 
std::size_t getSize () const
 Get number of elements. More...
 
bool prepend (const T &value)
 Insert in front.
 
bool append (const T &value)
 Insert at the end of the list.
 
void removeFront ()
 Remove the first entry.
 
const T & getFront () const
 
T & getFront ()
 
const T & getBack () const
 
T & getBack ()
 
void removeAll ()
 Remove all elements form the list.
 
iterator begin ()
 
const_iterator begin () const
 
iterator end ()
 
const_iterator end () const
 
iterator remove (const iterator &position)
 Erase element. More...
 
bool insert (const_iterator pos, const T &value)
 

Protected Typedefs

typedef Allocator::template rebind< Node >::other NodeAllocator
 

Protected Attributes

NodeAllocator nodeAllocator
 
Nodefront
 
Nodeback
 

Friends

class const_iterator
 
class iterator
 

Detailed Description

template<typename T, typename Allocator = allocator::Dynamic<T>>
class modm::LinkedList< T, Allocator >

Singly-linked list.

Template Parameters
TType of list entries
AllocatorAllocator used for memory allocation. See classes from modm::allocator namespace.
Author
Fabian Greif

Member Function Documentation

template<typename T , typename Allocator = allocator::Dynamic<T>>
iterator modm::LinkedList< T, Allocator >::begin ( )

Returns a read/write iterator that points to the first element in the list. Iteration is done in ordinary element order.

template<typename T , typename Allocator = allocator::Dynamic<T>>
const_iterator modm::LinkedList< T, Allocator >::begin ( ) const

Returns a read-only (constant) iterator that points to the first element in the list. Iteration is done in ordinary element order.

template<typename T , typename Allocator = allocator::Dynamic<T>>
iterator modm::LinkedList< T, Allocator >::end ( )

Returns a read/write iterator that points one past the last element in the list. Iteration is done in ordinary element order.

template<typename T , typename Allocator = allocator::Dynamic<T>>
const_iterator modm::LinkedList< T, Allocator >::end ( ) const

Returns a read-only (constant) iterator that points one past the last element in the list. Iteration is done in ordinary element order.

template<typename T , typename Allocator = allocator::Dynamic<T>>
const T& modm::LinkedList< T, Allocator >::getBack ( ) const
inline
Returns
the last node in the list
template<typename T , typename Allocator = allocator::Dynamic<T>>
const T& modm::LinkedList< T, Allocator >::getFront ( ) const
inline
Returns
the first node in the list
template<typename T , typename Allocator = allocator::Dynamic<T>>
std::size_t modm::LinkedList< T, Allocator >::getSize ( ) const

Get number of elements.

Warning
This method is slow because it has to iterate through all elements.
template<typename T , typename Allocator = allocator::Dynamic<T>>
iterator modm::LinkedList< T, Allocator >::remove ( const iterator position)

Erase element.

Removes a single element from the list container. This effectively reduces the list size by one, calling the element's destructor before.


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