STLdoc
STLdocumentation
 All Classes Namespaces Files Functions Variables Typedefs Enumerations Enumerator Friends Macros
Public Types | Public Member Functions | Private Member Functions | Private Attributes | Static Private Attributes | List of all members
Concurrency::details::_Dynamic_array< _Type > Class Template Reference

#include <agents.h>

Public Types

typedef _Dynamic_array< _Type_Myt
 
typedef _Typereference
 
typedef _Type const & const_reference
 

Public Member Functions

 _Dynamic_array ()
 
 ~_Dynamic_array ()
 
_Mytoperator= (const _Myt &_Right)
 
void _Clear ()
 
void _Push_back (_Type const &_Element)
 
reference operator[] (size_t _Pos)
 
const_reference operator[] (size_t _Pos) const
 
size_t _Size () const
 
void _Swap (_Myt &_Right)
 

Private Member Functions

void _Init ()
 
void _Grow (size_t _NewSize)
 

Private Attributes

_Type_M_array
 
size_t _M_index
 
size_t _M_size
 

Static Private Attributes

static const int _S_growthFactor = 2
 

Member Typedef Documentation

template<class _Type>
typedef _Type const& Concurrency::details::_Dynamic_array< _Type >::const_reference
template<class _Type>
typedef _Type& Concurrency::details::_Dynamic_array< _Type >::reference

Constructor & Destructor Documentation

template<class _Type>
Concurrency::details::_Dynamic_array< _Type >::_Dynamic_array ( )
inline
267  {
268  _Init();
269  }
void _Init()
Definition: agents.h:384
template<class _Type>
Concurrency::details::_Dynamic_array< _Type >::~_Dynamic_array ( )
inline
275  {
276  _Clear();
277  }
void _Clear()
Definition: agents.h:306

Member Function Documentation

template<class _Type>
void Concurrency::details::_Dynamic_array< _Type >::_Clear ( )
inline
307  {
308  if (_M_array != NULL)
309  {
310  delete [] _M_array;
311  _Init();
312  }
313  }
_Type * _M_array
Definition: agents.h:418
#define NULL
Definition: crtdbg.h:30
void _Init()
Definition: agents.h:384
template<class _Type>
void Concurrency::details::_Dynamic_array< _Type >::_Grow ( size_t  _NewSize)
inlineprivate
395  {
397 
398  _Type * _Array = new _Type[_NewSize];
399 
400  if (_M_array != NULL)
401  {
402  // Copy over the elememts
403  for (size_t _I = 0; _I < _M_size; _I++)
404  {
405  _Array[_I] = _M_array[_I];
406  }
407 
408  delete [] _M_array;
409  }
410 
411  _M_array = _Array;
412  _M_size = _NewSize;
413  }
#define _CONCRT_ASSERT(x)
Definition: concrt.h:137
_Type * _M_array
Definition: agents.h:418
#define NULL
Definition: crtdbg.h:30
size_t _M_size
Definition: agents.h:424
_In_ _CRT_GUARDOVERFLOW size_t _NewSize
Definition: malloc.h:108
_In_ wctype_t _Type
Definition: ctype.h:205
template<class _Type>
void Concurrency::details::_Dynamic_array< _Type >::_Init ( )
inlineprivate
385  {
386  _M_array = NULL;
387  _M_index = 0;
388  _M_size = 0;
389  }
size_t _M_index
Definition: agents.h:421
_Type * _M_array
Definition: agents.h:418
#define NULL
Definition: crtdbg.h:30
size_t _M_size
Definition: agents.h:424
template<class _Type>
void Concurrency::details::_Dynamic_array< _Type >::_Push_back ( _Type const &  _Element)
inline
319  {
320  if (_M_index >= _M_size)
321  {
322  // Not enough space. Grow the array
323  size_t _NewSize = (_M_index + 1) * _S_growthFactor;
324  _Grow(_NewSize);
325  }
326 
328  _M_array[_M_index] = _Element;
329  _M_index++;
330  }
size_t _M_index
Definition: agents.h:421
#define _CONCRT_ASSERT(x)
Definition: concrt.h:137
_Type * _M_array
Definition: agents.h:418
size_t _M_size
Definition: agents.h:424
_In_ _CRT_GUARDOVERFLOW size_t _NewSize
Definition: malloc.h:108
static const int _S_growthFactor
Definition: agents.h:426
void _Grow(size_t _NewSize)
Definition: agents.h:394
template<class _Type>
size_t Concurrency::details::_Dynamic_array< _Type >::_Size ( ) const
inline
354  {
355  return _M_index;
356  }
size_t _M_index
Definition: agents.h:421
template<class _Type>
void Concurrency::details::_Dynamic_array< _Type >::_Swap ( _Myt _Right)
inline
362  {
363  if (this != &_Right)
364  {
365  // Swap the details.
366  _Type * _Array = _M_array;
367  size_t _Index = _M_index;
368  size_t _Size = _M_size;
369 
370  _M_array = _Right._M_array;
371  _M_index = _Right._M_index;
372  _M_size = _Right._M_size;
373 
374  _Right._M_array = _Array;
375  _Right._M_index = _Index;
376  _Right._M_size = _Size;
377  }
378  }
size_t _M_index
Definition: agents.h:421
_Type * _M_array
Definition: agents.h:418
size_t _Size() const
Definition: agents.h:353
size_t _M_size
Definition: agents.h:424
_In_ wctype_t _Type
Definition: ctype.h:205
const _Ty & _Right
Definition: algorithm:4087
template<class _Type>
_Myt& Concurrency::details::_Dynamic_array< _Type >::operator= ( const _Myt _Right)
inline
283  {
284  if (this != &_Right)
285  {
286  // Remove all the elements
287  _Clear();
288 
289  // Allocate space for the new elements
290  size_t _Size = _Right._Size();
291  _Grow(_Size);
292 
293  // Copy over the new elements
294  for (size_t _I=0; _I < _Size; _I++)
295  {
296  _Push_back(_Right[_I]);
297  }
298  }
299 
300  return *this;
301  }
void _Push_back(_Type const &_Element)
Definition: agents.h:318
size_t _Size() const
Definition: agents.h:353
void _Clear()
Definition: agents.h:306
void _Grow(size_t _NewSize)
Definition: agents.h:394
const _Ty & _Right
Definition: algorithm:4087
template<class _Type>
reference Concurrency::details::_Dynamic_array< _Type >::operator[] ( size_t  _Pos)
inline
336  {
337  _CONCRT_ASSERT(_Pos < _M_size);
338  return _M_array[_Pos];
339  }
#define _CONCRT_ASSERT(x)
Definition: concrt.h:137
_Type * _M_array
Definition: agents.h:418
size_t _M_size
Definition: agents.h:424
template<class _Type>
const_reference Concurrency::details::_Dynamic_array< _Type >::operator[] ( size_t  _Pos) const
inline
345  {
346  _CONCRT_ASSERT(_Pos < _M_size);
347  return _M_array[_Pos];
348  }
#define _CONCRT_ASSERT(x)
Definition: concrt.h:137
_Type * _M_array
Definition: agents.h:418
size_t _M_size
Definition: agents.h:424

Member Data Documentation

template<class _Type>
_Type* Concurrency::details::_Dynamic_array< _Type >::_M_array
private
template<class _Type>
size_t Concurrency::details::_Dynamic_array< _Type >::_M_index
private
template<class _Type>
size_t Concurrency::details::_Dynamic_array< _Type >::_M_size
private
template<class _Type>
const int Concurrency::details::_Dynamic_array< _Type >::_S_growthFactor = 2
staticprivate

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