STLdoc
STLdocumentation
 All Classes Namespaces Files Functions Variables Typedefs Enumerations Enumerator Friends Macros
concurrent_vector.h
Go to the documentation of this file.
1 /***
2 * ==++==
3 *
4 * Copyright (c) Microsoft Corporation. All rights reserved.
5 * Microsoft would like to acknowledge that this concurrency data structure implementation
6 * is based on the Intel implementation of its Threading Building Blocks ("Intel Material").
7 *
8 * ==--==
9 * =+=+=+=+=+=+=+=+=+=+=+=+=+=+=+=+=+=+=+=+=+=+=+=+=+=+=+=+=+=+=+=+=+=+=+=+=+=+=+=+=+=+=+
10 *
11 * concurrent_vector.h
12 *
13 * =-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-
14 ****/
15 
16 /*
17  Intel Material Copyright 2005-2008 Intel Corporation. All Rights Reserved.
18 */
19 
20 #pragma once
21 
22 #include <crtdefs.h>
23 #include <memory>
24 #include <iterator>
25 #include <limits>
26 #include <algorithm>
27 #include <cstring>
28 #include <crtdbg.h>
29 #include <concrt.h>
30 
31 #define _PPL_CONTAINER
32 
33 #if !(defined (_M_X64) || defined (_M_IX86) || defined (_M_ARM) || defined (_M_ARM64))
34  #error ERROR: Concurrency Runtime is supported only on X64, X86, ARM, and ARM64 architectures.
35 #endif /* !(defined (_M_X64) || defined (_M_IX86) || defined (_M_ARM) || defined (_M_ARM64)) */
36 
37 #if defined (_M_CEE)
38  #error ERROR: Concurrency Runtime is not supported when compiling /clr.
39 #endif /* defined (_M_CEE) */
40 
41 #pragma pack(push,_CRT_PACKING)
42 #pragma warning (push)
43 #pragma warning (disable: 4510 4512 4610) // disable warnings for compiler unable to generate constructor
44 #pragma push_macro("new")
45 #undef new
46 
51 
52 namespace Concurrency
53 {
54 
55 template<typename _Ty, class _Ax = std::allocator<_Ty> >
57 
58 namespace details
59 {
60 
61  // Bad allocation marker.
62  #define _BAD_ALLOC_MARKER reinterpret_cast<void*>(63)
63 
64  // Base class of concurrent vector implementation.
66  {
67  protected:
68 
69  // Basic types declarations.
70  typedef size_t _Segment_index_t;
71  typedef size_t _Size_type;
72 
73  // Size constants
74  static const _Segment_index_t _Default_initial_segments = 1; // 2 initial items
75 
76  // Number of slots for segment's pointers inside the class
77  static const _Segment_index_t _Pointers_per_short_table = 3; // to fit into 8 words of entire structure
78  static const _Segment_index_t _Pointers_per_long_table = sizeof(_Segment_index_t) * 8; // one segment per bit
79 
80  // Segment pointer. Can be zero-initialized.
81  struct _Segment_t
82  {
83  void* _My_array;
84  };
85 
86  // Data fields
87 
88  // allocator function pointer
89  void* (__cdecl *_My_vector_allocator_ptr)(_Concurrent_vector_base_v4 &, size_t);
90 
91  // embedded storage of segment pointers
93 
94  // Methods
95 
97  {
98  _My_early_size = 0;
99  _My_first_block = 0; // here is not _Default_initial_segments
100  for( _Segment_index_t _I = 0; _I < _Pointers_per_short_table; _I++)
101  _My_storage[_I]._My_array = NULL;
103  }
105 
106  _CONCRTIMP static _Segment_index_t __cdecl _Segment_index_of( _Size_type _Index );
107 
108  static _Segment_index_t _Segment_base( _Segment_index_t _K )
109  {
110  return (_Segment_index_t(1)<<_K & ~_Segment_index_t(1));
111  }
112 
113  static _Segment_index_t _Segment_base_index_of( _Segment_index_t &_Index )
114  {
115  _Segment_index_t _K = _Segment_index_of( _Index );
116  _Index -= _Segment_base(_K);
117  return _K;
118  }
119 
120  static _Size_type _Segment_size( _Segment_index_t _K )
121  {
122  return _Segment_index_t(1)<<_K; // fake value for _K==0
123  }
124 
125  // An operation on an n-element array starting at begin.
126  typedef void (__cdecl *_My_internal_array_op1)(void* _Begin, _Size_type _N );
127 
128  // An operation on n-element destination array and n-element source array.
129  typedef void (__cdecl *_My_internal_array_op2)(void* _Dst, const void* _Src, _Size_type _N );
130 
131  // Internal structure for shrink_to_fit().
133  {
134  _Segment_index_t _First_block;
136  };
137 
138  _CONCRTIMP void _Internal_reserve( _Size_type _N, _Size_type _Element_size, _Size_type _Max_size );
139  _CONCRTIMP _Size_type _Internal_capacity() const;
140  void _Internal_grow( _Size_type _Start, _Size_type _Finish, _Size_type _Element_size, _My_internal_array_op2 _Init, const void *_Src );
141  _Size_type _Internal_grow_segment( const _Size_type _Start, _Size_type _Finish, _Size_type _Element_size, _Segment_t** _PPSegment, _Size_type* _PSegStart, _Size_type* _PSegFinish );
142  _CONCRTIMP _Size_type _Internal_grow_by( _Size_type _Delta, _Size_type _Element_size, _My_internal_array_op2 _Init, const void *_Src );
143  _CONCRTIMP void* _Internal_push_back( _Size_type _Element_size, _Size_type& _Index );
145  void _Internal_truncate( _Size_type _Old_size, _Size_type _New_size, _Size_type _Element_size, _My_internal_array_op1 _Destroy);
146  _CONCRTIMP void* _Internal_compact( _Size_type _Element_size, void *_Table, _My_internal_array_op1 _Destroy, _My_internal_array_op2 _Copy );
147  _CONCRTIMP void _Internal_copy( const _Concurrent_vector_base_v4& _Src, _Size_type _Element_size, _My_internal_array_op2 _Copy );
148  _CONCRTIMP void _Internal_assign( const _Concurrent_vector_base_v4& _Src, _Size_type _Element_size,
150  _CONCRTIMP void _Internal_throw_exception(_Size_type) const;
152 
153  _CONCRTIMP void _Internal_resize( _Size_type _New_size, _Size_type _Element_size, _Size_type _Max_size, _My_internal_array_op1 _Destroy, _My_internal_array_op2 _Init, const void* _Src);
154  _CONCRTIMP _Size_type _Internal_grow_to_at_least_with_result( _Size_type _New_size, _Size_type _Element_size, _My_internal_array_op2 _Init, const void *_Src );
155 
156  // Count of segments in the first block.
158 
159  // Requested size of vector.
161 
162  // Pointer to the segments table.
164 
165 
166  private:
167  // Private functionality.
168  class _Helper;
169  friend class _Helper;
170  };
171 
173 
174  // Meets requirements of a forward iterator for STL.*/
176  template<typename _Container, typename _Value>
178  {
179  // concurrent_vector over which we are iterating.
180  _Container* _My_vector;
181 
182  // Index into the vector.
183  size_t _My_index;
184 
185  // Caches _My_vector-&gt;_Internal_subscript(_My_index)
187  mutable _Value* _My_item;
188 
189  template<typename _C, typename _Ty>
191 
192  template<typename _C, typename _Ty, typename _U>
193  friend bool operator==( const _Vector_iterator<_C,_Ty>&, const _Vector_iterator<_C,_U>& );
194 
195  template<typename _C, typename _Ty, typename _U>
196  friend bool operator<( const _Vector_iterator<_C,_Ty>&, const _Vector_iterator<_C,_U>& );
197 
198  template<typename _C, typename _Ty, typename _U>
200 
201  template<typename _C, typename _U>
202  friend class ::Concurrency::details::_Vector_iterator;
203 
204  template<typename _Ty, class _Ax>
205  friend class ::Concurrency::concurrent_vector;
206 
207  _Vector_iterator( const _Container& _Vec, size_t _Index, void* _Ptr = NULL )
208  : _My_vector(const_cast<_Container*>(&_Vec)),
209  _My_index(_Index),
210  _My_item(static_cast<_Value*>(_Ptr))
211  {
212  }
213 
214  public:
215  // Default constructor
217  : _My_vector(NULL), _My_index(~size_t(0)), _My_item(NULL)
218  {
219  }
220 
222  : _My_vector(_Other._My_vector),
223  _My_index(_Other._My_index),
224  _My_item(_Other._My_item)
225  {
226  }
227 
229  {
230  return _Vector_iterator( *_My_vector, _My_index+_Offset );
231  }
233  {
234  _My_index+=_Offset;
235  _My_item = NULL;
236  return *this;
237  }
239  {
240  return _Vector_iterator( *_My_vector, _My_index-_Offset );
241  }
243  {
244  _My_index-=_Offset;
245  _My_item = NULL;
246  return *this;
247  }
248  _Value& operator*() const
249  {
250  _Value* _Item = _My_item;
251  if( !_Item )
252  _Item = _My_item = &_My_vector->_Internal_subscript(_My_index);
253  _CONCRT_ASSERT( _Item==&_My_vector->_Internal_subscript(_My_index)); // corrupt cache
254  return *_Item;
255  }
257  {
258  return _My_vector->_Internal_subscript(_My_index+_K);
259  }
261  {
262  return &operator*();
263  }
264 
265  // Pre increment
267  {
268  size_t _K = ++_My_index;
269  if( _My_item )
270  {
271  // Following test uses 2's-complement wizardry.
272  if( (_K& (_K-2))==0 )
273  {
274  // _K is a power of two that is at least _K-2.
275  _My_item= NULL;
276  }
277  else
278  {
279  ++_My_item;
280  }
281  }
282  return *this;
283  }
284 
285  // Pre decrement
287  {
288  _CONCRT_ASSERT( _My_index>0 ); // operator--() applied to iterator already at beginning of concurrent_vector.
289  size_t _K = _My_index--;
290  if( _My_item )
291  {
292  // Following test uses 2's-complement wizardry.
293  if( (_K& (_K-2))==0 )
294  {
295  // k is a power of two that is at least k-2.
296  _My_item= NULL;
297  }
298  else
299  {
300  --_My_item;
301  }
302  }
303  return *this;
304  }
305 
306  // Post increment
308  {
309  _Vector_iterator _Result = *this;
310  operator++();
311  return _Result;
312  }
313 
314  // Post decrement
316  {
317  _Vector_iterator _Result = *this;
318  operator--();
319  return _Result;
320  }
321 
322  // STL support
323 
326  typedef _Value* pointer;
327  typedef _Value& reference;
328  typedef std::random_access_iterator_tag iterator_category;
329  };
330 
331  template<typename _Container, typename _Value>
332  struct std::_Is_checked_helper<_Vector_iterator<_Container, _Value> >
333  : public true_type
334  { // mark _Vector_iterator as checked. This suppresses warning C4996
335  };
336 
337  template<typename _Container, typename _Ty>
339  {
340  return _Vector_iterator<_Container,_Ty>( *_Vec._My_vector, _Vec._My_index+_Offset );
341  }
342 
343  template<typename _Container, typename _Ty, typename _U>
345  {
346  return _I._My_index==_J._My_index && _I._My_vector == _J._My_vector;
347  }
348 
349  template<typename _Container, typename _Ty, typename _U>
351  {
352  return !(_I==_J);
353  }
354 
355  template<typename _Container, typename _Ty, typename _U>
356  bool operator<( const _Vector_iterator<_Container,_Ty>& _I, const _Vector_iterator<_Container,_U>& _J )
357  {
358  return _I._My_index<_J._My_index && _I._My_vector == _J._My_vector;
359  }
360 
361  template<typename _Container, typename _Ty, typename _U>
363  {
364  return _J<_I;
365  }
366 
367  template<typename _Container, typename _Ty, typename _U>
369  {
370  return !(_I<_J);
371  }
372 
373  template<typename _Container, typename _Ty, typename _U>
374  bool operator<=( const _Vector_iterator<_Container,_Ty>& _I, const _Vector_iterator<_Container,_U>& _J )
375  {
376  return !(_J<_I);
377  }
378 
379  template<typename _Container, typename _Ty, typename _U>
381  {
382  return ptrdiff_t(_I._My_index)-ptrdiff_t(_J._My_index);
383  }
384 
385  template<typename _Ty, class _Ax>
387  {
388  public:
389  typedef typename _Ax::template
390  rebind<_Ty>::other _Allocator_type;
391  _Allocator_type _My_allocator;
392 
394  : _My_allocator()
395  {
396  }
397 
398  _Allocator_base(const _Allocator_type &_Al)
399  : _My_allocator(_Al)
400  {
401  }
402  };
403 
404 } // namespace details
405 
422 
423 template<typename _Ty, class _Ax>
424 class concurrent_vector: protected details::_Allocator_base<_Ty, _Ax>,
425  private details::_Concurrent_vector_base_v4
426 {
427 private:
429 
430  template<typename _C, typename _U>
432 
433 public:
434 
438 
440 
444 
446 
450 
451  typedef _Ty value_type;
452 
456 
458 
462 
463  typedef _Ty& reference;
464 
469 
470  typedef const _Ty& const_reference;
471 
475 
476  typedef _Ty *pointer;
477 
481 
482  typedef const _Ty *const_pointer;
483 
488 
490 
494 
496 
501 
502  typedef std::reverse_iterator<iterator> reverse_iterator;
503 
507 
508  typedef std::reverse_iterator<const_iterator> const_reverse_iterator;
509 
527 
528  explicit concurrent_vector(const allocator_type &_Al = allocator_type())
529  : details::_Allocator_base<_Ty, _Ax>(_Al)
530  {
532  }
533 
551 
553  : details::_Allocator_base<_Ty, _Ax>(_Vector.get_allocator())
554  {
556  _Internal_copy(_Vector, sizeof(_Ty), &_Copy_array);
557  }
558 
582 
583  template<class M>
584  concurrent_vector( const concurrent_vector<_Ty, M>& _Vector, const allocator_type& _Al = allocator_type() )
585  : details::_Allocator_base<_Ty, _Ax>(_Al)
586  {
588  _Internal_copy(_Vector._Internal_vector_base(), sizeof(_Ty), &_Copy_array);
589  }
590 
591 
609 
611  : details::_Allocator_base<_Ty, _Ax>(_Vector.get_allocator())
612  {
614  _Concurrent_vector_base_v4::_Internal_swap(_Vector._Internal_vector_base());
615  }
616 
634 
635  explicit concurrent_vector(size_type _N)
636  {
638  if ( !_N ) return;
639  _Internal_reserve(_N, sizeof(_Ty), max_size()); _My_early_size = _N;
641  _Initialize_array(static_cast<_Ty*>(_My_segment[0]._My_array), NULL, _N);
642  }
643 
667 
668  concurrent_vector(size_type _N, const_reference _Item, const allocator_type& _Al = allocator_type())
669  : details::_Allocator_base<_Ty, _Ax>(_Al)
670  {
672  _Internal_assign( _N, _Item );
673  }
674 
701 
702  template<class _InputIterator>
703  concurrent_vector(_InputIterator _Begin, _InputIterator _End, const allocator_type &_Al = allocator_type())
704  : details::_Allocator_base<_Ty, _Ax>(_Al)
705  {
708  }
709 
719 
721  {
722  if( this != &_Vector )
723  _Concurrent_vector_base_v4::_Internal_assign(_Vector, sizeof(_Ty), &_Destroy_array, &_Assign_array, &_Copy_array);
724  return *this;
725  }
726 
739 
740  template<class M>
742  {
743  if( static_cast<void*>( this ) != static_cast<const void*>( &_Vector ) )
744  {
745  _Concurrent_vector_base_v4::_Internal_assign(_Vector._Internal_vector_base(),
746  sizeof(_Ty), &_Destroy_array, &_Assign_array, &_Copy_array);
747  }
748  return *this;
749  }
750 
760 
762  {
763  if( static_cast<void*>( this ) != static_cast<const void*>( &_Vector ) )
764  {
765  _Concurrent_vector_base_v4::_Internal_swap(_Vector._Internal_vector_base());
766  _Vector.clear();
767  }
768  return *this;
769  }
770 
783 
784  iterator grow_by( size_type _Delta )
785  {
786  return iterator(*this, _Delta ? _Internal_grow_by( _Delta, sizeof(_Ty), &_Initialize_array, NULL ) : _My_early_size);
787  }
788 
804 
805  iterator grow_by( size_type _Delta, const_reference _Item )
806  {
807  return iterator(*this, _Delta ? _Internal_grow_by( _Delta, sizeof(_Ty), &_Initialize_array_by, static_cast<const void*>(&_Item) ) : _My_early_size);
808  }
809 
820 
821  iterator grow_to_at_least( size_type _N )
822  {
823  size_type _M = 0;
824  if( _N )
825  {
827  if( _M > _N )
828  _M = _N;
829  }
830  return iterator(*this, _M);
831  };
832 
842 
843  iterator push_back( const_reference _Item )
844  {
845  size_type _K;
846  void *_Ptr = _Internal_push_back(sizeof(_Ty), _K);
847  _Internal_loop_guide _Loop(1, _Ptr);
848  _Loop._Init(&_Item);
849  return iterator(*this, _K, _Ptr);
850  }
851 
861 
862  iterator push_back( _Ty &&_Item )
863  {
864  size_type _K;
865  void *_Ptr = _Internal_push_back(sizeof(_Ty), _K);
866  new (_Ptr) _Ty( std::move(_Item));
867  return iterator(*this, _K, _Ptr);
868  }
869 
887 
888  reference operator[]( size_type _Index )
889  {
890  return _Internal_subscript(_Index);
891  }
892 
910 
911  const_reference operator[]( size_type _Index ) const
912  {
913  return _Internal_subscript(_Index);
914  }
915 
935 
936  reference at( size_type _Index )
937  {
939  }
940 
960 
961  const_reference at( size_type _Index ) const
962  {
964  }
965 
977 
978  size_type size() const
979  {
980  size_type _Sz = _My_early_size;
981  size_type _Cp = _Internal_capacity();
982  return _Cp < _Sz ? _Cp : _Sz;
983  }
984 
991 
992  bool empty() const
993  {
994  return !_My_early_size;
995  }
996 
1007 
1008  size_type capacity() const
1009  {
1010  return _Internal_capacity();
1011  }
1012 
1025 
1026  void reserve( size_type _N )
1027  {
1028  if( _N )
1029  _Internal_reserve(_N, sizeof(_Ty), max_size());
1030  }
1031 
1041 
1042  void shrink_to_fit();
1043 
1059 
1060  void resize(size_type _N)
1061  {
1063  }
1064 
1084 
1085  void resize(size_type _N, const _Ty& _Val)
1086  {
1087  _Internal_resize( _N, sizeof(_Ty), max_size(), _Destroy_array, _Initialize_array_by, static_cast<const void*>(&_Val) );
1088  }
1089 
1096 
1097  size_type max_size() const
1098  {
1099  return (~size_type(0))/sizeof(_Ty);
1100  }
1101 
1110 
1111  iterator begin()
1112  {
1113  return iterator(*this,0);
1114  }
1115 
1124 
1125  iterator end()
1126  {
1127  return iterator(*this,size());
1128  }
1129 
1138 
1139  const_iterator begin() const
1140  {
1141  return const_iterator(*this,0);
1142  }
1143 
1152 
1153  const_iterator end() const
1154  {
1155  return const_iterator(*this,size());
1156  }
1157 
1166 
1167  reverse_iterator rbegin()
1168  {
1169  return reverse_iterator(end());
1170  }
1171 
1180 
1181  reverse_iterator rend()
1182  {
1183  return reverse_iterator(begin());
1184  }
1185 
1194 
1195  const_reverse_iterator rbegin() const
1196  {
1197  return const_reverse_iterator(end());
1198  }
1199 
1208 
1209  const_reverse_iterator rend() const
1210  {
1211  return const_reverse_iterator(begin());
1212  }
1213 
1221 
1222  const_iterator cbegin() const
1223  {
1224  return (((const _Myt *)this)->begin());
1225  }
1226 
1234 
1235  const_iterator cend() const
1236  {
1237  return (((const _Myt *)this)->end());
1238  }
1239 
1247 
1248  const_reverse_iterator crbegin() const
1249  {
1250  return (((const _Myt *)this)->rbegin());
1251  }
1252 
1260 
1261  const_reverse_iterator crend() const
1262  {
1263  return (((const _Myt *)this)->rend());
1264  }
1265 
1273 
1274  reference front()
1275  {
1276  _CONCRT_ASSERT( size()>0 );
1277  return static_cast<_Ty*>(_My_segment[0]._My_array)[0];
1278  }
1279 
1287 
1288  const_reference front() const
1289  {
1290  _CONCRT_ASSERT( size()>0 );
1291  return static_cast<_Ty*>(_My_segment[0]._My_array)[0];
1292  }
1293 
1301 
1302  reference back()
1303  {
1304  _Size_type sz = size();
1305  _CONCRT_ASSERT( sz > 0 );
1306  return _Internal_subscript( sz-1 );
1307  }
1308 
1316 
1317  const_reference back() const
1318  {
1319  _Size_type sz = size();
1320  _CONCRT_ASSERT( sz > 0 );
1321  return _Internal_subscript( sz-1 );
1322  }
1323 
1330 
1331  allocator_type get_allocator() const
1332  {
1333  return this->_My_allocator;
1334  }
1335 
1351 
1352  void assign(size_type _N, const_reference _Item)
1353  {
1354  clear();
1355  _Internal_assign( _N, _Item );
1356  }
1357 
1376 
1377  template<class _InputIterator>
1378  void assign(_InputIterator _Begin, _InputIterator _End)
1379  {
1380  clear();
1382  }
1383 
1390 
1391  void swap(concurrent_vector &_Vector)
1392  {
1393  if( this != &_Vector )
1394  {
1395  _Concurrent_vector_base_v4::_Internal_swap(static_cast<_Concurrent_vector_base_v4&>(_Vector));
1396  std::swap(this->_My_allocator, _Vector._My_allocator);
1397  }
1398  }
1399 
1408 
1409  void clear()
1410  {
1412  }
1413 
1417 
1419  {
1420  _Segment_t *_Table = _My_segment;
1421  _Internal_free_segments( reinterpret_cast<void**>(_Table), _Internal_clear(&_Destroy_array), _My_first_block );
1422  // base class destructor call
1423  }
1424 
1425  const ::Concurrency::details::_Concurrent_vector_base_v4 &_Internal_vector_base() const { return *this; }
1427 private:
1428 
1429  // Allocate _K items
1431  {
1432  return static_cast<concurrent_vector<_Ty, _Ax>&>(_Vb)._My_allocator.allocate(_K);
1433  }
1434  // Free _K segments from table
1435  void _Internal_free_segments(void *_Table[], _Segment_index_t _K, _Segment_index_t _First_block);
1436 
1437  // Get reference to element at given _Index.
1438  _Ty& _Internal_subscript( size_type _Index ) const;
1439 
1440  // Get reference to element at given _Index with errors checks
1441  _Ty& _Internal_subscript_with_exceptions( size_type _Index ) const;
1442 
1443  // assign _N items by copying _Item
1444  void _Internal_assign(size_type _N, const_reference _Item);
1445 
1446  // helper class
1447  template<bool B> class _Is_integer_tag;
1448 
1449  // assign integer items by copying when arguments are treated as iterators. See C++ Standard 2003 23.1.1 p9
1450  template<class _I>
1452  {
1453  _Internal_assign(static_cast<size_type>(_First), static_cast<_Ty>(_Last));
1454  }
1455  // inline proxy assign by iterators
1456  template<class _I>
1458  internal_assign_iterators(_First, _Last);
1459  }
1460  // assign by iterators
1461  template<class _I>
1462  void internal_assign_iterators(_I _First, _I _Last);
1463 
1464  // Construct _N instances of _Ty, starting at "begin".
1465  static void __cdecl _Initialize_array( void* _Begin, const void*, size_type _N );
1466 
1467  // Construct _N instances of _Ty, starting at "begin".
1468  static void __cdecl _Initialize_array_by( void* _Begin, const void* _Src, size_type _N );
1469 
1470  // Construct _N instances of _Ty, starting at "begin".
1471  static void __cdecl _Copy_array( void* _Dst, const void* _Src, size_type _N );
1472 
1473  // Assign _N instances of _Ty, starting at "begin".
1474  static void __cdecl _Assign_array( void* _Dst, const void* _Src, size_type _N );
1475 
1476  // Destroy _N instances of _Ty, starting at "begin".
1477  static void __cdecl _Destroy_array( void* _Begin, size_type _N );
1478 
1479  // Exception-aware helper class for filling a segment by exception-danger operators of user class
1481  {
1482  public:
1483  const pointer _My_array;
1484  const size_type _N;
1485  size_type _I;
1486  _Internal_loop_guide(size_type _NTrials, void *_Ptr)
1487  : _My_array(static_cast<pointer>(_Ptr)), _N(_NTrials), _I(0)
1488  {
1489  }
1490 
1491  void _Init()
1492  {
1493  for(; _I < _N; ++_I)
1494  new( &_My_array[_I] ) _Ty();
1495  }
1496  void _Init(const void *_Src)
1497  {
1498  for(; _I < _N; ++_I)
1499  new( &_My_array[_I] ) _Ty(*static_cast<const _Ty*>(_Src));
1500  }
1501  void _Copy(const void *_Src)
1502  {
1503  for(; _I < _N; ++_I)
1504  new( &_My_array[_I] ) _Ty(static_cast<const _Ty*>(_Src)[_I]);
1505  }
1506  void _Assign(const void *_Src)
1507  {
1508  for(; _I < _N; ++_I)
1509  _My_array[_I] = static_cast<const _Ty*>(_Src)[_I];
1510  }
1511  template<class _It> void _Iterate(_It &_Src)
1512  {
1513  for(; _I < _N; ++_I, ++_Src)
1514  new( &_My_array[_I] ) _Ty( *_Src );
1515  }
1517  {
1518  if(_I < _N) // if exception raised, do zeroing on the rest of items
1519  std::memset(_My_array+_I, 0, (_N-_I)*sizeof(value_type));
1520  }
1521  private:
1522  void operator=(const _Internal_loop_guide&); // prevent warning: assign operator can't be generated
1523  };
1524 };
1525 
1534 
1535 template<typename _Ty, class _Ax>
1537 {
1538  _Internal_segments_table _Old = { 0, nullptr };
1539  try
1540  {
1541  if( _Internal_compact( sizeof(_Ty), &_Old, &_Destroy_array, &_Copy_array ) )
1542  _Internal_free_segments( _Old._Table, _Pointers_per_long_table, _Old._First_block ); // Free joined and unnecessary segments
1543  }
1544  catch(...)
1545  {
1546  if( _Old._First_block ) // Free segment allocated for compacting. Only for support of exceptions in ctor of user _Ty[pe]
1547  _Internal_free_segments( _Old._Table, 1, _Old._First_block );
1548  throw;
1549  }
1550 }
1551 
1552 template<typename _Ty, class _Ax>
1554 {
1555  // Free the arrays
1556  while( _K > _First_block )
1557  {
1558  --_K;
1559  _Ty* _Array = static_cast<_Ty*>(_Table[_K]);
1560  _Table[_K] = NULL;
1561  if( _Array > _BAD_ALLOC_MARKER ) // check for correct segment pointer
1562  this->_My_allocator.deallocate( _Array, _Segment_size(_K) );
1563  }
1564  _Ty* _Array = static_cast<_Ty*>(_Table[0]);
1565  if( _Array > _BAD_ALLOC_MARKER )
1566  {
1567  _CONCRT_ASSERT( _First_block > 0 );
1568  while(_K > 0)
1569  _Table[--_K] = NULL;
1570  this->_My_allocator.deallocate( _Array, _Segment_size(_First_block) );
1571  }
1572 }
1573 
1574 template<typename _Ty, class _Ax>
1576 {
1577  _CONCRT_ASSERT( _Index<_My_early_size ); // index out of bounds
1578  size_type _J = _Index;
1579  _Segment_index_t _K = _Segment_base_index_of( _J );
1580  _CONCRT_ASSERT( _My_segment != (_Segment_t*)_My_storage || _K < _Pointers_per_short_table ); // index is under construction
1581  // no need in load_with_acquire because the thread works in its own space or gets
1582  _Ty* _Array = static_cast<_Ty*>(_My_segment[_K]._My_array);
1583  _CONCRT_ASSERT( _Array != _BAD_ALLOC_MARKER ); // instance may be broken by bad allocation; use at() instead
1584  _CONCRT_ASSERT( _Array != NULL ); // index is being allocated
1585  return _Array[_J];
1586 }
1587 
1588 template<typename _Ty, class _Ax>
1590 {
1591  if( _Index >= _My_early_size )
1592  _Internal_throw_exception(0); // throw std::out_of_range
1593  size_type _J = _Index;
1594  _Segment_index_t _K = _Segment_base_index_of( _J );
1595  if( _My_segment == (_Segment_t*)_My_storage && _K >= _Pointers_per_short_table )
1596  _Internal_throw_exception(1); // throw std::out_of_range
1597  void *_Array = _My_segment[_K]._My_array; // no need in load_with_acquire
1598  if( _Array <= _BAD_ALLOC_MARKER ) // check for correct segment pointer
1599  _Internal_throw_exception(2); // throw std::range_error
1600  return static_cast<_Ty*>(_Array)[_J];
1601 }
1602 
1603 template<typename _Ty, class _Ax>
1604 void concurrent_vector<_Ty, _Ax>::_Internal_assign(size_type _N, const_reference _Item)
1605 {
1606  _CONCRT_ASSERT( _My_early_size == 0 );
1607  if( !_N )
1608  return;
1609  _Internal_reserve(_N, sizeof(_Ty), max_size());
1610  _My_early_size = _N;
1611  _Segment_index_t _K = 0;
1612  _Size_type _Sz = _Segment_size( _My_first_block );
1613  while (_Sz < _N)
1614  {
1615  _Initialize_array_by(static_cast<_Ty*>(_My_segment[_K]._My_array), static_cast<const void*>(&_Item), _Sz);
1616  _N -= _Sz;
1617  if (!_K)
1618  {
1619  _K = _My_first_block;
1620  }
1621  else {
1622  ++_K;
1623  _Sz <<= 1;
1624  }
1625  }
1626  _Initialize_array_by(static_cast<_Ty*>(_My_segment[_K]._My_array), static_cast<const void*>(&_Item), _N);
1627 }
1628 
1629 template<typename _Ty, class _Ax> template<class _I>
1631 {
1632  _CONCRT_ASSERT(_My_early_size == 0);
1633  size_type _N = std::distance(_First, _Last);
1634  if( !_N ) return;
1635  _Internal_reserve(_N, sizeof(_Ty), max_size());
1636  _My_early_size = _N;
1637  _Segment_index_t _K = 0;
1638  _Size_type _Sz = _Segment_size( _My_first_block );
1639  while (_Sz < _N)
1640  {
1641  _Internal_loop_guide _Loop(_Sz, _My_segment[_K]._My_array);
1642  _Loop._Iterate(_First);
1643  _N -= _Sz;
1644  if (!_K)
1645  {
1646  _K = _My_first_block;
1647  }
1648  else {
1649  ++_K;
1650  _Sz <<= 1;
1651  }
1652  }
1653 
1654  _Internal_loop_guide _Loop(_N, _My_segment[_K]._My_array);
1655  _Loop._Iterate(_First);
1656 }
1657 
1658 template<typename _Ty, class _Ax>
1659 void __cdecl concurrent_vector<_Ty, _Ax>::_Initialize_array( void* _Begin, const void *, size_type _N )
1660 {
1661  _Internal_loop_guide _Loop(_N, _Begin); _Loop._Init();
1662 }
1663 
1664 template<typename _Ty, class _Ax>
1665 void __cdecl concurrent_vector<_Ty, _Ax>::_Initialize_array_by( void* _Begin, const void *_Src, size_type _N )
1666 {
1667  _Internal_loop_guide _Loop(_N, _Begin); _Loop._Init(_Src);
1668 }
1669 
1670 template<typename _Ty, class _Ax>
1671 void __cdecl concurrent_vector<_Ty, _Ax>::_Copy_array( void* _Dst, const void* _Src, size_type _N ) {
1672  _Internal_loop_guide _Loop(_N, _Dst); _Loop._Copy(_Src);
1673 }
1674 
1675 template<typename _Ty, class _Ax>
1676 void __cdecl concurrent_vector<_Ty, _Ax>::_Assign_array( void* _Dst, const void* _Src, size_type _N )
1677 {
1678  _Internal_loop_guide _Loop(_N, _Dst); _Loop._Assign(_Src);
1679 }
1680 
1681 #pragma warning(push)
1682 #pragma warning(disable: 4189) /* local variable _Array is initialized but not used - the compiler optimizes away calls to the destructor */
1683 
1684 template<typename _Ty, class _Ax>
1685 void __cdecl concurrent_vector<_Ty, _Ax>::_Destroy_array( void* _Begin, size_type _N )
1686 {
1687  _Ty* _Array = static_cast<_Ty*>(_Begin);
1688  for( size_type _J=_N; _J>0; --_J )
1689  _Array[_J-1].~_Ty(); // destructors are supposed to not throw any exceptions
1690 }
1691 
1692 #pragma warning(pop)
1693 
1725 
1726 template<typename _Ty, class A1, class A2>
1728 {
1729  // Simply: return _A.size() == _B.size() && std::equal(_A.begin(), _A.end(), _B.begin());
1730  if(_A.size() != _B.size())
1731  return false;
1732  typename concurrent_vector<_Ty, A1>::const_iterator _I(_A.begin());
1733  typename concurrent_vector<_Ty, A2>::const_iterator _J(_B.begin());
1734  for(; _I != _A.end(); ++_I, ++_J)
1735  {
1736  if( !(*_I == *_J) )
1737  return false;
1738  }
1739  return true;
1740 }
1741 
1772 
1773 template<typename _Ty, class A1, class A2>
1775 {
1776  return !(_A == _B);
1777 }
1778 
1810 
1811 template<typename _Ty, class A1, class A2>
1812 inline bool operator<(const concurrent_vector<_Ty, A1> &_A, const concurrent_vector<_Ty, A2> &_B)
1813 {
1814  return (std::lexicographical_compare(_A.begin(), _A.end(), _B.begin(), _B.end()));
1815 }
1816 
1848 
1849 template<typename _Ty, class A1, class A2>
1851 {
1852  return _B < _A;
1853 }
1854 
1886 
1887 template<typename _Ty, class A1, class A2>
1888 inline bool operator<=(const concurrent_vector<_Ty, A1> &_A, const concurrent_vector<_Ty, A2> &_B)
1889 {
1890  return !(_B < _A);
1891 }
1892 
1924 
1925 template<typename _Ty, class A1, class A2>
1927 {
1928  return !(_A < _B);
1929 }
1930 
1960 
1961 template<typename _Ty, class _Ax>
1963 {
1964  _A.swap( _B );
1965 }
1966 
1967 } // namespace Concurrency
1968 
1969 namespace concurrency = ::Concurrency;
1970 
1971 #pragma pop_macro("new")
1972 #pragma warning (pop)
1973 #pragma pack(pop)
void _Internal_grow(_Size_type _Start, _Size_type _Finish, _Size_type _Element_size, _My_internal_array_op2 _Init, const void *_Src)
reference operator[](size_type _Index)
Provides access to the element at the given index in the concurrent vector. This method is concurrenc...
Definition: concurrent_vector.h:888
const_reverse_iterator rend() const
Returns an iterator of type reverse_iterator or const_reverse_iterator to the end of the concurrent...
Definition: concurrent_vector.h:1209
_CONCRTIMP _Size_type _Internal_grow_to_at_least_with_result(_Size_type _New_size, _Size_type _Element_size, _My_internal_array_op2 _Init, const void *_Src)
void(__cdecl * _My_internal_array_op2)(void *_Dst, const void *_Src, _Size_type _N)
Definition: concurrent_vector.h:129
Definition: xtr1common:22
_Vector_iterator operator++(int)
Definition: concurrent_vector.h:307
void *__cdecl * _My_vector_allocator_ptr(_Concurrent_vector_base_v4 &, size_t)
_CONCRTIMP _Size_type _Internal_capacity() const
concurrent_vector(const concurrent_vector &_Vector)
Constructs a concurrent vector.
Definition: concurrent_vector.h:552
_Vector_iterator operator+(ptrdiff_t _Offset) const
Definition: concurrent_vector.h:228
static _CONCRTIMP _Segment_index_t __cdecl _Segment_index_of(_Size_type _Index)
const ::Concurrency::details::_Concurrent_vector_base_v4 & _Internal_vector_base() const
Definition: concurrent_vector.h:1425
size_t _Size_type
Definition: concurrent_vector.h:71
iterator push_back(_Ty &&_Item)
Appends the given item to the end of the concurrent vector. This method is concurrency-safe.
Definition: concurrent_vector.h:862
const_reference front() const
Returns a reference or a const reference to the first element in the concurrent vector. If the concurrent vector is empty, the return value is undefined. This method is concurrency-safe.
Definition: concurrent_vector.h:1288
_Vector_iterator(const _Vector_iterator< _Container, typename _Container::value_type > &_Other)
Definition: concurrent_vector.h:221
#define NULL
Definition: vcruntime.h:236
~_Internal_loop_guide()
Definition: concurrent_vector.h:1516
_Value & operator*() const
Definition: concurrent_vector.h:248
_Vector_iterator & operator-=(ptrdiff_t _Offset)
Definition: concurrent_vector.h:242
concurrent_vector(const allocator_type &_Al=allocator_type())
Constructs a concurrent vector.
Definition: concurrent_vector.h:528
_Value * operator->() const
Definition: concurrent_vector.h:260
_Value value_type
Definition: concurrent_vector.h:325
void _Internal_truncate(_Size_type _Old_size, _Size_type _New_size, _Size_type _Element_size, _My_internal_array_op1 _Destroy)
_Vector_iterator()
Definition: concurrent_vector.h:216
void _Assign(const void *_Src)
Definition: concurrent_vector.h:1506
std::enable_if< details::_Is_extent_or_index< _Tuple_type< _Rank > >::value, bool >::type operator==(const _Tuple_type< _Rank > &_Lhs, const _Tuple_type< _Rank > &_Rhs) __GPU
Definition: amp.h:822
~concurrent_vector()
Erases all elements and destroys this concurrent vector.
Definition: concurrent_vector.h:1418
Definition: concurrent_vector.h:65
_Value * pointer
Definition: concurrent_vector.h:326
reverse_iterator rend()
Returns an iterator of type reverse_iterator or const_reverse_iterator to the end of the concurrent...
Definition: concurrent_vector.h:1181
const _Ty * const_pointer
A type that provides a pointer to a const element in a concurrent vector.
Definition: concurrent_vector.h:482
_CONCRTIMP void _Internal_throw_exception(_Size_type) const
_Allocator_base(const _Allocator_type &_Al)
Definition: concurrent_vector.h:398
void _Init()
Definition: concurrent_vector.h:1491
#define _CONCRT_ASSERT(x)
Definition: concrt.h:123
bool operator==(const _Concurrent_queue_iterator< _C, _Ty > &_I, const _Concurrent_queue_iterator< _C, _U > &_J)
Definition: concurrent_queue.h:318
concurrent_vector(size_type _N, const_reference _Item, const allocator_type &_Al=allocator_type())
Constructs a concurrent vector.
Definition: concurrent_vector.h:668
_Vector_iterator(const _Container &_Vec, size_t _Index, void *_Ptr=NULL)
Definition: concurrent_vector.h:207
_CONCRTIMP _Size_type _Internal_grow_by(_Size_type _Delta, _Size_type _Element_size, _My_internal_array_op2 _Init, const void *_Src)
iterator grow_to_at_least(size_type _N)
Grows this concurrent vector until it has at least _N elements. This method is concurrency-safe.
Definition: concurrent_vector.h:821
size_type capacity() const
Returns the maximum size to which the concurrent vector can grow without having to allocate more memo...
Definition: concurrent_vector.h:1008
ptrdiff_t difference_type
A type that provides the signed distance between two elements in a concurrent vector.
Definition: concurrent_vector.h:457
reference at(size_type _Index)
Provides access to the element at the given index in the concurrent vector. This method is concurrenc...
Definition: concurrent_vector.h:936
void swap(concurrent_vector< _Ty, _Ax > &_A, concurrent_vector< _Ty, _Ax > &_B)
Exchanges the elements of two concurrent_vector objects.
Definition: concurrent_vector.h:1962
static _Size_type _Segment_size(_Segment_index_t _K)
Definition: concurrent_vector.h:120
_In_ int _Val
Definition: vcruntime_string.h:62
size_type _I
Definition: concurrent_vector.h:1485
details::_Vector_iterator< concurrent_vector, _Ty > iterator
A type that provides a random-access iterator that can read any element in a concurrent vector...
Definition: concurrent_vector.h:489
The Concurrency namespace provides classes and functions that provide access to the Concurrency Runti...
Definition: agents.h:43
static _Segment_index_t _Segment_base_index_of(_Segment_index_t &_Index)
Definition: concurrent_vector.h:113
Definition: concurrent_vector.h:1447
void swap(concurrent_vector &_Vector)
Swaps the contents of two concurrent vectors. This method is not concurrency-safe.
Definition: concurrent_vector.h:1391
void _Internal_assign(_I _First, _I _Last, _Is_integer_tag< true > *)
Definition: concurrent_vector.h:1451
Definition: concurrent_vector.h:177
friend ptrdiff_t operator-(const _Vector_iterator< _C, _Ty > &, const _Vector_iterator< _C, _U > &)
int ptrdiff_t
Definition: vcruntime.h:199
_Ty & reference
A type that provides a reference to an element stored in a concurrent vector.
Definition: concurrent_vector.h:463
_Internal_loop_guide(size_type _NTrials, void *_Ptr)
Definition: concurrent_vector.h:1486
void * _My_array
Definition: concurrent_vector.h:83
const pointer _My_array
Definition: concurrent_vector.h:1483
iterator grow_by(size_type _Delta)
Grows this concurrent vector by _Delta elements. This method is concurrency-safe.
Definition: concurrent_vector.h:784
static void __cdecl _Initialize_array(void *_Begin, const void *, size_type _N)
Definition: concurrent_vector.h:1659
static const _Segment_index_t _Pointers_per_long_table
Definition: concurrent_vector.h:78
void assign(size_type _N, const_reference _Item)
Erases the elements of the concurrent vector and assigns to it either _N copies of _Item ...
Definition: concurrent_vector.h:1352
details::_Allocator_base< _Ty, _Ax >::_Allocator_type allocator_type
A type that represents the allocator class for the concurrent vector.
Definition: concurrent_vector.h:445
void _Copy(const void *_Src)
Definition: concurrent_vector.h:1501
_Container * _My_vector
Definition: concurrent_vector.h:180
_Vector_iterator & operator--()
Definition: concurrent_vector.h:286
_CONCRTIMP void * _Internal_push_back(_Size_type _Element_size, _Size_type &_Index)
concurrent_vector(concurrent_vector &&_Vector)
Constructs a concurrent vector.
Definition: concurrent_vector.h:610
void _Init(const void *_Src)
Definition: concurrent_vector.h:1496
const _Ty & const_reference
A type that provides a reference to a const element stored in a concurrent vector for reading and per...
Definition: concurrent_vector.h:470
_Iter_diff_t< _InIt > distance(_InIt _First, _InIt _Last)
Definition: xutility:1124
concurrent_vector(size_type _N)
Constructs a concurrent vector.
Definition: concurrent_vector.h:635
static void __cdecl _Initialize_array_by(void *_Begin, const void *_Src, size_type _N)
Definition: concurrent_vector.h:1665
size_type max_size() const
Returns the maximum number of elements the concurrent vector can hold. This method is concurrency-saf...
Definition: concurrent_vector.h:1097
void shrink_to_fit()
Compacts the internal representation of the concurrent vector to reduce fragmentation and optimize me...
Definition: concurrent_vector.h:1536
_Allocator_base()
Definition: concurrent_vector.h:393
reference back()
Returns a reference or a const reference to the last element in the concurrent vector. If the concurrent vector is empty, the return value is undefined. This method is concurrency-safe.
Definition: concurrent_vector.h:1302
reverse_iterator rbegin()
Returns an iterator of type reverse_iterator or const_reverse_iterator to the beginning of the conc...
Definition: concurrent_vector.h:1167
concurrent_vector< _Ty, _Ax > _Myt
Definition: concurrent_vector.h:428
size_t _Segment_index_t
Definition: concurrent_vector.h:70
_Vector_iterator & operator++()
Definition: concurrent_vector.h:266
_Value & operator[](ptrdiff_t _K) const
Definition: concurrent_vector.h:256
concurrent_vector & operator=(const concurrent_vector &_Vector)
Assigns the contents of another concurrent_vector object to this one. This method is not concurrency-...
Definition: concurrent_vector.h:720
unsigned int size_t
Definition: sourceannotations.h:19
void resize(size_type _N, const _Ty &_Val)
Changes the size of the concurrent vector to the requested size, deleting or adding elements as neces...
Definition: concurrent_vector.h:1085
_Ty & _Internal_subscript_with_exceptions(size_type _Index) const
Definition: concurrent_vector.h:1589
void internal_assign_iterators(_I _First, _I _Last)
Definition: concurrent_vector.h:1630
const_reference at(size_type _Index) const
Provides access to the element at the given index in the concurrent vector. This method is concurrenc...
Definition: concurrent_vector.h:961
_Size_type _Internal_grow_segment(const _Size_type _Start, _Size_type _Finish, _Size_type _Element_size, _Segment_t **_PPSegment, _Size_type *_PSegStart, _Size_type *_PSegFinish)
_CONCRTIMP void _Internal_copy(const _Concurrent_vector_base_v4 &_Src, _Size_type _Element_size, _My_internal_array_op2 _Copy)
_Subatomic< _Size_type > _My_early_size
Definition: concurrent_vector.h:160
void * _Table[_Pointers_per_long_table]
Definition: concurrent_vector.h:135
_CONCRTIMP void _Internal_assign(const _Concurrent_vector_base_v4 &_Src, _Size_type _Element_size, _My_internal_array_op1 _Destroy, _My_internal_array_op2 _Assign, _My_internal_array_op2 _Copy)
iterator begin()
Returns an iterator of type iterator or const_iterator to the beginning of the concurrent vector...
Definition: concurrent_vector.h:1111
const_iterator cend() const
Returns an iterator of type const_iterator to the end of the concurrent vector. This method is concu...
Definition: concurrent_vector.h:1235
std::reverse_iterator< const_iterator > const_reverse_iterator
A type that provides a random-access iterator that can read any const element in the concurrent vecto...
Definition: concurrent_vector.h:508
_Value * _My_item
Definition: concurrent_vector.h:187
static void __cdecl _Assign_array(void *_Dst, const void *_Src, size_type _N)
Definition: concurrent_vector.h:1676
_Concurrent_vector_base_v4 _Concurrent_vector_base
Definition: concurrent_vector.h:172
_CONCRTIMP _Segment_index_t _Internal_clear(_My_internal_array_op1 _Destroy)
::Concurrency::details::_Concurrent_vector_base_v4 & _Internal_vector_base()
Definition: concurrent_vector.h:1426
The concurrent_vector class is a sequence container class that allows random access to any element...
Definition: concurrent_vector.h:56
_Vector_iterator operator--(int)
Definition: concurrent_vector.h:315
void assign(_InputIterator _Begin, _InputIterator _End)
Erases the elements of the concurrent vector and assigns to it either _N copies of _Item ...
Definition: concurrent_vector.h:1378
_Concurrent_vector_base_v4()
Definition: concurrent_vector.h:96
void resize(size_type _N)
Changes the size of the concurrent vector to the requested size, deleting or adding elements as neces...
Definition: concurrent_vector.h:1060
_Vector_iterator< _Container, _Ty > operator+(ptrdiff_t _Offset, const _Vector_iterator< _Container, _Ty > &_Vec)
Definition: concurrent_vector.h:338
void(__cdecl * _My_internal_array_op1)(void *_Begin, _Size_type _N)
Definition: concurrent_vector.h:126
static void __cdecl _Copy_array(void *_Dst, const void *_Src, size_type _N)
Definition: concurrent_vector.h:1671
static void *__cdecl _Internal_allocator(::Concurrency::details::_Concurrent_vector_base_v4 &_Vb, size_t _K)
Definition: concurrent_vector.h:1430
iterator push_back(const_reference _Item)
Appends the given item to the end of the concurrent vector. This method is concurrency-safe.
Definition: concurrent_vector.h:843
static _Segment_index_t _Segment_base(_Segment_index_t _K)
Definition: concurrent_vector.h:108
_Vector_iterator & operator+=(ptrdiff_t _Offset)
Definition: concurrent_vector.h:232
const_reverse_iterator rbegin() const
Returns an iterator of type reverse_iterator or const_reverse_iterator to the beginning the concurr...
Definition: concurrent_vector.h:1195
static const _Segment_index_t _Default_initial_segments
Definition: concurrent_vector.h:74
_CONCRTIMP void * _Internal_compact(_Size_type _Element_size, void *_Table, _My_internal_array_op1 _Destroy, _My_internal_array_op2 _Copy)
Definition: concurrent_vector.h:1480
static const _Segment_index_t _Pointers_per_short_table
Definition: concurrent_vector.h:77
_Subatomic< _Size_type > _My_first_block
Definition: concurrent_vector.h:157
_Ty value_type
A type that represents the data type stored in a concurrent vector.
Definition: concurrent_vector.h:451
details::_Vector_iterator< concurrent_vector, const _Ty > const_iterator
A type that provides a random-access iterator that can read a const element in a concurrent vector...
Definition: concurrent_vector.h:495
const_iterator end() const
Returns an iterator of type iterator or const_iterator to the end of the concurrent vector...
Definition: concurrent_vector.h:1153
_Segment_t _My_storage[_Pointers_per_short_table]
Definition: concurrent_vector.h:92
size_t _My_index
Definition: concurrent_vector.h:183
void _Iterate(_It &_Src)
Definition: concurrent_vector.h:1511
void _Internal_free_segments(void *_Table[], _Segment_index_t _K, _Segment_index_t _First_block)
Definition: concurrent_vector.h:1553
void _Internal_assign(_I _First, _I _Last, _Is_integer_tag< false > *)
Definition: concurrent_vector.h:1457
friend _Vector_iterator< _C, _Ty > operator+(ptrdiff_t _Offset, const _Vector_iterator< _C, _Ty > &_Vec)
_Vector_iterator operator-(ptrdiff_t _Offset) const
Definition: concurrent_vector.h:238
std::enable_if< details::_Is_extent_or_index< _Tuple_type< _Rank > >::value, bool >::type operator!=(const _Tuple_type< _Rank > &_Lhs, const _Tuple_type< _Rank > &_Rhs) __GPU
Definition: amp.h:829
const_iterator cbegin() const
Returns an iterator of type const_iterator to the beginning of the concurrent vector. This method is concurrency-safe.
Definition: concurrent_vector.h:1222
const size_type _N
Definition: concurrent_vector.h:1484
#define _CONCRTIMP
Definition: crtdefs.h:48
const_reverse_iterator crbegin() const
Returns an iterator of type const_reverse_iterator to the beginning of the concurrent vector...
Definition: concurrent_vector.h:1248
constexpr remove_reference< _Ty >::type && move(_Ty &&_Arg) _NOEXCEPT
Definition: type_traits:1290
const_reference back() const
Returns a reference or a const reference to the last element in the concurrent_vector. If the concurrent vector is empty, the return value is undefined. This method is concurrency-safe.
Definition: concurrent_vector.h:1317
bool operator>=(const concurrent_vector< _Ty, A1 > &_A, const concurrent_vector< _Ty, A2 > &_B)
Tests if the concurrent_vector object on the left side of the operator is greater than or equal to th...
Definition: concurrent_vector.h:1926
const_iterator begin() const
Returns an iterator of type iterator or const_iterator to the beginning of the concurrent vector...
Definition: concurrent_vector.h:1139
void reserve(size_type _N)
Allocates enough space to grow the concurrent vector to size _N without having to allocate more memo...
Definition: concurrent_vector.h:1026
Definition: concurrent_vector.h:386
const_reverse_iterator crend() const
Returns an iterator of type const_reverse_iterator to the end of the concurrent vector. This method is concurrency-safe.
Definition: concurrent_vector.h:1261
_Ty & _Internal_subscript(size_type _Index) const
Definition: concurrent_vector.h:1575
#define _BAD_ALLOC_MARKER
Definition: concurrent_vector.h:62
void operator=(const _Internal_loop_guide &)
ptrdiff_t difference_type
Definition: concurrent_vector.h:324
_CRT_BEGIN_C_HEADER typedef void(__CRTDECL *unexpected_handler)()
_Value & reference
Definition: concurrent_vector.h:327
void _Destroy(_Ptrty _Ptr)
Definition: xmemory0:287
details::_Concurrent_vector_base_v4::_Size_type size_type
A type that counts the number of elements in a concurrent vector.
Definition: concurrent_vector.h:439
bool operator>=(const _Vector_iterator< _Container, _Ty > &_I, const _Vector_iterator< _Container, _U > &_J)
Definition: concurrent_vector.h:368
bool operator>(const _Vector_iterator< _Container, _Ty > &_I, const _Vector_iterator< _Container, _U > &_J)
Definition: concurrent_vector.h:362
concurrent_vector & operator=(concurrent_vector &&_Vector)
Assigns the contents of another concurrent_vector object to this one. This method is not concurrency-...
Definition: concurrent_vector.h:761
concurrent_vector(const concurrent_vector< _Ty, M > &_Vector, const allocator_type &_Al=allocator_type())
Constructs a concurrent vector.
Definition: concurrent_vector.h:584
concurrent_vector & operator=(const concurrent_vector< _Ty, M > &_Vector)
Assigns the contents of another concurrent_vector object to this one. This method is not concurrency-...
Definition: concurrent_vector.h:741
friend bool operator==(const _Vector_iterator< _C, _Ty > &, const _Vector_iterator< _C, _U > &)
bool operator!=(const _Concurrent_queue_iterator< _C, _Ty > &_I, const _Concurrent_queue_iterator< _C, _U > &_J)
Definition: concurrent_queue.h:324
allocator_type get_allocator() const
Returns a copy of the allocator used to construct the concurrent vector. This method is concurrency-s...
Definition: concurrent_vector.h:1331
bool empty() const
Tests if the concurrent vector is empty at the time this method is called. This method is concurrency...
Definition: concurrent_vector.h:992
_CONCRTIMP void _Internal_reserve(_Size_type _N, _Size_type _Element_size, _Size_type _Max_size)
iterator grow_by(size_type _Delta, const_reference _Item)
Grows this concurrent vector by _Delta elements. This method is concurrency-safe.
Definition: concurrent_vector.h:805
_Subatomic< _Segment_t * > _My_segment
Definition: concurrent_vector.h:163
bool operator>(const concurrent_vector< _Ty, A1 > &_A, const concurrent_vector< _Ty, A2 > &_B)
Tests if the concurrent_vector object on the left side of the operator is greater than the concurrent...
Definition: concurrent_vector.h:1850
static void __cdecl _Destroy_array(void *_Begin, size_type _N)
Definition: concurrent_vector.h:1685
bool lexicographical_compare(_InIt1 _First1, _InIt1 _Last1, _InIt2 _First2, _InIt2 _Last2)
Definition: memory:830
_In_ int _Value
Definition: setjmp.h:173
ptrdiff_t operator-(const _Vector_iterator< _Container, _Ty > &_I, const _Vector_iterator< _Container, _U > &_J)
Definition: concurrent_vector.h:380
const_reference operator[](size_type _Index) const
Provides read access to element at the given index in the concurrent vector. This method is concurren...
Definition: concurrent_vector.h:911
friend class _Helper
Definition: concurrent_vector.h:168
std::reverse_iterator< iterator > reverse_iterator
A type that provides a random-access iterator that can read any element in a reversed concurrent vect...
Definition: concurrent_vector.h:502
_CONCRTIMP void _Internal_resize(_Size_type _New_size, _Size_type _Element_size, _Size_type _Max_size, _My_internal_array_op1 _Destroy, _My_internal_array_op2 _Init, const void *_Src)
_FwdIt _Last
Definition: algorithm:1936
void clear()
Erases all elements in the concurrent vector. This method is not concurrency-safe.
Definition: concurrent_vector.h:1409
size_type size() const
Returns the number of elements in the concurrent vector. This method is concurrency-safe.
Definition: concurrent_vector.h:978
_Ax::template rebind< _Ty >::other _Allocator_type
Definition: concurrent_vector.h:390
_CONCRTIMP void _Internal_swap(_Concurrent_vector_base_v4 &)
void _Internal_assign(size_type _N, const_reference _Item)
Definition: concurrent_vector.h:1604
std::random_access_iterator_tag iterator_category
Definition: concurrent_vector.h:328
iterator end()
Returns an iterator of type iterator or const_iterator to the end of the concurrent vector...
Definition: concurrent_vector.h:1125
reference front()
Returns a reference or a const reference to the first element in the concurrent vector. If the concurrent vector is empty, the return value is undefined. This method is concurrency-safe.
Definition: concurrent_vector.h:1274
concurrent_vector(_InputIterator _Begin, _InputIterator _End, const allocator_type &_Al=allocator_type())
Constructs a concurrent vector.
Definition: concurrent_vector.h:703
_Ty * pointer
A type that provides a pointer to an element in a concurrent vector.
Definition: concurrent_vector.h:476
_Allocator_type _My_allocator
Definition: concurrent_vector.h:391
_Segment_index_t _First_block
Definition: concurrent_vector.h:134