Dash Core Source Documentation (0.16.0.1)

Find detailed information regarding the Dash Core source code.

prevector.h
Go to the documentation of this file.
1 // Copyright (c) 2015 The Bitcoin Core developers
2 // Distributed under the MIT software license, see the accompanying
3 // file COPYING or http://www.opensource.org/licenses/mit-license.php.
4 
5 #ifndef BITCOIN_PREVECTOR_H
6 #define BITCOIN_PREVECTOR_H
7 
8 #include <assert.h>
9 #include <stdlib.h>
10 #include <stdint.h>
11 #include <string.h>
12 
13 #include <cstddef>
14 #include <iterator>
15 #include <type_traits>
16 
17 #include <compat.h>
18 
19 #pragma pack(push, 1)
20 
38 template<unsigned int N, typename T, typename Size = uint32_t, typename Diff = int32_t>
39 class prevector {
40 public:
41  typedef Size size_type;
42  typedef Diff difference_type;
43  typedef T value_type;
45  typedef const value_type& const_reference;
46  typedef value_type* pointer;
47  typedef const value_type* const_pointer;
48 
49  class iterator {
50  T* ptr;
51  public:
52  typedef Diff difference_type;
53  typedef T value_type;
54  typedef T* pointer;
55  typedef T& reference;
56  typedef std::random_access_iterator_tag iterator_category;
57  iterator(T* ptr_) : ptr(ptr_) {}
58  T& operator*() const { return *ptr; }
59  T* operator->() const { return ptr; }
60  T& operator[](size_type pos) { return ptr[pos]; }
61  const T& operator[](size_type pos) const { return ptr[pos]; }
62  iterator& operator++() { ptr++; return *this; }
63  iterator& operator--() { ptr--; return *this; }
64  iterator operator++(int) { iterator copy(*this); ++(*this); return copy; }
65  iterator operator--(int) { iterator copy(*this); --(*this); return copy; }
66  difference_type friend operator-(iterator a, iterator b) { return (&(*a) - &(*b)); }
67  iterator operator+(size_type n) { return iterator(ptr + n); }
68  iterator& operator+=(size_type n) { ptr += n; return *this; }
69  iterator operator-(size_type n) { return iterator(ptr - n); }
70  iterator& operator-=(size_type n) { ptr -= n; return *this; }
71  bool operator==(iterator x) const { return ptr == x.ptr; }
72  bool operator!=(iterator x) const { return ptr != x.ptr; }
73  bool operator>=(iterator x) const { return ptr >= x.ptr; }
74  bool operator<=(iterator x) const { return ptr <= x.ptr; }
75  bool operator>(iterator x) const { return ptr > x.ptr; }
76  bool operator<(iterator x) const { return ptr < x.ptr; }
77  };
78 
80  T* ptr;
81  public:
82  typedef Diff difference_type;
83  typedef T value_type;
84  typedef T* pointer;
85  typedef T& reference;
86  typedef std::bidirectional_iterator_tag iterator_category;
87  reverse_iterator(T* ptr_) : ptr(ptr_) {}
88  T& operator*() { return *ptr; }
89  const T& operator*() const { return *ptr; }
90  T* operator->() { return ptr; }
91  const T* operator->() const { return ptr; }
92  reverse_iterator& operator--() { ptr++; return *this; }
93  reverse_iterator& operator++() { ptr--; return *this; }
94  reverse_iterator operator++(int) { reverse_iterator copy(*this); ++(*this); return copy; }
95  reverse_iterator operator--(int) { reverse_iterator copy(*this); --(*this); return copy; }
96  bool operator==(reverse_iterator x) const { return ptr == x.ptr; }
97  bool operator!=(reverse_iterator x) const { return ptr != x.ptr; }
98  };
99 
101  const T* ptr;
102  public:
103  typedef Diff difference_type;
104  typedef const T value_type;
105  typedef const T* pointer;
106  typedef const T& reference;
107  typedef std::random_access_iterator_tag iterator_category;
108  const_iterator(const T* ptr_) : ptr(ptr_) {}
109  const_iterator(iterator x) : ptr(&(*x)) {}
110  const T& operator*() const { return *ptr; }
111  const T* operator->() const { return ptr; }
112  const T& operator[](size_type pos) const { return ptr[pos]; }
113  const_iterator& operator++() { ptr++; return *this; }
114  const_iterator& operator--() { ptr--; return *this; }
115  const_iterator operator++(int) { const_iterator copy(*this); ++(*this); return copy; }
116  const_iterator operator--(int) { const_iterator copy(*this); --(*this); return copy; }
117  difference_type friend operator-(const_iterator a, const_iterator b) { return (&(*a) - &(*b)); }
119  const_iterator& operator+=(size_type n) { ptr += n; return *this; }
121  const_iterator& operator-=(size_type n) { ptr -= n; return *this; }
122  bool operator==(const_iterator x) const { return ptr == x.ptr; }
123  bool operator!=(const_iterator x) const { return ptr != x.ptr; }
124  bool operator>=(const_iterator x) const { return ptr >= x.ptr; }
125  bool operator<=(const_iterator x) const { return ptr <= x.ptr; }
126  bool operator>(const_iterator x) const { return ptr > x.ptr; }
127  bool operator<(const_iterator x) const { return ptr < x.ptr; }
128  };
129 
131  const T* ptr;
132  public:
133  typedef Diff difference_type;
134  typedef const T value_type;
135  typedef const T* pointer;
136  typedef const T& reference;
137  typedef std::bidirectional_iterator_tag iterator_category;
138  const_reverse_iterator(const T* ptr_) : ptr(ptr_) {}
140  const T& operator*() const { return *ptr; }
141  const T* operator->() const { return ptr; }
142  const_reverse_iterator& operator--() { ptr++; return *this; }
143  const_reverse_iterator& operator++() { ptr--; return *this; }
146  bool operator==(const_reverse_iterator x) const { return ptr == x.ptr; }
147  bool operator!=(const_reverse_iterator x) const { return ptr != x.ptr; }
148  };
149 
150 private:
153  char direct[sizeof(T) * N];
154  struct {
156  char* indirect;
157  };
158  } _union;
159 
160  T* direct_ptr(difference_type pos) { return reinterpret_cast<T*>(_union.direct) + pos; }
161  const T* direct_ptr(difference_type pos) const { return reinterpret_cast<const T*>(_union.direct) + pos; }
162  T* indirect_ptr(difference_type pos) { return reinterpret_cast<T*>(_union.indirect) + pos; }
163  const T* indirect_ptr(difference_type pos) const { return reinterpret_cast<const T*>(_union.indirect) + pos; }
164  bool is_direct() const { return _size <= N; }
165 
166  void change_capacity(size_type new_capacity) {
167  if (new_capacity <= N) {
168  if (!is_direct()) {
169  T* indirect = indirect_ptr(0);
170  T* src = indirect;
171  T* dst = direct_ptr(0);
172  memcpy(dst, src, size() * sizeof(T));
173  free(indirect);
174  _size -= N + 1;
175  }
176  } else {
177  if (!is_direct()) {
178  /* FIXME: Because malloc/realloc here won't call new_handler if allocation fails, assert
179  success. These should instead use an allocator or new/delete so that handlers
180  are called as necessary, but performance would be slightly degraded by doing so. */
181  _union.indirect = static_cast<char*>(realloc(_union.indirect, ((size_t)sizeof(T)) * new_capacity));
182  assert(_union.indirect);
183  _union.capacity = new_capacity;
184  } else {
185  char* new_indirect = static_cast<char*>(malloc(((size_t)sizeof(T)) * new_capacity));
186  assert(new_indirect);
187  T* src = direct_ptr(0);
188  T* dst = reinterpret_cast<T*>(new_indirect);
189  memcpy(dst, src, size() * sizeof(T));
190  _union.indirect = new_indirect;
191  _union.capacity = new_capacity;
192  _size += N + 1;
193  }
194  }
195  }
196 
197  T* item_ptr(difference_type pos) { return is_direct() ? direct_ptr(pos) : indirect_ptr(pos); }
198  const T* item_ptr(difference_type pos) const { return is_direct() ? direct_ptr(pos) : indirect_ptr(pos); }
199 
200  void fill(T* dst, ptrdiff_t count) {
201  if (IS_TRIVIALLY_CONSTRUCTIBLE<T>::value) {
202  // The most common use of prevector is where T=unsigned char. For
203  // trivially constructible types, we can use memset() to avoid
204  // looping.
205  ::memset(dst, 0, count * sizeof(T));
206  } else {
207  for (auto i = 0; i < count; ++i) {
208  new(static_cast<void*>(dst + i)) T();
209  }
210  }
211  }
212 
213  void fill(T* dst, ptrdiff_t count, const T& value) {
214  for (auto i = 0; i < count; ++i) {
215  new(static_cast<void*>(dst + i)) T(value);
216  }
217  }
218 
219  template<typename InputIterator>
220  void fill(T* dst, InputIterator first, InputIterator last) {
221  while (first != last) {
222  new(static_cast<void*>(dst)) T(*first);
223  ++dst;
224  ++first;
225  }
226  }
227 
228  void fill(T* dst, const_iterator first, const_iterator last) {
229  ptrdiff_t count = last - first;
230  fill(dst, &*first, count);
231  }
232 
233  void fill(T* dst, const T* src, ptrdiff_t count) {
234  if (IS_TRIVIALLY_CONSTRUCTIBLE<T>::value) {
235  ::memmove(dst, src, count * sizeof(T));
236  } else {
237  for (ptrdiff_t i = 0; i < count; i++) {
238  new(static_cast<void*>(dst)) T(*src);
239  ++dst;
240  ++src;
241  }
242  }
243  }
244 
245 public:
246  void assign(size_type n, const T& val) {
247  clear();
248  if (capacity() < n) {
249  change_capacity(n);
250  }
251  _size += n;
252  fill(item_ptr(0), n, val);
253  }
254 
255  template<typename InputIterator>
256  void assign(InputIterator first, InputIterator last) {
257  size_type n = last - first;
258  clear();
259  if (capacity() < n) {
260  change_capacity(n);
261  }
262  _size += n;
263  fill(item_ptr(0), first, last);
264  }
265 
266  prevector() : _size(0), _union{{}} {}
267 
268  explicit prevector(size_type n) : _size(0) {
269  resize(n);
270  }
271 
272  explicit prevector(size_type n, const T& val = T()) : _size(0) {
273  change_capacity(n);
274  _size += n;
275  fill(item_ptr(0), n, val);
276  }
277 
278  template<typename InputIterator>
279  prevector(InputIterator first, InputIterator last) : _size(0) {
280  size_type n = last - first;
281  change_capacity(n);
282  _size += n;
283  fill(item_ptr(0), first, last);
284  }
285 
287  size_type n = other.size();
288  change_capacity(n);
289  _size += n;
290  fill(item_ptr(0), other.begin(), other.end());
291  }
292 
294  swap(other);
295  }
296 
298  if (&other == this) {
299  return *this;
300  }
301  assign(other.begin(), other.end());
302  return *this;
303  }
304 
306  swap(other);
307  return *this;
308  }
309 
310  size_type size() const {
311  return is_direct() ? _size : _size - N - 1;
312  }
313 
314  bool empty() const {
315  return size() == 0;
316  }
317 
318  iterator begin() { return iterator(item_ptr(0)); }
319  const_iterator begin() const { return const_iterator(item_ptr(0)); }
320  iterator end() { return iterator(item_ptr(size())); }
322 
327 
328  size_t capacity() const {
329  if (is_direct()) {
330  return N;
331  } else {
332  return _union.capacity;
333  }
334  }
335 
337  return *item_ptr(pos);
338  }
339 
340  const T& operator[](size_type pos) const {
341  return *item_ptr(pos);
342  }
343 
344  void resize(size_type new_size) {
345  size_type cur_size = size();
346  if (cur_size == new_size) {
347  return;
348  }
349  if (cur_size > new_size) {
350  erase(item_ptr(new_size), end());
351  return;
352  }
353  if (new_size > capacity()) {
354  change_capacity(new_size);
355  }
356  ptrdiff_t increase = new_size - cur_size;
357  fill(item_ptr(cur_size), increase);
358  _size += increase;
359  }
360 
361  void reserve(size_type new_capacity) {
362  if (new_capacity > capacity()) {
363  change_capacity(new_capacity);
364  }
365  }
366 
367  void shrink_to_fit() {
369  }
370 
371  void clear() {
372  resize(0);
373  }
374 
375  iterator insert(iterator pos, const T& value) {
376  size_type p = pos - begin();
377  size_type new_size = size() + 1;
378  if (capacity() < new_size) {
379  change_capacity(new_size + (new_size >> 1));
380  }
381  T* ptr = item_ptr(p);
382  memmove(ptr + 1, ptr, (size() - p) * sizeof(T));
383  _size++;
384  new(static_cast<void*>(ptr)) T(value);
385  return iterator(ptr);
386  }
387 
388  void insert(iterator pos, size_type count, const T& value) {
389  size_type p = pos - begin();
390  size_type new_size = size() + count;
391  if (capacity() < new_size) {
392  change_capacity(new_size + (new_size >> 1));
393  }
394  T* ptr = item_ptr(p);
395  memmove(ptr + count, ptr, (size() - p) * sizeof(T));
396  _size += count;
397  fill(item_ptr(p), count, value);
398  }
399 
400  template<typename InputIterator>
401  void insert(iterator pos, InputIterator first, InputIterator last) {
402  size_type p = pos - begin();
403  difference_type count = last - first;
404  size_type new_size = size() + count;
405  if (capacity() < new_size) {
406  change_capacity(new_size + (new_size >> 1));
407  }
408  T* ptr = item_ptr(p);
409  memmove(ptr + count, ptr, (size() - p) * sizeof(T));
410  _size += count;
411  fill(ptr, first, last);
412  }
413 
414  inline void resize_uninitialized(size_type new_size) {
415  // resize_uninitialized changes the size of the prevector but does not initialize it.
416  // If size < new_size, the added elements must be initialized explicitly.
417  if (capacity() < new_size) {
418  change_capacity(new_size);
419  _size += new_size - size();
420  return;
421  }
422  if (new_size < size()) {
423  erase(item_ptr(new_size), end());
424  } else {
425  _size += new_size - size();
426  }
427  }
428 
430  return erase(pos, pos + 1);
431  }
432 
434  // Erase is not allowed to the change the object's capacity. That means
435  // that when starting with an indirectly allocated prevector with
436  // size and capacity > N, the result may be a still indirectly allocated
437  // prevector with size <= N and capacity > N. A shrink_to_fit() call is
438  // necessary to switch to the (more efficient) directly allocated
439  // representation (with capacity N and size <= N).
440  iterator p = first;
441  char* endp = (char*)&(*end());
442  if (!std::is_trivially_destructible<T>::value) {
443  while (p != last) {
444  (*p).~T();
445  _size--;
446  ++p;
447  }
448  } else {
449  _size -= last - p;
450  }
451  memmove(&(*first), &(*last), endp - ((char*)(&(*last))));
452  return first;
453  }
454 
455  void push_back(const T& value) {
456  size_type new_size = size() + 1;
457  if (capacity() < new_size) {
458  change_capacity(new_size + (new_size >> 1));
459  }
460  new(item_ptr(size())) T(value);
461  _size++;
462  }
463 
464  void pop_back() {
465  erase(end() - 1, end());
466  }
467 
468  T& front() {
469  return *item_ptr(0);
470  }
471 
472  const T& front() const {
473  return *item_ptr(0);
474  }
475 
476  T& back() {
477  return *item_ptr(size() - 1);
478  }
479 
480  const T& back() const {
481  return *item_ptr(size() - 1);
482  }
483 
485  std::swap(_union, other._union);
486  std::swap(_size, other._size);
487  }
488 
490  if (!std::is_trivially_destructible<T>::value) {
491  clear();
492  }
493  if (!is_direct()) {
494  free(_union.indirect);
495  _union.indirect = nullptr;
496  }
497  }
498 
499  bool operator==(const prevector<N, T, Size, Diff>& other) const {
500  if (other.size() != size()) {
501  return false;
502  }
503  const_iterator b1 = begin();
504  const_iterator b2 = other.begin();
505  const_iterator e1 = end();
506  while (b1 != e1) {
507  if ((*b1) != (*b2)) {
508  return false;
509  }
510  ++b1;
511  ++b2;
512  }
513  return true;
514  }
515 
516  bool operator!=(const prevector<N, T, Size, Diff>& other) const {
517  return !(*this == other);
518  }
519 
520  bool operator<(const prevector<N, T, Size, Diff>& other) const {
521  if (size() < other.size()) {
522  return true;
523  }
524  if (size() > other.size()) {
525  return false;
526  }
527  const_iterator b1 = begin();
528  const_iterator b2 = other.begin();
529  const_iterator e1 = end();
530  while (b1 != e1) {
531  if ((*b1) < (*b2)) {
532  return true;
533  }
534  if ((*b2) < (*b1)) {
535  return false;
536  }
537  ++b1;
538  ++b2;
539  }
540  return false;
541  }
542 
543  size_t allocated_memory() const {
544  if (is_direct()) {
545  return 0;
546  } else {
547  return ((size_t)(sizeof(T))) * _union.capacity;
548  }
549  }
550 
552  return item_ptr(0);
553  }
554 
555  const value_type* data() const {
556  return item_ptr(0);
557  }
558 
559  template<typename V>
560  static void assign_to(const_iterator b, const_iterator e, V& v) {
561  // We know that internally the iterators are pointing to continues memory, so we can directly use the pointers here
562  // This avoids internal use of std::copy and operator++ on the iterators and instead allows efficient memcpy/memmove
563  if (IS_TRIVIALLY_CONSTRUCTIBLE<T>::value) {
564  auto s = e - b;
565  if (v.size() != s) {
566  v.resize(s);
567  }
568  ::memmove(v.data(), &*b, s);
569  } else {
570  v.assign(&*b, &*e);
571  }
572  }
573 };
574 
575 #pragma pack(pop)
576 
577 #endif // BITCOIN_PREVECTOR_H
bool operator!=(const prevector< N, T, Size, Diff > &other) const
Definition: prevector.h:516
T * direct_ptr(difference_type pos)
Definition: prevector.h:160
std::bidirectional_iterator_tag iterator_category
Definition: prevector.h:86
prevector & operator=(const prevector< N, T, Size, Diff > &other)
Definition: prevector.h:297
const value_type & const_reference
Definition: prevector.h:45
void fill(T *dst, const_iterator first, const_iterator last)
Definition: prevector.h:228
const_iterator operator--(int)
Definition: prevector.h:116
OutIter copy(Range &&r, OutIter out)
Definition: algorithm.hpp:168
void resize(size_type new_size)
Definition: prevector.h:344
const T * operator->() const
Definition: prevector.h:91
const T & operator[](size_type pos) const
Definition: prevector.h:61
const value_type * const_pointer
Definition: prevector.h:47
void assign(size_type n, const T &val)
Definition: prevector.h:246
T * indirect_ptr(difference_type pos)
Definition: prevector.h:162
iterator operator+(size_type n)
Definition: prevector.h:67
bool operator<=(const_iterator x) const
Definition: prevector.h:125
iterator operator-(size_type n)
Definition: prevector.h:69
T & back()
Definition: prevector.h:476
prevector(prevector< N, T, Size, Diff > &&other)
Definition: prevector.h:293
void assign(InputIterator first, InputIterator last)
Definition: prevector.h:256
void shrink_to_fit()
Definition: prevector.h:367
void pop_back()
Definition: prevector.h:464
T * operator->() const
Definition: prevector.h:59
reverse_iterator operator++(int)
Definition: prevector.h:94
iterator insert(iterator pos, const T &value)
Definition: prevector.h:375
void clear()
Definition: prevector.h:371
Size size_type
Definition: prevector.h:41
reverse_iterator operator--(int)
Definition: prevector.h:95
const T & operator[](size_type pos) const
Definition: prevector.h:112
void fill(T *dst, ptrdiff_t count, const T &value)
Definition: prevector.h:213
bool operator!=(iterator x) const
Definition: prevector.h:72
const_iterator & operator-=(size_type n)
Definition: prevector.h:121
const_reverse_iterator & operator--()
Definition: prevector.h:142
const_iterator & operator++()
Definition: prevector.h:113
iterator operator++(int)
Definition: prevector.h:64
void insert(iterator pos, InputIterator first, InputIterator last)
Definition: prevector.h:401
const_reverse_iterator operator--(int)
Definition: prevector.h:145
void fill(T *dst, InputIterator first, InputIterator last)
Definition: prevector.h:220
const T & back() const
Definition: prevector.h:480
const T * operator->() const
Definition: prevector.h:141
iterator operator--(int)
Definition: prevector.h:65
const value_type * data() const
Definition: prevector.h:555
const T * direct_ptr(difference_type pos) const
Definition: prevector.h:161
size_t allocated_memory() const
Definition: prevector.h:543
bool operator==(const prevector< N, T, Size, Diff > &other) const
Definition: prevector.h:499
void resize_uninitialized(size_type new_size)
Definition: prevector.h:414
size_t capacity() const
Definition: prevector.h:328
const_reverse_iterator & operator++()
Definition: prevector.h:143
bool is_direct() const
Definition: prevector.h:164
~prevector()
Definition: prevector.h:489
void fill(T *dst, const T *src, ptrdiff_t count)
Definition: prevector.h:233
iterator(T *ptr_)
Definition: prevector.h:57
T & operator[](size_type pos)
Definition: prevector.h:60
bool operator==(const_reverse_iterator x) const
Definition: prevector.h:146
bool operator>=(iterator x) const
Definition: prevector.h:73
value_type * data()
Definition: prevector.h:551
prevector(const prevector< N, T, Size, Diff > &other)
Definition: prevector.h:286
prevector(size_type n, const T &val=T())
Definition: prevector.h:272
const_reverse_iterator operator++(int)
Definition: prevector.h:144
bool operator>=(const_iterator x) const
Definition: prevector.h:124
T value_type
Definition: prevector.h:43
const T * item_ptr(difference_type pos) const
Definition: prevector.h:198
iterator end()
Definition: prevector.h:320
Diff difference_type
Definition: prevector.h:42
void push_back(const T &value)
Definition: prevector.h:455
T & front()
Definition: prevector.h:468
prevector & operator=(prevector< N, T, Size, Diff > &&other)
Definition: prevector.h:305
value_type * pointer
Definition: prevector.h:46
const T & operator*() const
Definition: prevector.h:110
const_reverse_iterator rend() const
Definition: prevector.h:326
const_reverse_iterator rbegin() const
Definition: prevector.h:324
T & operator[](size_type pos)
Definition: prevector.h:336
void swap(prevector< N, T, Size, Diff > &other)
Definition: prevector.h:484
bool operator<=(iterator x) const
Definition: prevector.h:74
void insert(iterator pos, size_type count, const T &value)
Definition: prevector.h:388
const_iterator operator+(size_type n)
Definition: prevector.h:118
prevector(size_type n)
Definition: prevector.h:268
reverse_iterator rend()
Definition: prevector.h:325
const_reverse_iterator(reverse_iterator x)
Definition: prevector.h:139
bool operator>(const_iterator x) const
Definition: prevector.h:126
bool operator==(iterator x) const
Definition: prevector.h:71
reverse_iterator rbegin()
Definition: prevector.h:323
void fill(T *dst, ptrdiff_t count)
Definition: prevector.h:200
char direct[sizeof(T) *N]
Definition: prevector.h:153
iterator & operator+=(size_type n)
Definition: prevector.h:68
iterator erase(iterator pos)
Definition: prevector.h:429
bool operator<(iterator x) const
Definition: prevector.h:76
const_reverse_iterator(const T *ptr_)
Definition: prevector.h:138
const T & operator[](size_type pos) const
Definition: prevector.h:340
const_iterator(iterator x)
Definition: prevector.h:109
reverse_iterator & operator++()
Definition: prevector.h:93
Implements a drop-in replacement for std::vector<T> which stores up to N elements directly (without h...
Definition: prevector.h:39
T & operator*() const
Definition: prevector.h:58
bool operator!=(const_reverse_iterator x) const
Definition: prevector.h:147
const_iterator & operator--()
Definition: prevector.h:114
bool operator==(reverse_iterator x) const
Definition: prevector.h:96
const_iterator operator-(size_type n)
Definition: prevector.h:120
void reserve(size_type new_capacity)
Definition: prevector.h:361
const T * operator->() const
Definition: prevector.h:111
void change_capacity(size_type new_capacity)
Definition: prevector.h:166
const T & front() const
Definition: prevector.h:472
prevector(InputIterator first, InputIterator last)
Definition: prevector.h:279
T * item_ptr(difference_type pos)
Definition: prevector.h:197
void * memcpy(void *a, const void *b, size_t c)
bool empty() const
Definition: prevector.h:314
bool operator>(iterator x) const
Definition: prevector.h:75
reverse_iterator & operator--()
Definition: prevector.h:92
std::random_access_iterator_tag iterator_category
Definition: prevector.h:56
union prevector::direct_or_indirect _union
const T & operator*() const
Definition: prevector.h:89
std::bidirectional_iterator_tag iterator_category
Definition: prevector.h:137
static int count
Definition: tests.c:45
const_iterator operator++(int)
Definition: prevector.h:115
iterator begin()
Definition: prevector.h:318
std::random_access_iterator_tag iterator_category
Definition: prevector.h:107
size_type size() const
Definition: prevector.h:310
iterator erase(iterator first, iterator last)
Definition: prevector.h:433
bool operator!=(const_iterator x) const
Definition: prevector.h:123
static void assign_to(const_iterator b, const_iterator e, V &v)
Definition: prevector.h:560
iterator & operator++()
Definition: prevector.h:62
size_type _size
Definition: prevector.h:151
difference_type friend operator-(iterator a, iterator b)
Definition: prevector.h:66
const T * indirect_ptr(difference_type pos) const
Definition: prevector.h:163
bool operator<(const_iterator x) const
Definition: prevector.h:127
const_iterator end() const
Definition: prevector.h:321
iterator & operator-=(size_type n)
Definition: prevector.h:70
void * memmove(void *a, const void *b, size_t c)
const_iterator begin() const
Definition: prevector.h:319
iterator & operator--()
Definition: prevector.h:63
bool operator==(const_iterator x) const
Definition: prevector.h:122
bool operator!=(reverse_iterator x) const
Definition: prevector.h:97
const_iterator & operator+=(size_type n)
Definition: prevector.h:119
const_iterator(const T *ptr_)
Definition: prevector.h:108
value_type & reference
Definition: prevector.h:44
difference_type friend operator-(const_iterator a, const_iterator b)
Definition: prevector.h:117
Released under the MIT license