25 #ifndef WSHAREDSEQUENCECONTAINER_H
26 #define WSHAREDSEQUENCECONTAINER_H
30 #include <boost/thread.hpp>
32 #include "WSharedObject.h"
38 template <
typename S >
81 void push_back(
const typename S::value_type& x );
88 void push_front(
const typename S::value_type& x );
118 typename S::value_type&
operator[](
size_t n );
128 const typename S::value_type&
operator[](
size_t n )
const;
138 typename S::value_type&
at(
size_t n );
148 const typename S::value_type&
at(
size_t n )
const;
156 void remove(
const typename S::value_type& element );
185 void replace(
const typename S::value_type& oldValue,
const typename S::value_type& newValue );
194 size_t count(
const value_type& value );
203 template <
typename Comparator >
204 void sort( Comparator comp );
213 template <
typename Comparator >
223 template <
typename Comparator >
233 template <
typename Comparator >
247 const typename S::value_type& value );
262 template <
typename S >
269 template <
typename S >
275 template <
typename S >
280 a->get().push_back( x );
283 template <
typename S >
288 a->get().insert( a->get().begin(), x );
291 template <
typename S >
299 template <
typename S >
307 template <
typename S >
312 size_t size = a->get().size();
316 template <
typename S >
320 return const_cast< S&
>( a->get() ).
operator[]( n );
324 template <
typename S >
328 return a->get().operator[]( n );
331 template <
typename S >
335 return const_cast< S&
>( a->get() ).at( n );
339 template <
typename S >
343 return a->get().at( n );
346 template <
typename S >
351 a->get().erase( std::remove( a->get().begin(), a->get().end(), element ), a->get().end() );
354 template <
typename S >
359 return a->get().erase( position );
362 template <
typename S >
369 return a->get().erase( first, last );
372 template <
typename S >
376 std::replace( a->get().begin(), a->get().end(), oldValue, newValue );
379 template <
typename S >
383 return std::count( a->get().begin(), a->get().end(), value );
386 template <
typename S >
387 template <
typename Comparator >
391 return std::sort( a->get().begin(), a->get().end(), comp );
394 template <
typename S >
395 template <
typename Comparator >
400 return std::sort( first, last, comp );
403 template <
typename S >
404 template <
typename Comparator >
408 return std::stable_sort( a->get().begin(), a->get().end(), comp );
411 template <
typename S >
412 template <
typename Comparator >
417 return std::stable_sort( first, last, comp );
420 template <
typename S >
424 const typename S::value_type& value )
426 return std::find( first, last, value );
429 template <
typename S >
433 return std::find( a->get().begin(), a->get().end(), value );
436 #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.