25 #ifndef WSHAREDSEQUENCECONTAINER_H
26 #define WSHAREDSEQUENCECONTAINER_H
31 #include <boost/thread.hpp>
34 #include "WSharedObject.h"
40 template <
typename S >
83 void push_back(
const typename S::value_type& x );
90 void push_front(
const typename S::value_type& x );
120 typename S::value_type&
operator[](
size_t n );
130 const typename S::value_type&
operator[](
size_t n )
const;
140 typename S::value_type&
at(
size_t n );
150 const typename S::value_type&
at(
size_t n )
const;
158 void remove(
const typename S::value_type& element );
187 void replace(
const typename S::value_type& oldValue,
const typename S::value_type& newValue );
196 size_t count(
const value_type& value );
205 template <
typename Comparator >
206 void sort( Comparator comp );
215 template <
typename Comparator >
225 template <
typename Comparator >
235 template <
typename Comparator >
249 const typename S::value_type& value );
264 template <
typename S >
271 template <
typename S >
277 template <
typename S >
282 a->get().push_back( x );
285 template <
typename S >
290 a->get().insert( a->get().begin(), x );
293 template <
typename S >
301 template <
typename S >
309 template <
typename S >
314 size_t size = a->get().size();
318 template <
typename S >
322 return const_cast< S&
>( a->get() ).
operator[]( n );
326 template <
typename S >
330 return a->get().operator[]( n );
333 template <
typename S >
337 return const_cast< S&
>( a->get() ).at( n );
341 template <
typename S >
345 return a->get().at( n );
348 template <
typename S >
353 a->get().erase( std::remove( a->get().begin(), a->get().end(), element ), a->get().end() );
356 template <
typename S >
361 return a->get().erase( position );
364 template <
typename S >
371 return a->get().erase( first, last );
374 template <
typename S >
378 std::replace( a->get().begin(), a->get().end(), oldValue, newValue );
381 template <
typename S >
385 return std::count( a->get().begin(), a->get().end(), value );
388 template <
typename S >
389 template <
typename Comparator >
393 return std::sort( a->get().begin(), a->get().end(), comp );
396 template <
typename S >
397 template <
typename Comparator >
402 return std::sort( first, last, comp );
405 template <
typename S >
406 template <
typename Comparator >
410 return std::stable_sort( a->get().begin(), a->get().end(), comp );
413 template <
typename S >
414 template <
typename Comparator >
419 return std::stable_sort( first, last, comp );
422 template <
typename S >
426 const typename S::value_type& value )
428 return std::find( first, last, value );
431 template <
typename S >
435 return std::find( a->get().begin(), a->get().end(), value );
438 #endif // WSHAREDSEQUENCECONTAINER_H
void pop_back()
Removes an element from the end.
void push_back(const typename S::value_type &x)
Adds a new element at the end of the container.
S::value_type & at(size_t n)
Get item at position n.
WSharedSequenceContainer< S >::Iterator erase(typename WSharedSequenceContainer< S >::Iterator position)
Erase the element at the specified position.
void sort(Comparator comp)
Resorts the container using the specified comparator from its begin to its end.
size_t size() const
The size of the container.
This class provides a common interface for thread-safe access to sequence containers (list...
WSharedSequenceContainer()
Default constructor.
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.
S::const_iterator ConstIterator
A typedef for the correct const iterator useful to traverse this sequence container.
void clear()
Clears the container.
void replace(const typename S::value_type &oldValue, const typename S::value_type &newValue)
Replaces the specified old value by a new one.
virtual ~WSharedSequenceContainer()
Destructor.
void remove(const typename S::value_type &element)
Searches and removes the specified element.
Wrapper around an object/type for thread safe sharing of objects among multiple threads.
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).
S::value_type value_type
The type of the elements.
S::value_type & operator[](size_t n)
Get item at position n.
void push_front(const typename S::value_type &x)
Adds a new element at the beginning of the container.
S::iterator Iterator
A typedef for the correct iterator to traverse this sequence container.
size_t count(const value_type &value)
Counts the number of occurrences of the specified value inside the container.
void stableSort(Comparator comp)
Resorts the container using the specified comparator from its begin to its end.