FastArduino v1.10
C++ library to build fast but small Arduino/AVR projects
|
Linked list of type T_
items.
More...
#include <fastarduino/linked_list.h>
Public Types | |
using | T = T_ |
The type of items in this list. More... | |
Public Member Functions | |
void | insert (T &item) INLINE |
Insert item at the beginning of this list. More... | |
bool | remove (T &item) INLINE |
Remove item from this list. More... | |
template<typename F > | |
void | traverse (F func) |
Traverse all items of this list and execute f functor. More... | |
Linked list of type T_
items.
This list offers 3 operations:
For the sake of SRAM size optimization, the list is not double linked.
A concrete example of LinkedList
use in FastArduino API can be found in events::Dispatcher
.
T_ | the type of items stored in the list; this must be a Link<T> . |
Definition at line 80 of file linked_list.h.
using containers::LinkedList< T_ >::T = T_ |
The type of items in this list.
Definition at line 93 of file linked_list.h.
|
inline |
Definition at line 83 of file linked_list.h.
|
inline |
Insert item
at the beginning of this list.
Note that item
is not copied by the list, only a reference is kept, thus it is caller's responsibility to ensure that item
will live at least as long as this list lives.
item | a reference to the inserted item |
Definition at line 103 of file linked_list.h.
|
inline |
Remove item
from this list.
The item is first searched in the list (from the beginning to the end), and removed if found. Note that search is based on item
reference (i.e. pointer), not content.
item | a reference of the item to remove |
true | if item was found in this list and removed |
false | if item was not found in this list |
Definition at line 118 of file linked_list.h.
|
inline |
Traverse all items of this list and execute f
functor.
F | the functor type: this type may just be a function pointer or a class overloading operator() ; in any case, it is passed a reference to a T item and must return a bool ; if it returns true for a given item, then that item will be removed from this list. |
func | the functor to execute on each item |
Definition at line 132 of file linked_list.h.