A simple lock-based list implementation to append or erase data of type T. More...
#include <rtt/ListLocked.hpp>
Public Types | |
| typedef T | value_t |
Public Member Functions | |
| ListLocked (unsigned int lsize, unsigned int unused=0) | |
| Create a lock-based list wich can store lsize elements. | |
| size_t | capacity () const |
| size_t | size () const |
| bool | empty () const |
| void | grow (size_t items=1) |
| Grow the capacity to contain at least n additional items. | |
| void | shrink (size_t items=1) |
| Shrink the capacity with at most n items. | |
| void | reserve (size_t lsize) |
| Reserve a capacity for this list. | |
| void | clear () |
| bool | append (value_t item) |
| Append a single value to the list. | |
| value_t | front () const |
| Returns the first element of the list. | |
| value_t | back () const |
| Returns the last element of the list. | |
| size_t | append (const std::vector< T > &items) |
| Append a sequence of values to the list. | |
| bool | erase (value_t item) |
| Erase a value from the list. | |
| template<class Function > | |
| void | apply (Function func) |
| Apply a function to the elements of the whole list. | |
| template<class Function > | |
| value_t | find_if (Function func, value_t blank=value_t()) |
| Find an item in the list such that func( item ) == true. | |
A simple lock-based list implementation to append or erase data of type T.
| T | The value type to be stored in the list. Example : ListLocked is a list which holds values of type A. |
Definition at line 33 of file ListLocked.hpp.
| RTT::ListLocked< T >::ListLocked | ( | unsigned int | lsize, | |
| unsigned int | unused = 0 | |||
| ) | [inline] |
Create a lock-based list wich can store lsize elements.
| lsize | the initial capacity of the list. ' |
Definition at line 57 of file ListLocked.hpp.
| size_t RTT::ListLocked< T >::append | ( | const std::vector< T > & | items | ) | [inline] |
Append a sequence of values to the list.
| items | the values to append. |
Definition at line 175 of file ListLocked.hpp.
| bool RTT::ListLocked< T >::append | ( | value_t | item | ) | [inline] |
Append a single value to the list.
| d | the value to write |
Definition at line 143 of file ListLocked.hpp.
| void RTT::ListLocked< T >::apply | ( | Function | func | ) | [inline] |
Apply a function to the elements of the whole list.
| func | The function to apply. |
Definition at line 205 of file ListLocked.hpp.
| bool RTT::ListLocked< T >::erase | ( | value_t | item | ) | [inline] |
Erase a value from the list.
| item | is to be erased from the list. |
Definition at line 191 of file ListLocked.hpp.
| value_t RTT::ListLocked< T >::find_if | ( | Function | func, | |
| value_t | blank = value_t() | |||
| ) | [inline] |
Find an item in the list such that func( item ) == true.
| blank | The value to return if not found. |
Definition at line 219 of file ListLocked.hpp.
| void RTT::ListLocked< T >::grow | ( | size_t | items = 1 |
) | [inline] |
Grow the capacity to contain at least n additional items.
This method tries to avoid too much re-allocations, by growing a bit more than required every N invocations and growing nothing in between.
| items | The number of items to at least additionally reserve. |
Definition at line 97 of file ListLocked.hpp.
| void RTT::ListLocked< T >::reserve | ( | size_t | lsize | ) | [inline] |
Reserve a capacity for this list.
| lsize | the minimal number of items this list will be able to hold. Will not drop below the current capacity() and this method will do nothing if lsize < this->capacity(). |
Definition at line 124 of file ListLocked.hpp.
| void RTT::ListLocked< T >::shrink | ( | size_t | items = 1 |
) | [inline] |
Shrink the capacity with at most n items.
This method does not actually free memory, it just prevents a (number of) subsequent grow() invocations to allocate more memory.
| items | The number of items to at most remove from the capacity. |
Definition at line 113 of file ListLocked.hpp.
1.6.3