amino::SyncList< T, Sequence > Class Template Reference

This is a implementation of lock based list. It is simply added lock before every operation of ordinary list(such as the std::list<T>). More...

#include <sync_list.h>

List of all members.

Public Types

typedef Sequence::iterator iterator
typedef Sequence::const_iterator const_iterator
typedef Sequence::size_type size_type
typedef Sequence::reference reference
typedef Sequence::const_reference const_reference
typedef Sequence::value_type value_type

Public Member Functions

bool empty ()
 Judge if the list is empty.
size_type size ()
 Get the size of list.
bool front (reference ret)
 Get the first element in the list. If the list is empty, it will return false, else return true and assign the first element to the parameter.
T & operator[] (int index)
 Get element without range check.
T & at (int index)
 Get element with range check.
bool insert (int index, const T &e)
 Add the specified element into the list.
bool push_front (const T &x)
 Add a specified element to be the first element of the list.
bool push_back (const T &x)
 Add a specified element to be the last element of the list.
void pop_front ()
 Pop the first element of the list.
void pop_back ()
 Pop the last element of the list.
void clear ()
 Erases all of the elements.
bool remove (const T &value)
 Remove one element. different from remove in stl, which remove all the same elements.
void unique ()
 Removes all but the first element in every consecutive group of equal elements.
void merge (Sequence &x)
 Both *this and x must be sorted according to operator<, and they must be distinct. (That is, it is required that &x != this.) This function removes all of x's elements and inserts them in order into *this.
void reverse ()
 Reverses the order of elements in the list. All iterators remain valid and continue to point to the same elements.
void sort ()
 Sort the list.
iterator begin ()
iterator end ()
const_iterator begin () const
const_iterator end () const


Detailed Description

template<class T, class Sequence = std::list<T>>
class amino::SyncList< T, Sequence >

This is a implementation of lock based list. It is simply added lock before every operation of ordinary list(such as the std::list<T>).

Author:
Dai Xiao Jun
Template Parameters:
T The type of the element which is stored in the list
Sequence The internal list's type which take the std::list<T> as the default value. *

Member Typedef Documentation

template<class T, class Sequence = std::list<T>>
typedef Sequence::iterator amino::SyncList< T, Sequence >::iterator

template<class T, class Sequence = std::list<T>>
typedef Sequence::const_iterator amino::SyncList< T, Sequence >::const_iterator

template<class T, class Sequence = std::list<T>>
typedef Sequence::size_type amino::SyncList< T, Sequence >::size_type

template<class T, class Sequence = std::list<T>>
typedef Sequence::reference amino::SyncList< T, Sequence >::reference

template<class T, class Sequence = std::list<T>>
typedef Sequence::const_reference amino::SyncList< T, Sequence >::const_reference

template<class T, class Sequence = std::list<T>>
typedef Sequence::value_type amino::SyncList< T, Sequence >::value_type


Member Function Documentation

template<class T, class Sequence = std::list<T>>
bool amino::SyncList< T, Sequence >::empty (  )  [inline]

Judge if the list is empty.

Returns:
If the list is empty, return true, else return false.

template<class T, class Sequence = std::list<T>>
size_type amino::SyncList< T, Sequence >::size (  )  [inline]

Get the size of list.

Returns:
The size of list

template<class T, class Sequence = std::list<T>>
bool amino::SyncList< T, Sequence >::front ( reference  ret  )  [inline]

Get the first element in the list. If the list is empty, it will return false, else return true and assign the first element to the parameter.

Parameters:
ret The first element in the list. It is valid if the return value is true.
Returns:
If the list is not empty, return true, else return false

template<class T, class Sequence = std::list<T>>
T& amino::SyncList< T, Sequence >::operator[] ( int  index  )  [inline]

Get element without range check.

Parameters:
index The position of the element
Returns:
the element in the right position

template<class T, class Sequence = std::list<T>>
T& amino::SyncList< T, Sequence >::at ( int  index  )  [inline]

Get element with range check.

Parameters:
index The position of the element
Returns:
The element in the right position

template<class T, class Sequence = std::list<T>>
bool amino::SyncList< T, Sequence >::insert ( int  index,
const T &  e 
) [inline]

Add the specified element into the list.

Parameters:
index The position to be added to
value The element to be added
Returns:
If the element inserted successful return true, else return false

template<class T, class Sequence = std::list<T>>
bool amino::SyncList< T, Sequence >::push_front ( const T &  x  )  [inline]

Add a specified element to be the first element of the list.

Returns:
true for success and false for failed

template<class T, class Sequence = std::list<T>>
bool amino::SyncList< T, Sequence >::push_back ( const T &  x  )  [inline]

Add a specified element to be the last element of the list.

Returns:
True for success and false for failed

template<class T, class Sequence = std::list<T>>
void amino::SyncList< T, Sequence >::pop_front (  )  [inline]

Pop the first element of the list.

template<class T, class Sequence = std::list<T>>
void amino::SyncList< T, Sequence >::pop_back (  )  [inline]

Pop the last element of the list.

template<class T, class Sequence = std::list<T>>
void amino::SyncList< T, Sequence >::clear (  )  [inline]

Erases all of the elements.

template<class T, class Sequence = std::list<T>>
bool amino::SyncList< T, Sequence >::remove ( const T &  value  )  [inline]

Remove one element. different from remove in stl, which remove all the same elements.

Parameters:
value The element to be removed
Returns:
If the value exists in the list, remove it and return true. else return false.

template<class T, class Sequence = std::list<T>>
void amino::SyncList< T, Sequence >::unique (  )  [inline]

Removes all but the first element in every consecutive group of equal elements.

template<class T, class Sequence = std::list<T>>
void amino::SyncList< T, Sequence >::merge ( Sequence &  x  )  [inline]

Both *this and x must be sorted according to operator<, and they must be distinct. (That is, it is required that &x != this.) This function removes all of x's elements and inserts them in order into *this.

x Another list

template<class T, class Sequence = std::list<T>>
void amino::SyncList< T, Sequence >::reverse (  )  [inline]

Reverses the order of elements in the list. All iterators remain valid and continue to point to the same elements.

template<class T, class Sequence = std::list<T>>
void amino::SyncList< T, Sequence >::sort (  )  [inline]

Sort the list.

template<class T, class Sequence = std::list<T>>
iterator amino::SyncList< T, Sequence >::begin (  )  [inline]

template<class T, class Sequence = std::list<T>>
iterator amino::SyncList< T, Sequence >::end (  )  [inline]

template<class T, class Sequence = std::list<T>>
const_iterator amino::SyncList< T, Sequence >::begin (  )  const [inline]

template<class T, class Sequence = std::list<T>>
const_iterator amino::SyncList< T, Sequence >::end (  )  const [inline]


The documentation for this class was generated from the following file:

Generated on Tue Dec 9 13:39:39 2008 for Amino by  doxygen 1.5.6