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

expanded vector template class More...

#include <vector2.h>

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

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

Collaboration graph
[legend]

List of all members.

Public Types

typedef vector2< _Ty, _Alloc > _Myt
typedef vector< _Ty, _Alloc > _Mybase

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 ()
void sort ()

Static Public Member Functions

static _Myt __cdecl dyn_create (size_type _Count,...)

Related Functions

(Note that these are not member functions.)

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


Detailed Description

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

expanded vector 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?

Todo:
The vector2(_Count) & vector2(_Count, _Val) constructors do not exist.
Parameters:
__Ty element/value type
__Alloc element/value allocator

Definition at line 75 of file vector2.h.


Member Typedef Documentation

template<class _Ty, class _Alloc = allocator<_Ty>>
typedef vector2<_Ty, _Alloc> std::vector2< _Ty, _Alloc >::_Myt

type abbrevation for this class

Definition at line 78 of file vector2.h.

template<class _Ty, class _Alloc = allocator<_Ty>>
typedef vector<_Ty, _Alloc> std::vector2< _Ty, _Alloc >::_Mybase

type abbrevation for parent class/template

Definition at line 79 of file vector2.h.


Member Function Documentation

template<class _Ty, class _Alloc = allocator<_Ty>>
virtual void std::vector2< _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 85 of file vector2.h.

00088     {
00089         if (size() > _Limit)
00090         {
00091             resize(_Limit);
00092         }
00093     }

template<class _Ty, class _Alloc = allocator<_Ty>>
pair<size_type, bool> std::vector2< _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 103 of file vector2.h.

00106     {
00107         size_type _Index = 0;
00108         for (const_iterator iter = begin(); iter != end(); ++iter, ++_Index)
00109         {
00110             if (*iter == _Val)
00111             {
00112                 return pair<size_type, bool>(_Index, true);
00113             }
00114         }
00115         return pair<size_type, bool>(-1, false);
00116     }

template<class _Ty, class _Alloc = allocator<_Ty>>
bool std::vector2< _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 124 of file vector2.h.

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

00127     {
00128         return std::find(begin(), end(), _Val) != end();
00129     }

template<class _Ty, class _Alloc = allocator<_Ty>>
bool std::vector2< _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 138 of file vector2.h.

00141     {
00142         return std::find(begin(), end(), _Val) == end();
00143     }

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

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

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

Definition at line 151 of file vector2.h.

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

00154     {
00155         if (!contains(_Val))
00156         {
00157             push_back(_Val);
00158             return true;
00159         }
00160         return false;
00161     }

Here is the call graph for this function:

std::vector2::contains

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

Check whether the vector contains any element

Returns:
element cout > 0

Definition at line 167 of file vector2.h.

00168     {
00169         return size() > 0;
00170     }

template<class _Ty, class _Alloc = allocator<_Ty>>
void std::vector2< _Ty, _Alloc >::sort (  )  [inline]

Sort the elements in the vector

Definition at line 174 of file vector2.h.

00175     {
00176         if (size() > 1)
00177         {
00178             std::sort(begin(), end());
00179         }
00180     }

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

Dynamic vector creation.

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

Definition at line 187 of file vector2.h.

00191     {
00192         _Myt       _Vector;
00193         va_list    _Args;
00194 
00195         va_start(_Args, _Count);
00196         while(_Count--)
00197         {
00198             _Vector.push_back(va_arg(_Args, const _Ty));
00199         }
00200         va_end(_Args);
00201         return _Vector;
00202     }


Friends And Related Function Documentation

template<class _Ty_a, class _Alloc_a, class _Ty_b, class _Alloc_b>
vector2< _Ty_a, _Alloc_a > & operator+= ( vector2< _Ty_a, _Alloc_a > &  container,
const vector< _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:
vector2::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 223 of file vector2.h.

00227 {
00228     // NO clear
00229     for (vector<_Ty_b, _Alloc_b>::const_iterator it = values.begin(); it != values.end(); ++it)
00230     {
00231         container.push_back((_Ty_a)*it);
00232     }
00233     return container;
00234 };

template<class _Ty_a, class _Alloc_a, class _Ty_b, class _Alloc_b>
vector2< _Ty_a, _Alloc_a > & operator<< ( vector2< _Ty_a, _Alloc_a > &  container,
const vector< _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:
vector2::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 254 of file vector2.h.

00258 {
00259     container.clear();
00260     container += values;
00261     return container;
00262 };


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