#include <ListLocked.hpp>
Classes | |
struct | Cont |
Public Types | |
typedef T | value_t |
Public Member Functions | |
bool | append (value_t item) |
size_t | append (const std::vector< T > &items) |
template<class Function > | |
void | apply (Function func) |
value_t | back () const |
size_t | capacity () const |
void | clear () |
template<typename Pred > | |
bool | delete_if (Pred pred) |
bool | empty () const |
bool | erase (value_t item) |
template<class Function > | |
value_t | find_if (Function func, value_t blank=value_t()) |
value_t | front () const |
void | grow (size_t items=1) |
ListLocked (unsigned int lsize, unsigned int unused=0) | |
void | reserve (size_t lsize) |
void | shrink (size_t items=1) |
size_t | size () const |
~ListLocked () | |
Private Types | |
typedef boost::intrusive::list < Cont > | BufferType |
typedef BufferType::const_iterator | CIterator |
typedef BufferType::iterator | Iterator |
typedef std::stack< Cont * > | StackType |
Private Member Functions | |
value_t & | get_data (Cont &c) |
Cont & | get_item (value_t item) |
void | give_back (Cont *cont) |
bool | is_item (value_t item, const Cont &cont) |
Private Attributes | |
os::MutexRecursive | m |
BufferType | mlist |
StackType | mreserved |
unsigned int | required |
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 72 of file ListLocked.hpp.
typedef boost::intrusive::list<Cont> RTT::internal::ListLocked< T >::BufferType [private] |
Definition at line 81 of file ListLocked.hpp.
typedef BufferType::const_iterator RTT::internal::ListLocked< T >::CIterator [private] |
Definition at line 84 of file ListLocked.hpp.
typedef BufferType::iterator RTT::internal::ListLocked< T >::Iterator [private] |
Definition at line 83 of file ListLocked.hpp.
typedef std::stack<Cont*> RTT::internal::ListLocked< T >::StackType [private] |
Definition at line 82 of file ListLocked.hpp.
typedef T RTT::internal::ListLocked< T >::value_t |
Definition at line 76 of file ListLocked.hpp.
RTT::internal::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 96 of file ListLocked.hpp.
RTT::internal::ListLocked< T >::~ListLocked | ( | ) | [inline] |
Definition at line 103 of file ListLocked.hpp.
bool RTT::internal::ListLocked< T >::append | ( | value_t | item | ) | [inline] |
Append a single value to the list.
d | the value to write |
Definition at line 182 of file ListLocked.hpp.
size_t RTT::internal::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 214 of file ListLocked.hpp.
void RTT::internal::ListLocked< T >::apply | ( | Function | func | ) | [inline] |
Apply a function to the elements of the whole list.
func | The function to apply. |
Definition at line 274 of file ListLocked.hpp.
value_t RTT::internal::ListLocked< T >::back | ( | ) | const [inline] |
Returns the last element of the list.
Definition at line 203 of file ListLocked.hpp.
size_t RTT::internal::ListLocked< T >::capacity | ( | ) | const [inline] |
Definition at line 111 of file ListLocked.hpp.
void RTT::internal::ListLocked< T >::clear | ( | ) | [inline] |
Definition at line 171 of file ListLocked.hpp.
bool RTT::internal::ListLocked< T >::delete_if | ( | Pred | pred | ) | [inline] |
Erase a value from the list.
function | each elements for which pred returns true are removed |
Definition at line 245 of file ListLocked.hpp.
bool RTT::internal::ListLocked< T >::empty | ( | ) | const [inline] |
Definition at line 123 of file ListLocked.hpp.
bool RTT::internal::ListLocked< T >::erase | ( | value_t | item | ) | [inline] |
Erase a value from the list.
item | is to be erased from the list. |
Definition at line 230 of file ListLocked.hpp.
value_t RTT::internal::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 288 of file ListLocked.hpp.
value_t RTT::internal::ListLocked< T >::front | ( | ) | const [inline] |
Returns the first element of the list.
Definition at line 194 of file ListLocked.hpp.
value_t& RTT::internal::ListLocked< T >::get_data | ( | Cont & | c | ) | [inline, private] |
Definition at line 315 of file ListLocked.hpp.
Cont& RTT::internal::ListLocked< T >::get_item | ( | value_t | item | ) | [inline, private] |
Definition at line 307 of file ListLocked.hpp.
void RTT::internal::ListLocked< T >::give_back | ( | Cont * | cont | ) | [inline, private] |
This is a dispose function for remove_and_dispose_if It takes a pointer as argument.
cont |
Definition at line 302 of file ListLocked.hpp.
void RTT::internal::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 136 of file ListLocked.hpp.
bool RTT::internal::ListLocked< T >::is_item | ( | value_t | item, |
const Cont & | cont | ||
) | [inline, private] |
This is a predicate function for remove_and_dispose_if It takes a reference as argument.
item | |
cont |
Definition at line 327 of file ListLocked.hpp.
void RTT::internal::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 163 of file ListLocked.hpp.
void RTT::internal::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 152 of file ListLocked.hpp.
size_t RTT::internal::ListLocked< T >::size | ( | ) | const [inline] |
Definition at line 117 of file ListLocked.hpp.
os::MutexRecursive RTT::internal::ListLocked< T >::m [mutable, private] |
Definition at line 90 of file ListLocked.hpp.
BufferType RTT::internal::ListLocked< T >::mlist [private] |
Definition at line 86 of file ListLocked.hpp.
StackType RTT::internal::ListLocked< T >::mreserved [private] |
Definition at line 87 of file ListLocked.hpp.
unsigned int RTT::internal::ListLocked< T >::required [private] |
Definition at line 88 of file ListLocked.hpp.