25 #ifndef WSHAREDSEQUENCECONTAINER_H
26 #define WSHAREDSEQUENCECONTAINER_H
30 #include <boost/thread.hpp>
32 #include "WSharedObject.h"
38 template <
typename S >
152 typename S::value_type&
at(
size_t n );
162 const typename S::value_type&
at(
size_t n )
const;
170 void remove(
const typename S::value_type& element );
199 void replace(
const typename S::value_type& oldValue,
const typename S::value_type& newValue );
217 template <
typename Comparator >
227 template <
typename Comparator >
237 template <
typename Comparator >
247 template <
typename Comparator >
261 const typename S::value_type& value );
276 template <
typename S >
283 template <
typename S >
289 template <
typename S >
294 a->get().push_back( x );
297 template <
typename S >
302 a->get().insert( a->get().begin(), x );
305 template <
typename S >
310 if( it == a->get().end() )
313 a->get().push_back( x );
317 template <
typename S >
322 if( it == a->get().end() )
325 a->get().insert( a->get().begin(), x );
329 template <
typename S >
337 template <
typename S >
345 template <
typename S >
350 size_t size = a->get().size();
354 template <
typename S >
358 return const_cast< S&
>( a->get() ).
operator[]( n );
362 template <
typename S >
366 return a->get().operator[]( n );
369 template <
typename S >
373 return const_cast< S&
>( a->get() ).at( n );
377 template <
typename S >
381 return a->get().at( n );
384 template <
typename S >
389 a->get().erase( std::remove( a->get().begin(), a->get().end(), element ), a->get().end() );
392 template <
typename S >
397 return a->get().erase( position );
400 template <
typename S >
407 return a->get().erase( first, last );
410 template <
typename S >
414 std::replace( a->get().begin(), a->get().end(), oldValue, newValue );
417 template <
typename S >
421 return std::count( a->get().begin(), a->get().end(), value );
424 template <
typename S >
425 template <
typename Comparator >
429 return std::sort( a->get().begin(), a->get().end(), comp );
432 template <
typename S >
433 template <
typename Comparator >
438 return std::sort( first, last, comp );
441 template <
typename S >
442 template <
typename Comparator >
446 return std::stable_sort( a->get().begin(), a->get().end(), comp );
449 template <
typename S >
450 template <
typename Comparator >
455 return std::stable_sort( first, last, comp );
458 template <
typename S >
462 const typename S::value_type& value )
464 return std::find( first, last, value );
467 template <
typename S >
471 return std::find( a->get().begin(), a->get().end(), value );
Wrapper around an object/type for thread safe sharing of objects among multiple threads.
ReadTicket getReadTicket() const
Returns a ticket to get read access to the contained data.
WriteTicket getWriteTicket(bool suppressNotify=false) const
Returns a ticket to get write access to the contained data.
This class provides a common interface for thread-safe access to sequence containers (list,...
WSharedSequenceContainer()
Default constructor.
size_t size() const
The size of the container.
WSharedSequenceContainer< S >::Iterator erase(typename WSharedSequenceContainer< S >::Iterator first, typename WSharedSequenceContainer< S >::Iterator last)
Erase the specified range of elements.
void remove(const typename S::value_type &element)
Searches and removes the specified element.
void unique_push_back(const typename S::value_type &x)
Add the element only if it is not inside the container until now.
const S::value_type & operator[](size_t n) const
Get item at position n.
void sort(typename WSharedSequenceContainer< S >::Iterator first, typename WSharedSequenceContainer< S >::Iterator last, Comparator comp)
Resorts the container using the specified comparator between [first,last) in ascending order.
void pop_back()
Removes an element from the end.
void sort(Comparator comp)
Resorts the container using the specified comparator from its begin to its end.
S::value_type value_type
The type of the elements.
void push_front(const typename S::value_type &x)
Adds a new element at the beginning of the container.
void clear()
Clears the container.
virtual ~WSharedSequenceContainer()
Destructor.
WSharedSequenceContainer< S >::Iterator find(typename WSharedSequenceContainer< S >::Iterator first, typename WSharedSequenceContainer< S >::Iterator last, const typename S::value_type &value)
Searches the specified value in the range [first,last).
void stableSort(Comparator comp)
Resorts the container using the specified comparator from its begin to its end.
void replace(const typename S::value_type &oldValue, const typename S::value_type &newValue)
Replaces the specified old value by a new one.
void push_back(const typename S::value_type &x)
Adds a new element at the end of the container.
const S::value_type & at(size_t n) const
Get item at position n.
size_t count(const value_type &value)
Counts the number of occurrences of the specified value inside the container.
S::value_type & operator[](size_t n)
Get item at position n.
WSharedSequenceContainer< S >::ConstIterator find(const typename S::value_type &value)
Searches the specified value in the range [begin,end).
S::iterator Iterator
A typedef for the correct iterator to traverse this sequence container.
void unique_push_front(const typename S::value_type &x)
Add the element only if it is not inside the container until now.
WSharedSequenceContainer< S >::Iterator erase(typename WSharedSequenceContainer< S >::Iterator position)
Erase the element at the specified position.
S::value_type & at(size_t n)
Get item at position n.
void stableSort(typename WSharedSequenceContainer< S >::Iterator first, typename WSharedSequenceContainer< S >::Iterator last, Comparator comp)
Resorts the container using the specified comparator between [first,last) in ascending order.
S::const_iterator ConstIterator
A typedef for the correct const iterator useful to traverse this sequence container.