Skip to content

These module docs are in beta and may be incomplete.

modm:container: Containers

A container is a holder object that stores a collection other objects (its elements). They are implemented as class templates, which allows a great flexibility in the types supported as elements.

Many containers have several member functions in common, and share functionalities. The decision of which type of container to use for a specific need does not generally depend only on the functionality offered by the container, but also on the efficiency of some of its members (complexity). This is especially true for sequence containers, which offer different trade-offs in complexity between inserting/removing elements and accessing them.

modm::Stack and modm::Queue are implemented as container adapters. Container adapters are not full container classes, but classes that provide a specific interface relying on an object of one of the container classes (such as modm::BoundedDeque or modm::LinkedList) to handle the elements. The underlying container is encapsulated in such a way that its elements are accessed by the members of the container class independently of the underlying container class used.

Sequence containers:

  • modm::DynamicArray
  • modm::LinkedList
  • modm::DoublyLinkedList
  • modm::BoundedDeque

Container adapters:

  • modm::Queue
  • modm::Stack
  • modm::BoundedStack
  • modm::BoundedQueue


  • modm::SmartPointer
  • modm::Pair

Two special containers hiding in the modm:architecture:atomic module:

  • modm::atomic::Queue
  • modm::atomic::Container

The first is a simple, interrupt-safe queue (but only for the AVRs). Whenever you need to exchange data between a interrupt routine and the normal program consider using this queue.

The atomic container wraps objects and provides atomic access to them. This comes in handy when simple objects are accessed by an interrupt and the main program. The container provides secure access without much work in this case.

Generic Interface

All implementation share a common set of function. Not every container implement every one of it, only a subset which is sufficient for the container.

  • append
  • prepend
  • (insert)
  • removeFront
  • removeBack
  • (remove)
  • getFront
  • getBack

  • push (only Stack and Queue)

  • pop (only Stack and Queue)
  • get (only Stack and Queue)

  • at

  • operator[]

  • clear

  • isEmpty

  • isFull
  • getSize
  • getMaxSize
  • getCapacity


// Class
class modm::BoundedDeque::const_iterator;
class modm::BoundedDeque< typename T , std::size_t N >;
class modm::BoundedQueue< typename T , std::size_t N, typename Container =BoundedDeque<T, N> >;
class modm::BoundedStack< typename T , std::size_t N, typename Container =BoundedDeque<T, N> >;
class modm::DoublyLinkedList::const_iterator;
class modm::DoublyLinkedList::iterator;
class modm::DoublyLinkedList< typename T, typename Allocator=allocator::Dynamic<T> >;
class modm::DynamicArray::const_iterator;
class modm::DynamicArray::iterator;
class modm::DynamicArray< typename T, typename Allocator=allocator::Dynamic<T> >;
class modm::LinkedList::const_iterator;
class modm::LinkedList::iterator;
class modm::LinkedList< typename T, typename Allocator=allocator::Dynamic<T> >;
class modm::Pair< typename T1, typename T2 >;
class modm::Queue< typename T , typename Container  >;
class modm::SmartPointer;
class modm::Stack< typename T, typename Container >;
// Struct
struct modm::DoublyLinkedList::Node;
struct modm::LinkedList::Node;
// Function
modm::IOStream& modm::operator<<(modm::IOStream &s, const modm::SmartPointer &sPtr);


modm:container modm_container modm: container modm_architecture modm: architecture modm_container->modm_architecture modm_io modm: io modm_container->modm_io modm_utils modm: utils modm_container->modm_utils modm_communication_xpcc modm: communication: xpcc modm_communication_xpcc->modm_container modm_math_geometry modm: math: geometry modm_math_geometry->modm_container modm_math_interpolation modm: math: interpolation modm_math_interpolation->modm_container modm_platform_i2c modm: platform: i2c modm_platform_i2c->modm_container modm_ui_gui modm: ui: gui modm_ui_gui->modm_container modm_ui_menu modm: ui: menu modm_ui_menu->modm_container