std::list2< _Ty, _Alloc > Class Template Reference

expanded list template class More...

#include <list2.h>

Inheritance diagram for std::list2< _Ty, _Alloc >:

Inheritance graph
[legend]
Collaboration diagram for std::list2< _Ty, _Alloc >:

Collaboration graph
[legend]

List of all members.

Public Member Functions

virtual void limit (size_type _Limit)
pair< size_type, bool > position (const _Ty &_Val) const
bool contains (const _Ty &_Val) const
bool contains_no (const _Ty &_Val) const
virtual bool add_if_new (const _Ty &_Val)
 operator bool ()
reference at (size_type _Off)
const_reference at (size_type _Off) const
reference operator[] (size_type _Off)
const_reference operator[] (size_type _Off) const

Static Public Member Functions

static list2< _Ty, _Alloc > __cdecl dyn_create (size_type _Count,...)

Protected Member Functions

void _Xran () const

Related Functions

(Note that these are not member functions.)

template<class _Ty_a, class _Alloc_a, class _Ty_b, class _Alloc_b>
list2< _Ty_a, _Alloc_a > & operator+= (list2< _Ty_a, _Alloc_a > &container, const list< _Ty_b, _Alloc_b > &values)
template<class _Ty_a, class _Alloc_a, class _Ty_b, class _Alloc_b>
list2< _Ty_a, _Alloc_a > & operator<< (list2< _Ty_a, _Alloc_a > &container, const list< _Ty_b, _Alloc_b > &values)


Detailed Description

template<class _Ty, class _Alloc = allocator<_Ty>>
class std::list2< _Ty, _Alloc >

expanded list template class

This specialisation supports:

Note:
deque2, list2 and vector2 are designed to be replaceable by each other and hence have the same access methods. However the main differences of their stl base templates still apply.
Speed?

Parameters:
_Ty element/value type
_Alloc element/value allocator

Definition at line 70 of file list2.h.


Member Function Documentation

template<class _Ty, class _Alloc = allocator<_Ty>>
virtual void std::list2< _Ty, _Alloc >::limit ( size_type  _Limit  )  [inline, virtual]

Limit does not grow if size() < _Limit as resize() does!

Parameters:
_Limit size limit for vector

Definition at line 80 of file list2.h.

00083     {
00084         if (size() > _Limit)
00085         {
00086             resize(_Limit);
00087         }
00088     }

template<class _Ty, class _Alloc = allocator<_Ty>>
pair<size_type, bool> std::list2< _Ty, _Alloc >::position ( const _Ty &  _Val  )  const [inline]

Brute force evaluation of element index in container. -1 is returned if element is not contained.

Parameters:
_Val element to search for
Returns:
  • position of _Val in vector or -1 if _VAL is not element of vector
  • whether or not _Val is element of vector

Definition at line 98 of file list2.h.

00101     {
00102         size_type _Index = 0;
00103         for (const_iterator iter = begin(); iter != end(); ++iter, ++_Index)
00104         {
00105             if (*iter == _Val)
00106             {
00107                 return pair<size_type, bool>(_Index, true);
00108             }
00109         }
00110         return pair<size_type, bool>(-1, false);
00111     }

template<class _Ty, class _Alloc = allocator<_Ty>>
bool std::list2< _Ty, _Alloc >::contains ( const _Ty &  _Val  )  const [inline]

Brute force test to check whether or not a specific value is contained in the vector.

Parameters:
_Val element to check for
Returns:
whether or not _Val is member of the vector

Definition at line 119 of file list2.h.

Referenced by std::list2< _Ty, _Alloc >::add_if_new().

00122     {
00123         return std::find(begin(), end(), _Val) != end();
00124     }

template<class _Ty, class _Alloc = allocator<_Ty>>
bool std::list2< _Ty, _Alloc >::contains_no ( const _Ty &  _Val  )  const [inline]

Brute force test to check whether or not a specific value is contained in the vector. The inverted result is returned this can be used for map2 values(check_fun_t) to return a unique list.

Parameters:
_Val element to check for
Returns:
whether or not _Val is new = NOT contained in the vector

Definition at line 133 of file list2.h.

00136     {
00137         return std::find(begin(), end(), _Val) == end();
00138     }

template<class _Ty, class _Alloc = allocator<_Ty>>
virtual bool std::list2< _Ty, _Alloc >::add_if_new ( const _Ty &  _Val  )  [inline, virtual]

Add _Val if it is not already contained in the list Returns wether or not _Val was added

Parameters:
_Val element to add
Returns:
whether _Val was added or already contained

Definition at line 146 of file list2.h.

References std::list2< _Ty, _Alloc >::contains().

00149     {
00150         if (!contains(_Val))
00151         {
00152             push_back(_Val);
00153             return true;
00154         }
00155         return false;
00156     }

Here is the call graph for this function:

std::list2::contains

template<class _Ty, class _Alloc = allocator<_Ty>>
std::list2< _Ty, _Alloc >::operator bool (  )  [inline]

Check whether the vector contains any element

Returns:
element cout > 0

Definition at line 162 of file list2.h.

00163     {
00164         return size() > 0;
00165     }

template<class _Ty, class _Alloc = allocator<_Ty>>
reference std::list2< _Ty, _Alloc >::at ( size_type  _Off  )  [inline]

dereference operator

Parameters:
_Off offset/index of element to dereference

Definition at line 171 of file list2.h.

References std::list2< _Ty, _Alloc >::_Xran().

Referenced by std::list2< _Ty, _Alloc >::operator[]().

00174     {   // subscript mutable sequence with checking
00175         if (size() <= _Off)
00176         {
00177             _Xran();
00178         }
00179         iterator it = begin();
00180         while(_Off--) ++it;
00181         return *it;
00182     }

Here is the call graph for this function:

std::list2::_Xran

template<class _Ty, class _Alloc = allocator<_Ty>>
const_reference std::list2< _Ty, _Alloc >::at ( size_type  _Off  )  const [inline]

dereference operator

Parameters:
_Off offset/index of element to dereference

Definition at line 188 of file list2.h.

References std::list2< _Ty, _Alloc >::_Xran().

00191     {   // subscript non mutable sequence with checking
00192         if (size() <= _Off)
00193         {
00194             _Xran();
00195         }
00196         const_iterator it = begin();
00197         while(_Off--) ++it;
00198         return *it;
00199     }

Here is the call graph for this function:

std::list2::_Xran

template<class _Ty, class _Alloc = allocator<_Ty>>
reference std::list2< _Ty, _Alloc >::operator[] ( size_type  _Off  )  [inline]

dereference operator

Parameters:
_Off offset/index of element to dereference

Definition at line 205 of file list2.h.

References std::list2< _Ty, _Alloc >::at().

00208     {   // subscript mutable sequence
00209         return at(_Off);
00210     }

Here is the call graph for this function:

std::list2::atstd::list2::_Xran

template<class _Ty, class _Alloc = allocator<_Ty>>
const_reference std::list2< _Ty, _Alloc >::operator[] ( size_type  _Off  )  const [inline]

dereference operator

Parameters:
_Off offset/index of element to dereference

Definition at line 216 of file list2.h.

References std::list2< _Ty, _Alloc >::at().

00219     {   // subscript nonmutable sequence
00220         return at(_Off);
00221     }

Here is the call graph for this function:

std::list2::atstd::list2::_Xran

template<class _Ty, class _Alloc = allocator<_Ty>>
static list2<_Ty, _Alloc> __cdecl std::list2< _Ty, _Alloc >::dyn_create ( size_type  _Count,
  ... 
) [inline, static]

Dynamic list creation.

Parameters:
_Count number of elemnts to put into list2
... elements to put into the vector each of type _Ty (_Count times)

Definition at line 228 of file list2.h.

00232     {
00233         _Myt       _List;
00234         va_list    _Args;
00235 
00236         va_start(_Args, _Count);
00237         while(_Count--)
00238         {
00239             _List.push_back(va_arg(_Args, const _Ty));
00240         }
00241         va_end(_Args);
00242         return _List;
00243     }

template<class _Ty, class _Alloc = allocator<_Ty>>
void std::list2< _Ty, _Alloc >::_Xran (  )  const [inline, protected]

throw an out of range exception

Definition at line 249 of file list2.h.

Referenced by std::list2< _Ty, _Alloc >::at().

00250     {   // report an out_of_range error
00251         _THROW(out_of_range, "invalid list2<T> subscript");
00252     }


Friends And Related Function Documentation

template<class _Ty_a, class _Alloc_a, class _Ty_b, class _Alloc_b>
list2< _Ty_a, _Alloc_a > & operator+= ( list2< _Ty_a, _Alloc_a > &  container,
const list< _Ty_b, _Alloc_b > &  values 
) [related]

add (not store) the values of a container to another container

Note:
the receiver container will not be emptied
Warning:
this operator can only be instanciated if a conversion from _Ty_b to _Ty_a exists
See also:
list2::operator<<
Parameters:
_Ty_a element/value type of receiver container
_Alloc_a element/value allocator of receiver container
_Ty_b element/value type of input container
_Alloc_b element/value allocator of input container
container container that receives th e input values
values container input values
Returns:
modified container

Definition at line 274 of file list2.h.

00278 {
00279     // NO clear
00280     for (list2<_Ty_b, _Alloc_b>::const_iterator it = values.begin(); it != values.end(); ++it)
00281     {
00282         container.push_back((_Ty_a)*it);
00283     }
00284     return container;
00285 };

template<class _Ty_a, class _Alloc_a, class _Ty_b, class _Alloc_b>
list2< _Ty_a, _Alloc_a > & operator<< ( list2< _Ty_a, _Alloc_a > &  container,
const list< _Ty_b, _Alloc_b > &  values 
) [related]

store (not add) the values of a container to another containert

Note:
the receiver container will be emptied
Warning:
this operator can only be instanciated if a conversion from _Ty_b to _Ty_a exists
See also:
list2::operator+=
Parameters:
_Ty_a element/value type of receiver container
_Alloc_a element/value allocator of receiver container
_Ty_b element/value type of input container
_Alloc_b element/value allocator of input container
container container that receives th e input values
values container input values
Returns:
modified container

Definition at line 305 of file list2.h.

00309 {
00310     container.clear();
00311     container += values;
00312     return container;
00313 };


The documentation for this class was generated from the following file:
  Hosted on code.google.com  
© Marcus Börger
Generated on Fri Jan 18 21:21:15 2008 for MBO-lib by doxygen 1.5.4