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
268  {
269  _Init();
270  }
void _Init()
Definition: agents.h:385
template<class _Type>
Concurrency::details::_Dynamic_array< _Type >::~_Dynamic_array ( )
inline
276  {
277  _Clear();
278  }
void _Clear()
Definition: agents.h:307

Member Function Documentation

template<class _Type>
void Concurrency::details::_Dynamic_array< _Type >::_Clear ( )
inline
308  {
309  if (_M_array != NULL)
310  {
311  delete [] _M_array;
312  _Init();
313  }
314  }
_Type * _M_array
Definition: agents.h:419
void _Init()
Definition: agents.h:385
#define NULL
Definition: corecrt.h:158
template<class _Type>
void Concurrency::details::_Dynamic_array< _Type >::_Grow ( size_t  _NewSize)
inlineprivate
396  {
397  _CONCRT_ASSERT( _NewSize > _M_size );
398 
399  _Type * _Array = new _Type[_NewSize];
400 
401  if (_M_array != NULL)
402  {
403  // Copy over the elements
404  for (size_t _I = 0; _I < _M_size; _I++)
405  {
406  _Array[_I] = _M_array[_I];
407  }
408 
409  delete [] _M_array;
410  }
411 
412  _M_array = _Array;
413  _M_size = _NewSize;
414  }
#define _CONCRT_ASSERT(x)
Definition: concrt.h:123
_Type * _M_array
Definition: agents.h:419
size_t _M_size
Definition: agents.h:425
_In_ wctype_t _Type
Definition: corecrt_wctype.h:111
#define NULL
Definition: corecrt.h:158
template<class _Type>
void Concurrency::details::_Dynamic_array< _Type >::_Init ( )
inlineprivate
386  {
387  _M_array = NULL;
388  _M_index = 0;
389  _M_size = 0;
390  }
size_t _M_index
Definition: agents.h:422
_Type * _M_array
Definition: agents.h:419
size_t _M_size
Definition: agents.h:425
#define NULL
Definition: corecrt.h:158
template<class _Type>
void Concurrency::details::_Dynamic_array< _Type >::_Push_back ( _Type const &  _Element)
inline
320  {
321  if (_M_index >= _M_size)
322  {
323  // Not enough space. Grow the array
324  size_t _NewSize = (_M_index + 1) * _S_growthFactor;
325  _Grow(_NewSize);
326  }
327 
329  _M_array[_M_index] = _Element;
330  _M_index++;
331  }
size_t _M_index
Definition: agents.h:422
#define _CONCRT_ASSERT(x)
Definition: concrt.h:123
_Type * _M_array
Definition: agents.h:419
size_t _M_size
Definition: agents.h:425
static const int _S_growthFactor
Definition: agents.h:427
void _Grow(size_t _NewSize)
Definition: agents.h:395
template<class _Type>
size_t Concurrency::details::_Dynamic_array< _Type >::_Size ( ) const
inline
355  {
356  return _M_index;
357  }
size_t _M_index
Definition: agents.h:422
template<class _Type>
void Concurrency::details::_Dynamic_array< _Type >::_Swap ( _Myt _Right)
inline
363  {
364  if (this != &_Right)
365  {
366  // Swap the details.
367  _Type * _Array = _M_array;
368  size_t _Index = _M_index;
369  size_t _Size = _M_size;
370 
371  _M_array = _Right._M_array;
372  _M_index = _Right._M_index;
373  _M_size = _Right._M_size;
374 
375  _Right._M_array = _Array;
376  _Right._M_index = _Index;
377  _Right._M_size = _Size;
378  }
379  }
size_t _M_index
Definition: agents.h:422
_Type * _M_array
Definition: agents.h:419
_In_ size_t _In_ int _Index
Definition: time.h:102
size_t _Size() const
Definition: agents.h:354
size_t _M_size
Definition: agents.h:425
_In_ wctype_t _Type
Definition: corecrt_wctype.h:111
constexpr const _Ty &() _Right
Definition: algorithm:3723
template<class _Type>
_Myt& Concurrency::details::_Dynamic_array< _Type >::operator= ( const _Myt _Right)
inline
284  {
285  if (this != &_Right)
286  {
287  // Remove all the elements
288  _Clear();
289 
290  // Allocate space for the new elements
291  size_t _Size = _Right._Size();
292  _Grow(_Size);
293 
294  // Copy over the new elements
295  for (size_t _I=0; _I < _Size; _I++)
296  {
297  _Push_back(_Right[_I]);
298  }
299  }
300 
301  return *this;
302  }
void _Push_back(_Type const &_Element)
Definition: agents.h:319
size_t _Size() const
Definition: agents.h:354
void _Clear()
Definition: agents.h:307
void _Grow(size_t _NewSize)
Definition: agents.h:395
constexpr const _Ty &() _Right
Definition: algorithm:3723
template<class _Type>
reference Concurrency::details::_Dynamic_array< _Type >::operator[] ( size_t  _Pos)
inline
337  {
338  _CONCRT_ASSERT(_Pos < _M_size);
339  return _M_array[_Pos];
340  }
#define _CONCRT_ASSERT(x)
Definition: concrt.h:123
_Type * _M_array
Definition: agents.h:419
size_t _M_size
Definition: agents.h:425
template<class _Type>
const_reference Concurrency::details::_Dynamic_array< _Type >::operator[] ( size_t  _Pos) const
inline
346  {
347  _CONCRT_ASSERT(_Pos < _M_size);
348  return _M_array[_Pos];
349  }
#define _CONCRT_ASSERT(x)
Definition: concrt.h:123
_Type * _M_array
Definition: agents.h:419
size_t _M_size
Definition: agents.h:425

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: