ManaPlus
msemsevector.h
Go to the documentation of this file.
1 
2 // Copyright (c) 2015 Noah Lopez
3 // Use, modification, and distribution is subject to the Boost Software
4 // License, Version 1.0. (See accompanying file LICENSE_1_0.txt or copy at
5 // http://www.boost.org/LICENSE_1_0.txt)
6 
7 #ifndef MSEMSEVECTOR_H
8 #define MSEMSEVECTOR_H
9 
10 /*compiler specific defines*/
11 #ifdef _MSC_VER
12 #if (1700 > _MSC_VER)
13 #define MSVC2010_COMPATIBLE 1
14 #endif /*(1700 > _MSC_VER)*/
15 #if (1900 > _MSC_VER)
16 #define MSVC2013_COMPATIBLE 1
17 #endif /*(1900 > _MSC_VER)*/
18 #else /*_MSC_VER*/
19 #if (defined(__GNUC__) || defined(__GNUG__))
20 #define GPP_COMPATIBLE 1
21 #if ((5 > __GNUC__) && (!defined(__clang__)))
22 #define GPP4P8_COMPATIBLE 1
23 #endif /*((5 > __GNUC__) && (!defined(__clang__)))*/
24 #endif
25 #endif /*_MSC_VER*/
26 
27 //define MSE_MSEVECTOR_USE_MSE_PRIMITIVES 1
28 #ifdef MSE_MSEVECTOR_USE_MSE_PRIMITIVES
30 #endif // MSE_MSEVECTOR_USE_MSE_PRIMITIVES
31 
32 #include <vector>
33 #include <assert.h>
34 #include <memory>
35 #include <unordered_map>
36 #include <functional>
37 #include <climits> // ULONG_MAX
38 #include <stdexcept>
39 
40 #ifdef MSE_CUSTOM_THROW_DEFINITION
41 #include <iostream>
42 #define MSE_THROW(x) MSE_CUSTOM_THROW_DEFINITION(x)
43 #else // MSE_CUSTOM_THROW_DEFINITION
44 #define MSE_THROW(x) throw(x)
45 #endif // MSE_CUSTOM_THROW_DEFINITION
46 
47 namespace mse {
48 
49 #ifdef MSE_MSEVECTOR_USE_MSE_PRIMITIVES
50  typedef mse::CSize_t msev_size_t;
51  typedef mse::CInt msev_int;
52  typedef bool msev_bool; // no added safety benefit to using mse::CBool in this case
53  #define msev_as_a_size_t as_a_size_t
54 #else // MSE_MSEVECTOR_USE_MSE_PRIMITIVES
55 #if SIZE_MAX <= ULONG_MAX
56 #define MSE_MSEVECTOR_BASE_INTEGER_TYPE long int
57 #else // SIZE_MAX <= ULONG_MAX
58 #define MSE_MSEVECTOR_BASE_INTEGER_TYPE long long int
59 #endif // SIZE_MAX <= ULONG_MAX
60 
61  typedef size_t msev_size_t;
63  typedef bool msev_bool;
64  typedef size_t msev_as_a_size_t;
65 #endif // MSE_MSEVECTOR_USE_MSE_PRIMITIVES
66 
67 
68  class msevector_range_error : public std::range_error { public:
69  using std::range_error::range_error;
70  };
71  class msevector_null_dereference_error : public std::logic_error { public:
72  using std::logic_error::logic_error;
73  };
74 
75  /* msev_pointer behaves similar to native pointers. It's a bit safer in that it initializes to
76  nullptr by default and checks for attempted dereference of null pointers. */
77  template<typename _Ty>
78  class msev_pointer {
79  public:
81  msev_pointer(_Ty* ptr) : m_ptr(ptr) {}
82  msev_pointer(const msev_pointer<_Ty>& src) : m_ptr(src.m_ptr) {}
83 
84  _Ty& operator*() const {
85 #ifndef MSE_DISABLE_MSEAR_POINTER_CHECKS
86  if (nullptr == m_ptr) { MSE_THROW(msevector_null_dereference_error("attempt to dereference null pointer - mse::msev_pointer")); }
87 #endif /*MSE_DISABLE_MSEAR_POINTER_CHECKS*/
88  return (*m_ptr);
89  }
90  _Ty* operator->() const {
91 #ifndef MSE_DISABLE_MSEAR_POINTER_CHECKS
92  if (nullptr == m_ptr) { MSE_THROW(msevector_null_dereference_error("attempt to dereference null pointer - mse::msev_pointer")); }
93 #endif /*MSE_DISABLE_MSEAR_POINTER_CHECKS*/
94  return m_ptr;
95  }
97  m_ptr = ptr;
98  return (*this);
99  }
100  bool operator==(const msev_pointer _Right_cref) const { return (_Right_cref.m_ptr == m_ptr); }
101  bool operator!=(const msev_pointer _Right_cref) const { return (!((*this) == _Right_cref)); }
102  bool operator==(const _Ty* _Right_cref) const { return (_Right_cref == m_ptr); }
103  bool operator!=(const _Ty* _Right_cref) const { return (!((*this) == _Right_cref)); }
104 
105  bool operator!() const { return (!m_ptr); }
106  operator bool() const { return (m_ptr != nullptr); }
107 
108  operator _Ty*() const { return m_ptr; }
109 
110  _Ty* m_ptr;
111  };
112 
113 #ifndef _XSTD
114 #define _XSTD ::std::
115 #endif /*_XSTD*/
116 
117  template<class _Ty, _Ty _Val>
119  { // convenient template for integral constant types
120  static const _Ty value = _Val;
121 
122  typedef _Ty value_type;
124 
125  operator value_type() const
126  { // return stored value
127  return (value);
128  }
129  };
130 
131  template<class _Iter>
133  : public integral_constant<bool, !std::is_integral<_Iter>::value>
134  { // tests for reasonable iterator candidate
135  };
136  template<typename _InIter>
137  using _mse_RequireInputIter = typename std::enable_if<
138  std::is_convertible<typename std::iterator_traits<_InIter>::iterator_category, std::input_iterator_tag>::value
139  //_mse_Is_iterator<_InIter>::value
140  >::type;
141 
142  /* Note that, at the moment, msevector inherits publicly from std::vector. This is not intended to be a permanent
143  characteristic of msevector and any reference to, or interpretation of, an msevector as an std::vector is (and has
144  always been) depricated. msevector endeavors to support the subset of the std::vector interface that is compatible
145  with the security/safety goals of msevector. (The remaining part of the std::vector interface may be supported, as a
146  user option, for compatibility.)
147  In particular, keep in mind that std::vector does not have a virtual destructor, so deallocating an msevector as an
148  std::vector would result in memory leaks. */
149  template<class _Ty, class _A = std::allocator<_Ty> >
150  class msevector : public std::vector<_Ty, _A> {
151  public:
152  typedef std::vector<_Ty, _A> base_class;
154 
155  typedef typename base_class::value_type value_type;
156  //typedef typename base_class::size_type size_type;
158  //typedef typename base_class::difference_type difference_type;
160  typedef typename base_class::pointer pointer;
161  typedef typename base_class::const_pointer const_pointer;
162  typedef typename base_class::reference reference;
163  typedef typename base_class::const_reference const_reference;
164 
165  explicit msevector(const _A& _Al = _A())
166  : base_class(_Al), m_mmitset(*this) {
167  /*m_debug_size = size();*/
168  }
169  explicit msevector(size_type _N)
170  : base_class(msev_as_a_size_t(_N)), m_mmitset(*this) {
171  /*m_debug_size = size();*/
172  }
173  explicit msevector(size_type _N, const _Ty& _V, const _A& _Al = _A())
174  : base_class(msev_as_a_size_t(_N), _V, _Al), m_mmitset(*this) {
175  /*m_debug_size = size();*/
176  }
177  msevector(base_class&& _X) : base_class(std::move(_X)), m_mmitset(*this) { /*m_debug_size = size();*/ }
178  msevector(const base_class& _X) : base_class(_X), m_mmitset(*this) { /*m_debug_size = size();*/ }
179  msevector(_Myt&& _X) : base_class(std::move(_X)), m_mmitset(*this) { /*m_debug_size = size();*/ }
180  msevector(const _Myt& _X) : base_class(_X), m_mmitset(*this) { /*m_debug_size = size();*/ }
181  typedef typename base_class::const_iterator _It;
182  /* Note that safety cannot be guaranteed when using these constructors that take unsafe typename base_class::iterator and/or pointer parameters. */
183  msevector(_It _F, _It _L, const _A& _Al = _A()) : base_class(_F, _L, _Al), m_mmitset(*this) { /*m_debug_size = size();*/ }
184  msevector(const _Ty* _F, const _Ty* _L, const _A& _Al = _A()) : base_class(_F, _L, _Al), m_mmitset(*this) { /*m_debug_size = size();*/ }
185  template<class _Iter
186  //, class = typename std::enable_if<_mse_Is_iterator<_Iter>::value, void>::type
187  , class = _mse_RequireInputIter<_Iter> >
188  msevector(_Iter _First, _Iter _Last) : base_class(_First, _Last), m_mmitset(*this) { /*m_debug_size = size();*/ }
189  template<class _Iter
190  //, class = typename std::enable_if<_mse_Is_iterator<_Iter>::value, void>::type
191  , class = _mse_RequireInputIter<_Iter> >
192  //msevector(_Iter _First, _Iter _Last, const typename base_class::_Alloc& _Al) : base_class(_First, _Last, _Al), m_mmitset(*this) { /*m_debug_size = size();*/ }
193  msevector(_Iter _First, _Iter _Last, const _A& _Al) : base_class(_First, _Last, _Al), m_mmitset(*this) { /*m_debug_size = size();*/ }
194  _Myt& operator=(const base_class& _X) {
195  base_class::operator =(_X);
196  /*m_debug_size = size();*/
197  m_mmitset.reset();
198  return (*this);
199  }
200  _Myt& operator=(_Myt&& _X) {
201  operator=(std::move(static_cast<base_class&>(_X)));
202  m_mmitset.reset();
203  return (*this);
204  }
205  _Myt& operator=(const _Myt& _X) {
206  operator=(static_cast<const base_class&>(_X));
207  m_mmitset.reset();
208  return (*this);
209  }
210  void reserve(size_type _Count)
211  { // determine new minimum length of allocated storage
212  auto original_capacity = msev_size_t((*this).capacity());
213 
214  base_class::reserve(msev_as_a_size_t(_Count));
215 
216  auto new_capacity = msev_size_t((*this).capacity());
217  bool realloc_occured = (new_capacity != original_capacity);
218  if (realloc_occured) {
220  }
221  }
222  void shrink_to_fit() { // reduce capacity
223  auto original_capacity = msev_size_t((*this).capacity());
224 
225  base_class::shrink_to_fit();
226 
227  auto new_capacity = msev_size_t((*this).capacity());
228  bool realloc_occured = (new_capacity != original_capacity);
229  if (realloc_occured) {
231  }
232  }
233  void resize(size_type _N, const _Ty& _X = _Ty()) {
234  auto original_size = msev_size_t((*this).size());
235  auto original_capacity = msev_size_t((*this).capacity());
236  bool shrinking = (_N < original_size);
237 
238  base_class::resize(msev_as_a_size_t(_N), _X);
239  /*m_debug_size = size();*/
240 
241  if (shrinking) {
242  m_mmitset.invalidate_inclusive_range(_N, msev_size_t(original_size - 1));
243  }
244  m_mmitset.shift_inclusive_range(original_size, original_size, msev_size_t(_N) - original_size); /*shift the end markers*/
245  auto new_capacity = msev_size_t((*this).capacity());
246  bool realloc_occured = (new_capacity != original_capacity);
247  if (realloc_occured) {
249  }
250  }
251  typename base_class::const_reference operator[](size_type _P) const {
252  return (*this).at(msev_as_a_size_t(_P));
253  }
254  typename base_class::reference operator[](size_type _P) {
255  return (*this).at(msev_as_a_size_t(_P));
256  }
257  typename base_class::reference front() { // return first element of mutable sequence
258  if (0 == (*this).size()) { MSE_THROW(msevector_range_error("front() on empty - typename base_class::reference front() - msevector")); }
259  return base_class::front();
260  }
261  typename base_class::const_reference front() const { // return first element of nonmutable sequence
262  if (0 == (*this).size()) { MSE_THROW(msevector_range_error("front() on empty - typename base_class::const_reference front() - msevector")); }
263  return base_class::front();
264  }
265  typename base_class::reference back() { // return last element of mutable sequence
266  if (0 == (*this).size()) { MSE_THROW(msevector_range_error("back() on empty - typename base_class::reference back() - msevector")); }
267  return base_class::back();
268  }
269  typename base_class::const_reference back() const { // return last element of nonmutable sequence
270  if (0 == (*this).size()) { MSE_THROW(msevector_range_error("back() on empty - typename base_class::const_reference back() - msevector")); }
271  return base_class::back();
272  }
273  void push_back(_Ty&& _X) {
274  if (m_mmitset.is_empty()) {
275  base_class::push_back(std::move(_X));
276  }
277  else {
278  auto original_size = msev_size_t((*this).size());
279  auto original_capacity = msev_size_t((*this).capacity());
280 
281  base_class::push_back(std::move(_X));
282  /*m_debug_size = size();*/
283 
284  assert((original_size + 1) == msev_size_t((*this).size()));
285  m_mmitset.shift_inclusive_range(original_size, original_size, 1); /*shift the end markers*/
286  auto new_capacity = msev_size_t((*this).capacity());
287  bool realloc_occured = (new_capacity != original_capacity);
288  if (realloc_occured) {
290  }
291  }
292  }
293  void push_back(const _Ty& _X) {
294  if (m_mmitset.is_empty()) {
295  base_class::push_back(_X);
296  }
297  else {
298  auto original_size = msev_size_t((*this).size());
299  auto original_capacity = msev_size_t((*this).capacity());
300 
301  base_class::push_back(_X);
302  /*m_debug_size = size();*/
303 
304  assert((original_size + 1) == msev_size_t((*this).size()));
305  m_mmitset.shift_inclusive_range(original_size, original_size, 1); /*shift the end markers*/
306  auto new_capacity = msev_size_t((*this).capacity());
307  bool realloc_occured = (new_capacity != original_capacity);
308  if (realloc_occured) {
310  }
311  }
312  }
313  void pop_back() {
314  if (m_mmitset.is_empty()) {
315  base_class::pop_back();
316  }
317  else {
318  auto original_size = msev_size_t((*this).size());
319  auto original_capacity = msev_size_t((*this).capacity());
320 
321  if (0 == original_size) { MSE_THROW(msevector_range_error("pop_back() on empty - void pop_back() - msevector")); }
322  base_class::pop_back();
323  /*m_debug_size = size();*/
324 
325  assert((original_size - 1) == msev_size_t((*this).size()));
326  m_mmitset.invalidate_inclusive_range(msev_size_t(original_size - 1), msev_size_t(original_size - 1));
327  m_mmitset.shift_inclusive_range(original_size, original_size, -1); /*shift the end markers*/
328  auto new_capacity = msev_size_t((*this).capacity());
329  bool realloc_occured = (new_capacity != original_capacity);
330  if (realloc_occured) {
332  }
333  }
334  }
335  void assign(_It _F, _It _L) {
336  base_class::assign(_F, _L);
337  /*m_debug_size = size();*/
338  m_mmitset.reset();
339  }
340  template<class _Iter>
341  void assign(_Iter _First, _Iter _Last) { // assign [_First, _Last)
342  base_class::assign(_First, _Last);
343  /*m_debug_size = size();*/
344  m_mmitset.reset();
345  }
346  void assign(size_type _N, const _Ty& _X = _Ty()) {
347  base_class::assign(msev_as_a_size_t(_N), _X);
348  /*m_debug_size = size();*/
349  m_mmitset.reset();
350  }
351  typename base_class::iterator insert(typename base_class::const_iterator _P, _Ty&& _X) {
352  return (emplace(_P, std::move(_X)));
353  }
354  typename base_class::iterator insert(typename base_class::const_iterator _P, const _Ty& _X = _Ty()) {
355  if (m_mmitset.is_empty()) {
356  typename base_class::iterator retval = base_class::insert(_P, _X);
357  /*m_debug_size = size();*/
358  return retval;
359  }
360  else {
361  msev_int di = std::distance(base_class::cbegin(), _P);
362  msev_size_t d = msev_size_t(di);
363  if ((0 > di) || (msev_size_t((*this).size()) < di)) { MSE_THROW(msevector_range_error("index out of range - typename base_class::iterator insert() - msevector")); }
364 
365  auto original_size = msev_size_t((*this).size());
366  auto original_capacity = msev_size_t((*this).capacity());
367 
368  typename base_class::iterator retval = base_class::insert(_P, _X);
369  /*m_debug_size = size();*/
370 
371  assert((original_size + 1) == msev_size_t((*this).size()));
372  assert(di == std::distance(base_class::begin(), retval));
373  m_mmitset.shift_inclusive_range(d, original_size, 1);
374  auto new_capacity = msev_size_t((*this).capacity());
375  bool realloc_occured = (new_capacity != original_capacity);
376  if (realloc_occured) {
378  }
379  return retval;
380  }
381  }
382 
383 #if !(defined(GPP4P8_COMPATIBLE))
384  typename base_class::iterator insert(typename base_class::const_iterator _P, size_type _M, const _Ty& _X) {
385  if (m_mmitset.is_empty()) {
386  typename base_class::iterator retval = base_class::insert(_P, msev_as_a_size_t(_M), _X);
387  /*m_debug_size = size();*/
388  return retval;
389  }
390  else {
391  msev_int di = std::distance(base_class::cbegin(), _P);
392  msev_size_t d = msev_size_t(di);
393  if ((0 > di) || ((*this).size() < msev_size_t(di))) { MSE_THROW(msevector_range_error("index out of range - typename base_class::iterator insert() - msevector")); }
394 
395  auto original_size = msev_size_t((*this).size());
396  auto original_capacity = msev_size_t((*this).capacity());
397 
398  typename base_class::iterator retval = base_class::insert(_P, msev_as_a_size_t(_M), _X);
399  /*m_debug_size = size();*/
400 
401  assert((original_size + _M) == msev_size_t((*this).size()));
402  assert(di == std::distance(base_class::begin(), retval));
403  m_mmitset.shift_inclusive_range(d, original_size, msev_int(_M));
404  auto new_capacity = msev_size_t((*this).capacity());
405  bool realloc_occured = (new_capacity != original_capacity);
406  if (realloc_occured) {
408  }
409  return retval;
410  }
411  }
412  template<class _Iter
413  //>typename std::enable_if<_mse_Is_iterator<_Iter>::value, typename base_class::iterator>::type
414  , class = _mse_RequireInputIter<_Iter> >
415  typename base_class::iterator insert(typename base_class::const_iterator _Where, _Iter _First, _Iter _Last) { // insert [_First, _Last) at _Where
416  if (m_mmitset.is_empty()) {
417  auto retval = base_class::insert(_Where, _First, _Last);
418  /*m_debug_size = size();*/
419  return retval;
420  }
421  else {
422  msev_int di = std::distance(base_class::cbegin(), _Where);
423  msev_size_t d = msev_size_t(di);
424  if ((0 > di) || ((*this).size() < msev_size_t(di))) { MSE_THROW(msevector_range_error("index out of range - typename base_class::iterator insert() - msevector")); }
425 
426  auto _M = msev_int(std::distance(_First, _Last));
427  auto original_size = msev_size_t((*this).size());
428  auto original_capacity = msev_size_t((*this).capacity());
429 
430  //if (0 > _M) { MSE_THROW(msevector_range_error("invalid argument - typename base_class::iterator insert() - msevector")); }
431  auto retval = base_class::insert(_Where, _First, _Last);
432  /*m_debug_size = size();*/
433 
434  assert((original_size + _M) == msev_size_t((*this).size()));
435  assert(di == std::distance(base_class::begin(), retval));
436  m_mmitset.shift_inclusive_range(d, original_size, _M);
437  auto new_capacity = msev_size_t((*this).capacity());
438  bool realloc_occured = (new_capacity != original_capacity);
439  if (realloc_occured) {
441  }
442  return retval;
443  }
444  }
445 
446 #else
448  /*typename base_class::iterator*/
449  void
450  /* g++4.8 seems to be using the c++98 version of this insert function instead of the c++11 version. */
451  insert(typename base_class::/*const_*/iterator _P, size_t _M, const _Ty& _X) {
452  msev_int di = std::distance(base_class::/*c*/begin(), _P);
453  msev_size_t d = msev_size_t(di);
454  if ((0 > di) || (msev_size_t((*this).size()) < di)) { MSE_THROW(msevector_range_error("index out of range - typename base_class::iterator insert() - msevector")); }
455 
456  auto original_size = msev_size_t((*this).size());
457  auto original_capacity = msev_size_t((*this).capacity());
458 
459  /*typename base_class::iterator retval =*/
460  base_class::insert(_P, _M, _X);
461  /*m_debug_size = size();*/
462 
463  assert((original_size + _M) == msev_size_t((*this).size()));
464  /*assert(di == std::distance(base_class::begin(), retval));*/
465  m_mmitset.shift_inclusive_range(d, original_size, _M);
466  auto new_capacity = msev_size_t((*this).capacity());
467  bool realloc_occured = (new_capacity != original_capacity);
468  if (realloc_occured) {
470  }
471  /*return retval;*/
472  }
473  template<class _Iter
474  //>typename std::enable_if<_mse_Is_iterator<_Iter>::value, void>::type
475  , class = _mse_RequireInputIter<_Iter> > void
476  insert(typename base_class::/*const_*/iterator _Where, _Iter _First, _Iter _Last) { // insert [_First, _Last) at _Where
477  msev_int di = std::distance(base_class::/*c*/begin(), _Where);
478  msev_size_t d = msev_size_t(di);
479  if ((0 > di) || (msev_size_t((*this).size()) < di)) { MSE_THROW(msevector_range_error("index out of range - typename base_class::iterator insert() - msevector")); }
480 
481  auto _M = msev_int(std::distance(_First, _Last));
482  auto original_size = msev_size_t((*this).size());
483  auto original_capacity = msev_size_t((*this).capacity());
484 
485  //if (0 > _M) { MSE_THROW(msevector_range_error("invalid argument - typename base_class::iterator insert() - msevector")); }
486  /*auto retval =*/
487  base_class::insert(_Where, _First, _Last);
488  /*m_debug_size = size();*/
489 
490  assert((original_size + _M) == msev_size_t((*this).size()));
491  /*assert(di == std::distance(base_class::begin(), retval));*/
492  m_mmitset.shift_inclusive_range(d, original_size, _M);
493  auto new_capacity = msev_size_t((*this).capacity());
494  bool realloc_occured = (new_capacity != original_capacity);
495  if (realloc_occured) {
497  }
498  /*return retval;*/
499  }
500 #endif
502  template<class ..._Valty>
503  void emplace_back(_Valty&& ..._Val)
504  { // insert by moving into element at end
505  if (m_mmitset.is_empty()) {
506  base_class::emplace_back(std::forward<_Valty>(_Val)...);
507  /*m_debug_size = size();*/
508  }
509  else {
510  auto original_size = msev_size_t((*this).size());
511  auto original_capacity = msev_size_t((*this).capacity());
512 
513  base_class::emplace_back(std::forward<_Valty>(_Val)...);
514  /*m_debug_size = size();*/
515 
516  assert((original_size + 1) == msev_size_t((*this).size()));
517  m_mmitset.shift_inclusive_range(original_size, original_size, 1); /*shift the end markers*/
518  auto new_capacity = msev_size_t((*this).capacity());
519  bool realloc_occured = (new_capacity != original_capacity);
520  if (realloc_occured) {
522  }
523  }
524  }
525  template<class ..._Valty>
526 #if !(defined(GPP4P8_COMPATIBLE))
527  typename base_class::iterator emplace(typename base_class::const_iterator _Where, _Valty&& ..._Val)
528  { // insert by moving _Val at _Where
529 #else
530  typename base_class::iterator emplace(typename base_class::/*const_*/iterator _Where, _Valty&& ..._Val)
531  { // insert by moving _Val at _Where
532 #endif
534  if (m_mmitset.is_empty()) {
535  auto retval = base_class::emplace(_Where, std::forward<_Valty>(_Val)...);
536  /*m_debug_size = size();*/
537  return retval;
538  }
539  else {
540 
541 #if !(defined(GPP4P8_COMPATIBLE))
542  msev_int di = std::distance(base_class::cbegin(), _Where);
543 #else
544  msev_int di = std::distance(base_class::/*c*/begin(), _Where);
545 #endif
547  msev_size_t d = msev_size_t(di);
548  if ((0 > di) || ((*this).size() < msev_size_t(di))) { MSE_THROW(msevector_range_error("index out of range - typename base_class::iterator emplace() - msevector")); }
549 
550  auto original_size = msev_size_t((*this).size());
551  auto original_capacity = msev_size_t((*this).capacity());
552 
553  auto retval = base_class::emplace(_Where, std::forward<_Valty>(_Val)...);
554  /*m_debug_size = size();*/
555 
556  assert((original_size + 1) == msev_size_t((*this).size()));
557  assert(di == std::distance(base_class::begin(), retval));
558  m_mmitset.shift_inclusive_range(d, original_size, 1);
559  auto new_capacity = msev_size_t((*this).capacity());
560  bool realloc_occured = (new_capacity != original_capacity);
561  if (realloc_occured) {
563  }
564  return retval;
565  }
566  }
567  typename base_class::iterator erase(typename base_class::const_iterator _P) {
568  if (m_mmitset.is_empty()) {
569  typename base_class::iterator retval = base_class::erase(_P);
570  /*m_debug_size = size();*/
571  return retval;
572  }
573  else {
574  msev_int di = std::distance(base_class::cbegin(), _P);
575  msev_size_t d = msev_size_t(di);
576  if ((0 > di) || ((*this).size() < msev_size_t(di))) { MSE_THROW(msevector_range_error("index out of range - typename base_class::iterator erase() - msevector")); }
577 
578  auto original_size = msev_size_t((*this).size());
579  auto original_capacity = msev_size_t((*this).capacity());
580 
581  if (base_class::end() == _P) { MSE_THROW(msevector_range_error("invalid argument - typename base_class::iterator erase(typename base_class::const_iterator _P) - msevector")); }
582  typename base_class::iterator retval = base_class::erase(_P);
583  /*m_debug_size = size();*/
584 
585  assert((original_size - 1) == msev_size_t((*this).size()));
586  assert(di == std::distance(base_class::begin(), retval));
587  {
589  m_mmitset.shift_inclusive_range(msev_size_t(d + 1), original_size, -1);
590  }
591  auto new_capacity = msev_size_t((*this).capacity());
592  bool realloc_occured = (new_capacity != original_capacity);
593  if (realloc_occured) {
595  }
596  return retval;
597  }
598  }
599  typename base_class::iterator erase(typename base_class::const_iterator _F, typename base_class::const_iterator _L) {
600  if (m_mmitset.is_empty()) {
601  typename base_class::iterator retval = base_class::erase(_F, _L);
602  /*m_debug_size = size();*/
603  return retval;
604  }
605  else {
606  msev_int di = std::distance(base_class::cbegin(), _F);
607  msev_size_t d = msev_size_t(di);
608  if ((0 > di) || ((*this).size() < msev_size_t(di))) { MSE_THROW(msevector_range_error("index out of range - typename base_class::iterator erase() - msevector")); }
609  msev_int di2 = std::distance(base_class::cbegin(), _L);
610  msev_size_t d2 = msev_size_t(di2);
611  if ((0 > di2) || ((*this).size() < msev_size_t(di2))) { MSE_THROW(msevector_range_error("index out of range - typename base_class::iterator erase() - msevector")); }
612 
613  auto _M = msev_int(std::distance(_F, _L));
614  auto original_size = msev_size_t((*this).size());
615  auto original_capacity = msev_size_t((*this).capacity());
616 
617  if ((base_class::end() == _F)/* || (0 > _M)*/) { MSE_THROW(msevector_range_error("invalid argument - typename base_class::iterator erase(typename base_class::iterator _F, typename base_class::iterator _L) - msevector")); }
618  typename base_class::iterator retval = base_class::erase(_F, _L);
619  /*m_debug_size = size();*/
620 
621  assert((original_size - _M) == msev_size_t((*this).size()));
622  assert(di == std::distance(base_class::begin(), retval));
623  {
624  if (1 <= _M) {
626  }
627  m_mmitset.shift_inclusive_range(msev_size_t(d + _M), original_size, -_M);
628  }
629  auto new_capacity = msev_size_t((*this).capacity());
630  bool realloc_occured = (new_capacity != original_capacity);
631  if (realloc_occured) {
633  }
634  return retval;
635  }
636  }
637  void clear() {
639  /*m_debug_size = size();*/
640  m_mmitset.reset();
641  }
642  void swap(base_class& _X) {
643  base_class::swap(_X);
644  /*m_debug_size = size();*/
645  m_mmitset.reset();
646  }
647  void swap(_Myt& _X) {
648  swap(static_cast<base_class&>(_X));
649  m_mmitset.reset();
650  }
651 
652  msevector(_XSTD initializer_list<typename base_class::value_type> _Ilist,
653  const _A& _Al = _A())
654  : base_class(_Ilist, _Al), m_mmitset(*this) { // construct from initializer_list
655  /*m_debug_size = size();*/
656  }
657  _Myt& operator=(_XSTD initializer_list<typename base_class::value_type> _Ilist) { // assign initializer_list
658  operator=(static_cast<base_class>(_Ilist));
659  m_mmitset.reset();
660  return (*this);
661  }
662  void assign(_XSTD initializer_list<typename base_class::value_type> _Ilist) { // assign initializer_list
663  base_class::assign(_Ilist);
664  /*m_debug_size = size();*/
665  m_mmitset.reset();
666  }
667 #if defined(GPP4P8_COMPATIBLE)
668  /* g++4.8 seems to be (incorrectly) using the c++98 version of this insert function instead of the c++11 version. */
669  /*typename base_class::iterator*/void insert(typename base_class::/*const_*/iterator _Where, _XSTD initializer_list<typename base_class::value_type> _Ilist) { // insert initializer_list
670  msev_int di = std::distance(base_class::/*c*/begin(), _Where);
671  msev_size_t d = msev_size_t(di);
672  if ((0 > di) || (msev_size_t((*this).size()) < di)) { MSE_THROW(msevector_range_error("index out of range - typename base_class::iterator insert() - msevector")); }
673 
674  auto _M = _Ilist.size();
675  auto original_size = msev_size_t((*this).size());
676  auto original_capacity = msev_size_t((*this).capacity());
677 
678  /*auto retval = */base_class::insert(_Where, _Ilist);
679  /*m_debug_size = size();*/
680 
681  assert((original_size + _M) == msev_size_t((*this).size()));
682  /*assert(di == std::distance(base_class::begin(), retval));*/
683  m_mmitset.shift_inclusive_range(d, original_size, _M);
684  auto new_capacity = msev_size_t((*this).capacity());
685  bool realloc_occured = (new_capacity != original_capacity);
686  if (realloc_occured) {
688  }
689  /*return retval;*/
690  }
691 #else /*defined(GPP4P8_COMPATIBLE)*/
692  typename base_class::iterator insert(typename base_class::const_iterator _Where, _XSTD initializer_list<typename base_class::value_type> _Ilist) { // insert initializer_list
693  if (m_mmitset.is_empty()) {
694  auto retval = base_class::insert(_Where, _Ilist);
695  /*m_debug_size = size();*/
696  return retval;
697  }
698  else {
699  msev_int di = std::distance(base_class::cbegin(), _Where);
700  msev_size_t d = msev_size_t(di);
701  if ((0 > di) || ((*this).size() < msev_size_t(di))) { MSE_THROW(msevector_range_error("index out of range - typename base_class::iterator insert() - msevector")); }
702 
703  auto _M = _Ilist.size();
704  auto original_size = msev_size_t((*this).size());
705  auto original_capacity = msev_size_t((*this).capacity());
706 
707  auto retval = base_class::insert(_Where, _Ilist);
708  /*m_debug_size = size();*/
709 
710  assert((original_size + _M) == msev_size_t((*this).size()));
711  assert(di == std::distance(base_class::begin(), retval));
712  m_mmitset.shift_inclusive_range(d, original_size, msev_int(_M));
713  auto new_capacity = msev_size_t((*this).capacity());
714  bool realloc_occured = (new_capacity != original_capacity);
715  if (realloc_occured) {
717  }
718  return retval;
719  }
720  }
721 #endif /*defined(GPP4P8_COMPATIBLE)*/
722 
723  //size_t m_debug_size;
724 
725  class random_access_const_iterator_base : public std::iterator<std::random_access_iterator_tag, value_type, difference_type, const_pointer, const_reference> {};
726  class random_access_iterator_base : public std::iterator<std::random_access_iterator_tag, value_type, difference_type, pointer, reference> {};
727 
728  /* mm_const_iterator_type acts much like a list iterator. */
730  public:
731  typedef typename base_class::const_iterator::iterator_category iterator_category;
732  typedef typename base_class::const_iterator::value_type value_type;
733  //typedef typename base_class::const_iterator::difference_type difference_type;
735  typedef difference_type distance_type; // retained
736  typedef typename base_class::const_iterator::pointer pointer;
737  typedef typename base_class::const_iterator::pointer const_pointer;
738  typedef typename base_class::const_iterator::reference reference;
739  typedef typename base_class::const_reference const_reference;
740 
741  void reset() { set_to_end_marker(); }
742  bool points_to_an_item() const {
743  if (m_points_to_an_item) { assert((1 <= m_owner_cptr->size()) && (m_index < m_owner_cptr->size())); return true; }
744  else { assert(!((1 <= m_owner_cptr->size()) && (m_index < m_owner_cptr->size()))); return false; }
745  }
746  bool points_to_end_marker() const {
747  if (false == points_to_an_item()) { assert(m_index == m_owner_cptr->size()); return true; }
748  else { return false; }
749  }
750  bool points_to_beginning() const {
751  if (0 == m_index) { return true; }
752  else { return false; }
753  }
754  /* has_next_item_or_end_marker() is just an alias for points_to_an_item(). */
755  bool has_next_item_or_end_marker() const { return points_to_an_item(); } //his is
756  /* has_next() is just an alias for points_to_an_item() that's familiar to java programmers. */
757  bool has_next() const { return has_next_item_or_end_marker(); }
758  bool has_previous() const { return (!points_to_beginning()); }
760  m_index = 0;
761  if (1 <= m_owner_cptr->size()) {
762  m_points_to_an_item = true;
763  }
764  else { assert(false == m_points_to_an_item); }
765  }
767  m_index = m_owner_cptr->size();
768  m_points_to_an_item = false;
769  }
770  void set_to_next() {
771  if (points_to_an_item()) {
772  m_index += 1;
773  if (m_owner_cptr->size() <= m_index) {
774  (*this).m_points_to_an_item = false;
775  if (m_owner_cptr->size() < m_index) { assert(false); reset(); }
776  }
777  }
778  else {
779  MSE_THROW(msevector_range_error("attempt to use invalid const_item_pointer - void set_to_next() - mm_const_iterator_type - msevector"));
780  }
781  }
783  if (has_previous()) {
784  m_index -= 1;
785  (*this).m_points_to_an_item = true;
786  }
787  else {
788  MSE_THROW(msevector_range_error("attempt to use invalid const_item_pointer - void set_to_previous() - mm_const_iterator_type - msevector"));
789  }
790  }
791  mm_const_iterator_type& operator ++() { (*this).set_to_next(); return (*this); }
792  mm_const_iterator_type operator++(int) { mm_const_iterator_type _Tmp = *this; ++*this; return (_Tmp); }
793  mm_const_iterator_type& operator --() { (*this).set_to_previous(); return (*this); }
794  mm_const_iterator_type operator--(int) { mm_const_iterator_type _Tmp = *this; --*this; return (_Tmp); }
796  auto new_index = msev_int(m_index) + n;
797  if ((0 > new_index) || (m_owner_cptr->size() < msev_size_t(new_index))) {
798  MSE_THROW(msevector_range_error("index out of range - void advance(difference_type n) - mm_const_iterator_type - msevector"));
799  }
800  else {
801  m_index = msev_size_t(new_index);
802  if (m_owner_cptr->size() <= m_index) {
803  (*this).m_points_to_an_item = false;
804  }
805  else {
806  (*this).m_points_to_an_item = true;
807  }
808  }
809  }
810  void regress(difference_type n) { advance(-n); }
811  mm_const_iterator_type& operator +=(difference_type n) { (*this).advance(n); return (*this); }
812  mm_const_iterator_type& operator -=(difference_type n) { (*this).regress(n); return (*this); }
814  mm_const_iterator_type retval(*this);
815  retval = (*this);
816  retval.advance(n);
817  return retval;
818  }
819  mm_const_iterator_type operator-(difference_type n) const { return ((*this) + (-n)); }
821  if ((rhs.m_owner_cptr) != ((*this).m_owner_cptr)) { MSE_THROW(msevector_range_error("invalid argument - difference_type operator-(const mm_const_iterator_type &rhs) const - msevector::mm_const_iterator_type")); }
822  auto retval = difference_type((*this).m_index) - difference_type(rhs.m_index);
823  assert(difference_type(m_owner_cptr->size()) >= retval);
824  return retval;
825  }
828  }
829  const_reference item() const { return operator*(); }
831  return m_owner_cptr->at(msev_as_a_size_t(m_index - 1));
832  }
834  return &(m_owner_cptr->at(msev_as_a_size_t(m_index)));
835  }
836  const_reference operator[](difference_type _Off) const { return (*m_owner_cptr).at(msev_as_a_size_t(difference_type(m_index) + _Off)); }
837  /*
838  mm_const_iterator_type& operator=(const typename base_class::const_iterator& _Right_cref)
839  {
840  msev_int d = std::distance<typename base_class::iterator>(m_owner_cptr->cbegin(), _Right_cref);
841  if ((0 <= d) && (m_owner_cptr->size() >= d)) {
842  if (m_owner_cptr->size() == d) {
843  assert(m_owner_cptr->cend() == _Right_cref);
844  m_points_to_an_item = false;
845  } else {
846  m_points_to_an_item = true;
847  }
848  m_index = msev_size_t(d);
849  base_class::const_iterator::operator=(_Right_cref);
850  }
851  else {
852  MSE_THROW(msevector_range_error("doesn't seem to be a valid assignment value - mm_const_iterator_type& operator=(const typename base_class::const_iterator& _Right_cref) - mm_const_iterator_type - msevector"));
853  }
854  return (*this);
855  }
856  */
858  {
859  if (((*this).m_owner_cptr) == (_Right_cref.m_owner_cptr)) {
860  assert((*this).m_owner_cptr->size() >= _Right_cref.m_index);
861  (*this).m_points_to_an_item = _Right_cref.m_points_to_an_item;
862  (*this).m_index = _Right_cref.m_index;
863  }
864  else {
865  MSE_THROW(msevector_range_error("doesn't seem to be a valid assignment value - mm_const_iterator_type& operator=(const typename base_class::iterator& _Right_cref) - mm_const_iterator_type - msevector"));
866  }
867  return (*this);
868  }
869  bool operator==(const mm_const_iterator_type& _Right_cref) const {
870  if (((*this).m_owner_cptr) != (_Right_cref.m_owner_cptr)) { MSE_THROW(msevector_range_error("invalid argument - mm_const_iterator_type& operator==(const mm_const_iterator_type& _Right) - mm_const_iterator_type - msevector")); }
871  return (_Right_cref.m_index == m_index);
872  }
873  bool operator!=(const mm_const_iterator_type& _Right_cref) const { return (!(_Right_cref == (*this))); }
874  bool operator<(const mm_const_iterator_type& _Right) const {
875  if (((*this).m_owner_cptr) != (_Right.m_owner_cptr)) { MSE_THROW(msevector_range_error("invalid argument - mm_const_iterator_type& operator<(const mm_const_iterator_type& _Right) - mm_const_iterator_type - msevector")); }
876  return (m_index < _Right.m_index);
877  }
878  bool operator<=(const mm_const_iterator_type& _Right) const { return (((*this) < _Right) || (_Right == (*this))); }
879  bool operator>(const mm_const_iterator_type& _Right) const { return (!((*this) <= _Right)); }
880  bool operator>=(const mm_const_iterator_type& _Right) const { return (!((*this) < _Right)); }
882  (*this) = _Right_cref;
883  }
884  void invalidate_inclusive_range(msev_size_t index_of_first, msev_size_t index_of_last) {
885  if ((index_of_first <= (*this).m_index) && (index_of_last >= (*this).m_index)) {
886  (*this).reset();
887  }
888  }
889  void shift_inclusive_range(msev_size_t index_of_first, msev_size_t index_of_last, msev_int shift) {
890  if ((index_of_first <= (*this).m_index) && (index_of_last >= (*this).m_index)) {
891  auto new_index = (*this).m_index + shift;
892  if ((0 > new_index) || (m_owner_cptr->size() < new_index)) {
893  MSE_THROW(msevector_range_error("void shift_inclusive_range() - mm_const_iterator_type - msevector"));
894  }
895  else {
896  (*this).m_index = msev_size_t(new_index);
897  (*this).sync_const_iterator_to_index();
898  }
899  }
900  }
902  return m_index;
903  }
904  operator typename base_class::const_iterator() const {
905  typename base_class::const_iterator retval = (*m_owner_cptr).cbegin();
906  retval += msev_as_a_size_t(m_index);
907  return retval;
908  }
909 
910  /* We actually want to make this constructor private, but doing so seems to break std::make_shared<mm_const_iterator_type>. */
911  mm_const_iterator_type(const _Myt& owner_cref) : m_owner_cptr(&owner_cref) { set_to_beginning(); }
912  private:
913  mm_const_iterator_type(const mm_const_iterator_type& src_cref) : m_owner_cptr(src_cref.m_owner_cptr) { (*this) = src_cref; }
915  assert(m_owner_cptr->size() >= (*this).m_index);
916  }
919  const _Myt* m_owner_cptr = nullptr;
920  friend class mm_iterator_set_type;
921  friend class /*_Myt*/msevector<_Ty, _A>;
922  friend class mm_iterator_type;
923  };
924  /* mm_iterator_type acts much like a list iterator. */
926  public:
927  typedef typename base_class::iterator::iterator_category iterator_category;
928  typedef typename base_class::iterator::value_type value_type;
929  //typedef typename base_class::iterator::difference_type difference_type;
931  typedef difference_type distance_type; // retained
932  typedef typename base_class::iterator::pointer pointer;
933  typedef typename base_class::iterator::reference reference;
934 
935  void reset() { set_to_end_marker(); }
936  bool points_to_an_item() const {
937  if (m_points_to_an_item) { assert((1 <= m_owner_ptr->size()) && (m_index < m_owner_ptr->size())); return true; }
938  else { assert(!((1 <= m_owner_ptr->size()) && (m_index < m_owner_ptr->size()))); return false; }
939  }
940  bool points_to_end_marker() const {
941  if (false == points_to_an_item()) { assert(m_index == m_owner_ptr->size()); return true; }
942  else { return false; }
943  }
944  bool points_to_beginning() const {
945  if (0 == m_index) { return true; }
946  else { return false; }
947  }
948  /* has_next_item_or_end_marker() is just an alias for points_to_an_item(). */
950  /* has_next() is just an alias for points_to_an_item() that's familiar to java programmers. */
951  bool has_next() const { return has_next_item_or_end_marker(); }
952  bool has_previous() const { return (!points_to_beginning()); }
954  m_index = 0;
955  if (1 <= m_owner_ptr->size()) {
956  m_points_to_an_item = true;
957  }
958  else { assert(false == m_points_to_an_item); }
959  }
961  m_index = m_owner_ptr->size();
962  m_points_to_an_item = false;
963  }
964  void set_to_next() {
965  if (points_to_an_item()) {
966  m_index += 1;
967  if (m_owner_ptr->size() <= m_index) {
968  (*this).m_points_to_an_item = false;
969  if (m_owner_ptr->size() < m_index) { assert(false); reset(); }
970  }
971  }
972  else {
973  MSE_THROW(msevector_range_error("attempt to use invalid item_pointer - void set_to_next() - mm_const_iterator_type - msevector"));
974  }
975  }
977  if (has_previous()) {
978  m_index -= 1;
979  (*this).m_points_to_an_item = true;
980  }
981  else {
982  MSE_THROW(msevector_range_error("attempt to use invalid item_pointer - void set_to_previous() - mm_iterator_type - msevector"));
983  }
984  }
985  mm_iterator_type& operator ++() { (*this).set_to_next(); return (*this); }
986  mm_iterator_type operator++(int) { mm_iterator_type _Tmp = *this; ++*this; return (_Tmp); }
987  mm_iterator_type& operator --() { (*this).set_to_previous(); return (*this); }
988  mm_iterator_type operator--(int) { mm_iterator_type _Tmp = *this; --*this; return (_Tmp); }
990  auto new_index = msev_int(m_index) + n;
991  if ((0 > new_index) || (m_owner_ptr->size() < msev_size_t(new_index))) {
992  MSE_THROW(msevector_range_error("index out of range - void advance(difference_type n) - mm_iterator_type - msevector"));
993  }
994  else {
995  m_index = msev_size_t(new_index);
996  if (m_owner_ptr->size() <= m_index) {
997  (*this).m_points_to_an_item = false;
998  }
999  else {
1000  (*this).m_points_to_an_item = true;
1001  }
1002  }
1003  }
1004  void regress(int n) { advance(-n); }
1005  mm_iterator_type& operator +=(difference_type n) { (*this).advance(n); return (*this); }
1006  mm_iterator_type& operator -=(difference_type n) { (*this).regress(n); return (*this); }
1008  mm_iterator_type retval(*this);
1009  retval = (*this);
1010  retval.advance(n);
1011  return retval;
1012  }
1013  mm_iterator_type operator-(difference_type n) const { return ((*this) + (-n)); }
1015  if ((rhs.m_owner_ptr) != ((*this).m_owner_ptr)) { MSE_THROW(msevector_range_error("invalid argument - difference_type operator-(const mm_iterator_type& rhs) const - msevector::mm_iterator_type")); }
1016  auto retval = difference_type((*this).m_index) - difference_type(rhs.m_index);
1017  assert(difference_type(m_owner_ptr->size()) >= retval);
1018  return retval;
1019  }
1021  return m_owner_ptr->at(msev_as_a_size_t(m_index));
1022  }
1023  reference item() const { return operator*(); }
1025  return m_owner_ptr->at(msev_as_a_size_t(m_index - 1));
1026  }
1028  return &(m_owner_ptr->at(msev_as_a_size_t(m_index)));
1029  }
1030  reference operator[](difference_type _Off) const { return (*m_owner_ptr).at(msev_as_a_size_t(difference_type(m_index) + _Off)); }
1031  /*
1032  mm_iterator_type& operator=(const typename base_class::iterator& _Right_cref)
1033  {
1034  msev_int d = std::distance<typename base_class::iterator>(m_owner_ptr->begin(), _Right_cref);
1035  if ((0 <= d) && (m_owner_ptr->size() >= d)) {
1036  if (m_owner_ptr->size() == d) {
1037  assert(m_owner_ptr->end() == _Right_cref);
1038  m_points_to_an_item = false;
1039  } else {
1040  m_points_to_an_item = true;
1041  }
1042  m_index = msev_size_t(d);
1043  base_class::iterator::operator=(_Right_cref);
1044  }
1045  else {
1046  MSE_THROW(msevector_range_error("doesn't seem to be a valid assignment value - mm_iterator_type& operator=(const typename base_class::iterator& _Right_cref) - mm_const_iterator_type - msevector"));
1047  }
1048  return (*this);
1049  }
1050  */
1052  {
1053  if (((*this).m_owner_ptr) == (_Right_cref.m_owner_ptr)) {
1054  assert((*this).m_owner_ptr->size() >= _Right_cref.m_index);
1055  (*this).m_points_to_an_item = _Right_cref.m_points_to_an_item;
1056  (*this).m_index = _Right_cref.m_index;
1057  }
1058  else {
1059  MSE_THROW(msevector_range_error("doesn't seem to be a valid assignment value - mm_iterator_type& operator=(const typename base_class::iterator& _Right_cref) - mm_const_iterator_type - msevector"));
1060  }
1061  return (*this);
1062  }
1063  bool operator==(const mm_iterator_type& _Right_cref) const {
1064  if (((*this).m_owner_ptr) != (_Right_cref.m_owner_ptr)) { MSE_THROW(msevector_range_error("invalid argument - mm_iterator_type& operator==(const typename base_class::iterator& _Right) - mm_iterator_type - msevector")); }
1065  return (_Right_cref.m_index == m_index);
1066  }
1067  bool operator!=(const mm_iterator_type& _Right_cref) const { return (!(_Right_cref == (*this))); }
1068  bool operator<(const mm_iterator_type& _Right) const {
1069  if (((*this).m_owner_ptr) != (_Right.m_owner_ptr)) { MSE_THROW(msevector_range_error("invalid argument - mm_iterator_type& operator<(const typename base_class::iterator& _Right) - mm_iterator_type - msevector")); }
1070  return (m_index < _Right.m_index);
1071  }
1072  bool operator<=(const mm_iterator_type& _Right) const { return (((*this) < _Right) || (_Right == (*this))); }
1073  bool operator>(const mm_iterator_type& _Right) const { return (!((*this) <= _Right)); }
1074  bool operator>=(const mm_iterator_type& _Right) const { return (!((*this) < _Right)); }
1075  void set_to_item_pointer(const mm_iterator_type& _Right_cref) {
1076  (*this) = _Right_cref;
1077  }
1078  void invalidate_inclusive_range(msev_size_t index_of_first, msev_size_t index_of_last) {
1079  if ((index_of_first <= (*this).m_index) && (index_of_last >= (*this).m_index)) {
1080  (*this).reset();
1081  }
1082  }
1083  void shift_inclusive_range(msev_size_t index_of_first, msev_size_t index_of_last, msev_int shift) {
1084  if ((index_of_first <= (*this).m_index) && (index_of_last >= (*this).m_index)) {
1085  auto new_index = (*this).m_index + shift;
1086  if ((0 > new_index) || (m_owner_ptr->size() < new_index)) {
1087  MSE_THROW(msevector_range_error("void shift_inclusive_range() - mm_iterator_type - msevector"));
1088  }
1089  else {
1090  (*this).m_index = msev_size_t(new_index);
1091  (*this).sync_iterator_to_index();
1092  }
1093  }
1094  }
1096  return m_index;
1097  }
1098  operator mm_const_iterator_type() const {
1100  retval.set_to_beginning();
1101  retval.advance(msev_int(m_index));
1102  return retval;
1103  }
1104  /* We actually want to make this constructor private, but doing so seems to break std::make_shared<mm_iterator_type>. */
1105  mm_iterator_type(_Myt& owner_ref) : m_owner_ptr(&owner_ref) { set_to_beginning(); }
1106  private:
1107  mm_iterator_type(const mm_iterator_type& src_cref) : m_owner_ptr(src_cref.m_owner_ptr) { (*this) = src_cref; }
1109  assert(m_owner_ptr->size() >= (*this).m_index);
1110  }
1113  _Myt* m_owner_ptr = nullptr;
1114  friend class mm_iterator_set_type;
1115  friend class /*_Myt*/msevector<_Ty, _A>;
1116  };
1117 
1118  private:
1119  typedef std::size_t CHashKey1;
1121  public:
1122  mm_const_iterator_handle_type(const CHashKey1& key_cref, const std::shared_ptr<mm_const_iterator_type>& shptr_cref) : m_shptr(shptr_cref), m_key(key_cref) {}
1123  private:
1124  std::shared_ptr<mm_const_iterator_type> m_shptr;
1126  friend class /*_Myt*/msevector<_Ty, _A>;
1127  friend class mm_iterator_set_type;
1128  };
1130  public:
1131  mm_iterator_handle_type(const CHashKey1& key_cref, const std::shared_ptr<mm_iterator_type>& shptr_ref) : m_shptr(shptr_ref), m_key(key_cref) {}
1132  private:
1133  std::shared_ptr<mm_iterator_type> m_shptr;
1135  friend class /*_Myt*/msevector<_Ty, _A>;
1136  friend class mm_iterator_set_type;
1137  };
1138 
1140  public:
1141  class CMMConstIterators : public std::unordered_map<CHashKey1, std::shared_ptr<mm_const_iterator_type>> {};
1142  class CMMIterators : public std::unordered_map<CHashKey1, std::shared_ptr<mm_iterator_type>> {};
1143 
1144  class assignable_CMMConstIterators_value_type : public std::pair<CHashKey1, std::shared_ptr<mm_const_iterator_type>> {
1145  public:
1147  assignable_CMMConstIterators_value_type(const typename CMMConstIterators::value_type& src) : std::pair<CHashKey1, std::shared_ptr<mm_iterator_type>>(src.first, src.second) {}
1148  assignable_CMMConstIterators_value_type& operator=(const typename CMMConstIterators::value_type& rhs) { (*this).first = rhs.first; (*this).second = rhs.second; return (*this); }
1149  operator typename CMMConstIterators::value_type() const { return CMMConstIterators::value_type((*this).first, (*this).second); }
1150  };
1151  class assignable_CMMIterators_value_type : public std::pair<CHashKey1, std::shared_ptr<mm_iterator_type>> {
1152  public:
1154  assignable_CMMIterators_value_type(const typename CMMIterators::value_type& src) : std::pair<CHashKey1, std::shared_ptr<mm_iterator_type>>(src.first, src.second) {}
1155  assignable_CMMIterators_value_type& operator=(const typename CMMIterators::value_type& rhs) { (*this).first = rhs.first; (*this).second = rhs.second; return (*this); }
1156  operator typename CMMIterators::value_type() const { return CMMIterators::value_type((*this).first, (*this).second); }
1157  };
1158 
1160  if (!mm_const_fast_mode1()) {
1162  }
1163  if (!mm_fast_mode1()) {
1165  }
1166  }
1167 
1168  void apply_to_all_mm_const_iterator_shptrs(const std::function<void(std::shared_ptr<mm_const_iterator_type>&)>& func_obj_ref) {
1169  if (!mm_const_fast_mode1()) {
1170  for (auto it = (*m_aux_mm_const_iterator_shptrs_ptr).begin(); (*m_aux_mm_const_iterator_shptrs_ptr).end() != it; it++) {
1171  func_obj_ref((*it).second);
1172  }
1173  }
1174  else {
1175  for (int i = 0; i < m_fm1_num_mm_const_iterators; i += 1) {
1176  func_obj_ref(m_fm1_key_mm_const_it_array[i].second);
1177  }
1178  }
1179  }
1180  void apply_to_all_mm_iterator_shptrs(const std::function<void(std::shared_ptr<mm_iterator_type>&)>& func_obj_ref) {
1181  if (!mm_fast_mode1()) {
1182  for (auto it = (*m_aux_mm_iterator_shptrs_ptr).begin(); (*m_aux_mm_iterator_shptrs_ptr).end() != it; it++) {
1183  func_obj_ref((*it).second);
1184  }
1185  }
1186  else {
1187  for (int i = 0; i < m_fm1_num_mm_iterators; i += 1) {
1188  func_obj_ref(m_fm1_key_mm_it_array[i].second);
1189  }
1190  }
1191  }
1193  void reset() {
1194  /* We can use "static" here because the lambda function does not capture any parameters. */
1195  static const std::function<void(std::shared_ptr<mm_const_iterator_type>&)> cit_func_obj = [](std::shared_ptr<mm_const_iterator_type>& a) { a->reset(); };
1197  static const std::function<void(std::shared_ptr<mm_iterator_type>&)> it_func_obj = [](std::shared_ptr<mm_iterator_type>& a) { a->reset(); };
1198  apply_to_all_mm_iterator_shptrs(it_func_obj);
1199  }
1201  /* No longer used. Relic from when mm_iterator_type contained a "native" iterator. */
1202  /* We can use "static" here because the lambda function does not capture any parameters. */
1203  /*
1204  static const std::function<void(std::shared_ptr<mm_const_iterator_type>&)> cit_func_obj = [](std::shared_ptr<mm_const_iterator_type>& a) { a->sync_const_iterator_to_index(); };
1205  apply_to_all_mm_const_iterator_shptrs(cit_func_obj);
1206  static const std::function<void(std::shared_ptr<mm_iterator_type>&)> it_func_obj = [](std::shared_ptr<mm_iterator_type>& a) { a->sync_iterator_to_index(); };
1207  apply_to_all_mm_iterator_shptrs(it_func_obj);
1208  */
1209  }
1210  void invalidate_inclusive_range(msev_size_t start_index, msev_size_t end_index) {
1211  const std::function<void(std::shared_ptr<mm_const_iterator_type>&)> cit_func_obj = [start_index, end_index](std::shared_ptr<mm_const_iterator_type>& a) { a->invalidate_inclusive_range(start_index, end_index); };
1213  const std::function<void(std::shared_ptr<mm_iterator_type>&)> it_func_obj = [start_index, end_index](std::shared_ptr<mm_iterator_type>& a) { a->invalidate_inclusive_range(start_index, end_index); };
1214  apply_to_all_mm_iterator_shptrs(it_func_obj);
1215  }
1216  void shift_inclusive_range(msev_size_t start_index, msev_size_t end_index, msev_int shift) {
1217  const std::function<void(std::shared_ptr<mm_const_iterator_type>&)> cit_func_obj = [start_index, end_index, shift](std::shared_ptr<mm_const_iterator_type>& a) { a->shift_inclusive_range(start_index, end_index, shift); };
1219  const std::function<void(std::shared_ptr<mm_iterator_type>&)> it_func_obj = [start_index, end_index, shift](std::shared_ptr<mm_iterator_type>& a) { a->shift_inclusive_range(start_index, end_index, shift); };
1220  apply_to_all_mm_iterator_shptrs(it_func_obj);
1221  }
1222  bool is_empty() const {
1223  if (mm_const_fast_mode1()) {
1224  if (1 <= m_fm1_num_mm_const_iterators) {
1225  return false;
1226  }
1227  }
1228  else {
1229  if (1 <= m_aux_mm_const_iterator_shptrs_ptr->size()) {
1230  return false;
1231  }
1232  }
1233  if (mm_fast_mode1()) {
1234  if (1 <= m_fm1_num_mm_iterators) {
1235  return false;
1236  }
1237  }
1238  else {
1239  if (1 <= m_aux_mm_iterator_shptrs_ptr->size()) {
1240  return false;
1241  }
1242  }
1243  return true;
1244  }
1245 
1247  //auto shptr = std::shared_ptr<mm_const_iterator_type>(new mm_const_iterator_type(*m_owner_ptr));
1248  auto shptr = std::make_shared<mm_const_iterator_type>(*m_owner_ptr);
1250  mm_const_iterator_handle_type retval(key, shptr);
1251  typename CMMConstIterators::value_type new_item(key, shptr);
1252  if (!mm_const_fast_mode1()) {
1253  (*m_aux_mm_const_iterator_shptrs_ptr).insert(new_item);
1254  } else {
1256  /* Too many items. Initiate and switch to slow mode. */
1257  /* Initialize slow storage. */
1259  /* First copy the items from fast storage to slow storage. */
1260  for (int i = 0; i < sc_fm1_max_mm_iterators; i += 1) {
1261  (*m_aux_mm_const_iterator_shptrs_ptr).insert(m_fm1_key_mm_const_it_array[i]);
1262  }
1263  /* Add the new items to slow storage. */
1264  (*m_aux_mm_const_iterator_shptrs_ptr).insert(new_item);
1265  }
1266  else {
1269  }
1270  }
1271  return retval;
1272  }
1274  if (!mm_const_fast_mode1()) {
1275  auto it = (*m_aux_mm_const_iterator_shptrs_ptr).find(handle.m_key);
1276  if ((*m_aux_mm_const_iterator_shptrs_ptr).end() != it) {
1277  (*m_aux_mm_const_iterator_shptrs_ptr).erase(it);
1278  }
1279  else {
1280  /* Do we need to throw here? */
1281  MSE_THROW(msevector_range_error("invalid handle - void release_aux_mm_const_iterator(mm_const_iterator_handle_type handle) - msevector::mm_iterator_set_type"));
1282  }
1283  }
1284  else {
1285  int found_index = -1;
1286  for (int i = 0; i < m_fm1_num_mm_const_iterators; i += 1) {
1287  if (handle.m_key == m_fm1_key_mm_const_it_array[i].first) {
1288  found_index = i;
1289  break;
1290  }
1291  }
1292  if (0 <= found_index) {
1294  assert(0 <= m_fm1_num_mm_const_iterators);
1295  for (int j = found_index; j < m_fm1_num_mm_const_iterators; j += 1) {
1297  }
1298  }
1299  else {
1300  /* Do we need to throw here? */
1301  MSE_THROW(msevector_range_error("invalid handle - void release_aux_mm_const_iterator(mm_const_iterator_handle_type handle) - msevector::mm_iterator_set_type"));
1302  }
1303  }
1304  }
1305 
1307  //auto shptr = std::shared_ptr<mm_iterator_type>(new mm_iterator_type(*m_owner_ptr));
1308  auto shptr = std::make_shared<mm_iterator_type>(*m_owner_ptr);
1310  mm_iterator_handle_type retval(key, shptr);
1311  typename CMMIterators::value_type new_item(key, shptr);
1312  if (!mm_fast_mode1()) {
1313  (*m_aux_mm_iterator_shptrs_ptr).insert(new_item);
1314  }
1315  else {
1317  /* Too many items. Initiate and switch to slow mode. */
1318  /* Initialize slow storage. */
1320  /* First copy the items from fast storage to slow storage. */
1321  for (int i = 0; i < sc_fm1_max_mm_iterators; i += 1) {
1322  (*m_aux_mm_iterator_shptrs_ptr).insert(m_fm1_key_mm_it_array[i]);
1323  }
1324  /* Add the new items to slow storage. */
1325  (*m_aux_mm_iterator_shptrs_ptr).insert(new_item);
1326  }
1327  else {
1330  }
1331  }
1332  return retval;
1333  }
1335  if (!mm_fast_mode1()) {
1336  auto it = (*m_aux_mm_iterator_shptrs_ptr).find(handle.m_key);
1337  if ((*m_aux_mm_iterator_shptrs_ptr).end() != it) {
1338  (*m_aux_mm_iterator_shptrs_ptr).erase(it);
1339  }
1340  else {
1341  /* Do we need to throw here? */
1342  MSE_THROW(msevector_range_error("invalid handle - void release_aux_mm_iterator(mm_iterator_handle_type handle) - msevector::mm_iterator_set_type"));
1343  }
1344  }
1345  else {
1346  int found_index = -1;
1347  for (int i = 0; i < m_fm1_num_mm_iterators; i += 1) {
1348  if (handle.m_key == m_fm1_key_mm_it_array[i].first) {
1349  found_index = i;
1350  break;
1351  }
1352  }
1353  if (0 <= found_index) {
1355  assert(0 <= m_fm1_num_mm_iterators);
1356  for (int j = found_index; j < m_fm1_num_mm_iterators; j += 1) {
1358  }
1359  }
1360  else {
1361  /* Do we need to throw here? */
1362  MSE_THROW(msevector_range_error("invalid handle - void release_aux_mm_iterator(mm_iterator_handle_type handle) - msevector::mm_iterator_set_type"));
1363  }
1364  }
1365  }
1367  if (!mm_fast_mode1()) {
1368  (*m_aux_mm_iterator_shptrs_ptr).clear();
1369  }
1370  else {
1371  for (int i = 0; i < m_fm1_num_mm_iterators; i += 1) {
1373  }
1375  }
1376  }
1378  return (*(handle.m_shptr));
1379  }
1381  return (*(handle.m_shptr));
1382  }
1383 
1384  private:
1386  if (!mm_const_fast_mode1()) {
1387  (*m_aux_mm_const_iterator_shptrs_ptr).clear();
1388  }
1389  else {
1390  for (int i = 0; i < m_fm1_num_mm_const_iterators; i += 1) {
1392  }
1394  }
1395  }
1396 
1398  /* This is a special type of class. The state (i.e. member values) of an object of this class is specific to (and only
1399  valid for) the particular instance of the object (or the object of which it is a member). So the correct state of a new
1400  copy of this type of object is not a copy of the state, but rather the state of a new object (which is just the default
1401  initialization state). */
1402  (*this).reset();
1403  return (*this);
1404  }
1405  mm_iterator_set_type& operator=(mm_iterator_set_type&& src) { /* see above */ (*this).reset(); return (*this); }
1406  mm_iterator_set_type(const mm_iterator_set_type& src) { /* see above */ }
1407  mm_iterator_set_type(const mm_iterator_set_type&& src) { /* see above */ }
1408 
1410 
1411  static const int sc_fm1_max_mm_iterators = 6/*arbitrary*/;
1412 
1413  bool mm_const_fast_mode1() const { return (nullptr == m_aux_mm_const_iterator_shptrs_ptr); }
1417 
1418  bool mm_fast_mode1() const { return (nullptr == m_aux_mm_iterator_shptrs_ptr); }
1422 
1423  _Myt* m_owner_ptr = nullptr;
1424 
1425  friend class /*_Myt*/msevector<_Ty, _A>;
1426  };
1428 
1429  public:
1431  return m_mmitset.const_item_pointer(handle);
1432  }
1434  return m_mmitset.item_pointer(handle);
1435  }
1436 
1437  private:
1444 
1445  public:
1447  public:
1451  typedef difference_type distance_type; // retained
1456 
1457  cipointer(const _Myt& owner_cref) : m_owner_cptr(&owner_cref) {
1459  m_handle_shptr = std::make_shared<mm_const_iterator_handle_type>(handle);
1460  }
1461  cipointer(const cipointer& src_cref) : m_owner_cptr(src_cref.m_owner_cptr) {
1463  m_handle_shptr = std::make_shared<mm_const_iterator_handle_type>(handle);
1464  const_item_pointer() = src_cref.const_item_pointer();
1465  }
1468  }
1471  //const mm_const_iterator_handle_type& handle() const { return (*m_handle_shptr); }
1472 
1477  /* has_next_item_or_end_marker() is just an alias for points_to_an_item(). */
1479  /* has_next() is just an alias for points_to_an_item() that's familiar to java programmers. */
1480  bool has_next() const { return const_item_pointer().has_next(); }
1481  bool has_previous() const { return const_item_pointer().has_previous(); }
1486  cipointer& operator ++() { const_item_pointer().operator ++(); return (*this); }
1487  cipointer operator++(int) { cipointer _Tmp = *this; ++*this; return (_Tmp); }
1488  cipointer& operator --() { const_item_pointer().operator --(); return (*this); }
1489  cipointer operator--(int) { cipointer _Tmp = *this; --*this; return (_Tmp); }
1492  cipointer& operator +=(difference_type n) { const_item_pointer().operator +=(n); return (*this); }
1493  cipointer& operator -=(difference_type n) { const_item_pointer().operator -=(n); return (*this); }
1494  cipointer operator+(difference_type n) const { auto retval = (*this); retval += n; return retval; }
1495  cipointer operator-(difference_type n) const { return ((*this) + (-n)); }
1496  difference_type operator-(const cipointer& _Right_cref) const { return const_item_pointer() - (_Right_cref.const_item_pointer()); }
1497  const_reference operator*() const { return const_item_pointer().operator*(); }
1498  const_reference item() const { return operator*(); }
1500  const_pointer operator->() const { return const_item_pointer().operator->(); }
1502  cipointer& operator=(const cipointer& _Right_cref) { const_item_pointer().operator=(_Right_cref.const_item_pointer()); return (*this); }
1503  bool operator==(const cipointer& _Right_cref) const { return const_item_pointer().operator==(_Right_cref.const_item_pointer()); }
1504  bool operator!=(const cipointer& _Right_cref) const { return (!(_Right_cref == (*this))); }
1505  bool operator<(const cipointer& _Right) const { return (const_item_pointer() < _Right.const_item_pointer()); }
1506  bool operator<=(const cipointer& _Right) const { return (const_item_pointer() <= _Right.const_item_pointer()); }
1507  bool operator>(const cipointer& _Right) const { return (const_item_pointer() > _Right.const_item_pointer()); }
1508  bool operator>=(const cipointer& _Right) const { return (const_item_pointer() >= _Right.const_item_pointer()); }
1511  private:
1512  const _Myt* m_owner_cptr = nullptr;
1513  std::shared_ptr<mm_const_iterator_handle_type> m_handle_shptr;
1514  friend class /*_Myt*/msevector<_Ty, _A>;
1515  };
1517  public:
1521  typedef difference_type distance_type; // retained
1524 
1525  ipointer(_Myt& owner_ref) : m_owner_ptr(&owner_ref) {
1527  m_handle_shptr = std::make_shared<mm_iterator_handle_type>(handle);
1528  }
1529  ipointer(const ipointer& src_cref) : m_owner_ptr(src_cref.m_owner_ptr) {
1531  m_handle_shptr = std::make_shared<mm_iterator_handle_type>(handle);
1532  item_pointer() = src_cref.item_pointer();
1533  }
1536  }
1538  mm_iterator_type& ip() const { return item_pointer(); }
1539  //const mm_iterator_handle_type& handle() const { return (*m_handle_shptr); }
1540  operator cipointer() const {
1541  cipointer retval(*m_owner_ptr);
1544  return retval;
1545  }
1546 
1547  void reset() { item_pointer().reset(); }
1548  bool points_to_an_item() const { return item_pointer().points_to_an_item(); }
1551  /* has_next_item_or_end_marker() is just an alias for points_to_an_item(). */
1553  /* has_next() is just an alias for points_to_an_item() that's familiar to java programmers. */
1554  bool has_next() const { return item_pointer().has_next(); }
1555  bool has_previous() const { return item_pointer().has_previous(); }
1560  ipointer& operator ++() { item_pointer().operator ++(); return (*this); }
1561  ipointer operator++(int) { ipointer _Tmp = *this; ++*this; return (_Tmp); }
1562  ipointer& operator --() { item_pointer().operator --(); return (*this); }
1563  ipointer operator--(int) { ipointer _Tmp = *this; --*this; return (_Tmp); }
1566  ipointer& operator +=(difference_type n) { item_pointer().operator +=(n); return (*this); }
1567  ipointer& operator -=(difference_type n) { item_pointer().operator -=(n); return (*this); }
1568  ipointer operator+(difference_type n) const { auto retval = (*this); retval += n; return retval; }
1569  ipointer operator-(difference_type n) const { return ((*this) + (-n)); }
1570  difference_type operator-(const ipointer& _Right_cref) const { return item_pointer() - (_Right_cref.item_pointer()); }
1571  reference operator*() const { return item_pointer().operator*(); }
1572  reference item() const { return operator*(); }
1574  pointer operator->() const { return item_pointer().operator->(); }
1575  reference operator[](difference_type _Off) const { return item_pointer()[_Off]; }
1576  ipointer& operator=(const ipointer& _Right_cref) { item_pointer().operator=(_Right_cref.item_pointer()); return (*this); }
1577  bool operator==(const ipointer& _Right_cref) const { return item_pointer().operator==(_Right_cref.item_pointer()); }
1578  bool operator!=(const ipointer& _Right_cref) const { return (!(_Right_cref == (*this))); }
1579  bool operator<(const ipointer& _Right) const { return (item_pointer() < _Right.item_pointer()); }
1580  bool operator<=(const ipointer& _Right) const { return (item_pointer() <= _Right.item_pointer()); }
1581  bool operator>(const ipointer& _Right) const { return (item_pointer() > _Right.item_pointer()); }
1582  bool operator>=(const ipointer& _Right) const { return (item_pointer() >= _Right.item_pointer()); }
1583  void set_to_item_pointer(const ipointer& _Right_cref) { item_pointer().set_to_item_pointer(_Right_cref.item_pointer()); }
1584  msev_size_t position() const { return item_pointer().position(); }
1585  private:
1586  _Myt* m_owner_ptr = nullptr;
1587  std::shared_ptr<mm_iterator_handle_type> m_handle_shptr;
1588  friend class /*_Myt*/msevector<_Ty, _A>;
1589  };
1590 
1591  ipointer ibegin() { // return ipointer for beginning of mutable sequence
1592  ipointer retval(*this);
1593  retval.set_to_beginning();
1594  return retval;
1595  }
1596  cipointer ibegin() const { // return ipointer for beginning of nonmutable sequence
1597  cipointer retval(*this);
1598  retval.set_to_beginning();
1599  return retval;
1600  }
1601  ipointer iend() { // return ipointer for end of mutable sequence
1602  ipointer retval(*this);
1603  retval.set_to_end_marker();
1604  return retval;
1605  }
1606  cipointer iend() const { // return ipointer for end of nonmutable sequence
1607  cipointer retval(*this);
1608  retval.set_to_end_marker();
1609  return retval;
1610  }
1611  cipointer cibegin() const { // return ipointer for beginning of nonmutable sequence
1612  cipointer retval(*this);
1613  retval.set_to_beginning();
1614  return retval;
1615  }
1616  cipointer ciend() const { // return ipointer for end of nonmutable sequence
1617  cipointer retval(*this);
1618  retval.set_to_end_marker();
1619  return retval;
1620  }
1621 
1622  msevector(const cipointer &start, const cipointer &end, const _A& _Al = _A())
1623  : base_class(_Al), m_mmitset(*this) {
1624  /*m_debug_size = size();*/
1625  assign(start, end);
1626  }
1628  if (start.m_owner_cptr != end.m_owner_cptr) { MSE_THROW(msevector_range_error("invalid arguments - void assign(const mm_const_iterator_type &start, const mm_const_iterator_type &end) - msevector")); }
1629  if (start > end) { MSE_THROW(msevector_range_error("invalid arguments - void assign(const mm_const_iterator_type &start, const mm_const_iterator_type &end) - msevector")); }
1630  typename base_class::const_iterator _F = start;
1631  typename base_class::const_iterator _L = end;
1632  (*this).assign(_F, _L);
1633  }
1635  auto end = last;
1636  end++; // this should include some checks
1637  (*this).assign(first, end);
1638  }
1639  void assign(const cipointer &start, const cipointer &end) {
1640  assign(start.const_item_pointer(), end.const_item_pointer());
1641  }
1642  void assign_inclusive(const cipointer &first, const cipointer &last) {
1644  }
1645  void insert_before(const mm_const_iterator_type &pos, size_type _M, const _Ty& _X) {
1646  if (pos.m_owner_cptr != this) { MSE_THROW(msevector_range_error("invalid arguments - void insert_before() - msevector")); }
1647  typename base_class::const_iterator _P = pos;
1648  (*this).insert(_P, _M, _X);
1649  }
1650  void insert_before(const mm_const_iterator_type &pos, _Ty&& _X) {
1651  if (pos.m_owner_cptr != this) { MSE_THROW(msevector_range_error("invalid arguments - void insert_before() - msevector")); }
1652  typename base_class::const_iterator _P = pos;
1653  (*this).insert(_P, 1, std::move(_X));
1654  }
1655  void insert_before(const mm_const_iterator_type &pos, const _Ty& _X = _Ty()) { (*this).insert(pos, 1, _X); }
1656  template<class _Iter
1657  //>typename std::enable_if<_mse_Is_iterator<_Iter>::value, typename base_class::iterator>::type
1658  , class = _mse_RequireInputIter<_Iter> >
1659  void insert_before(const mm_const_iterator_type &pos, const _Iter &start, const _Iter &end) {
1660  if (pos.m_owner_cptr != this) { MSE_THROW(msevector_range_error("invalid arguments - void insert_before() - msevector")); }
1661  //if (start.m_owner_cptr != end.m_owner_cptr) { MSE_THROW(msevector_range_error("invalid arguments - void insert_before(const mm_const_iterator_type &pos, const mm_const_iterator_type &start, const mm_const_iterator_type &end) - msevector")); }
1662  typename base_class::const_iterator _P = pos;
1663  (*this).insert(_P, start, end);
1664  }
1665  template<class _Iter
1666  //>typename std::enable_if<_mse_Is_iterator<_Iter>::value, typename base_class::iterator>::type
1667  , class = _mse_RequireInputIter<_Iter> >
1668  void insert_before_inclusive(const mm_const_iterator_type &pos, const _Iter &first, const _Iter &last) {
1669  if (pos.m_owner_cptr != this) { MSE_THROW(msevector_range_error("invalid arguments - void insert_before() - msevector")); }
1670  if (first.m_owner_cptr != last.m_owner_cptr) { MSE_THROW(msevector_range_error("invalid arguments - void insert_before_inclusive(const mm_const_iterator_type &pos, const mm_const_iterator_type &first, const mm_const_iterator_type &last) - msevector")); }
1671  if (!(last.points_to_item())) { MSE_THROW(msevector_range_error("invalid argument - void insert_before_inclusive(const mm_const_iterator_type &pos, const mm_const_iterator_type &first, const mm_const_iterator_type &last) - msevector")); }
1672  typename base_class::const_iterator _P = pos;
1673  auto _L = last;
1674  _L++;
1675  (*this).insert(_P, first, _L);
1676  }
1677  void insert_before(const mm_const_iterator_type &pos, _XSTD initializer_list<typename base_class::value_type> _Ilist) { // insert initializer_list
1678  if (pos.m_owner_cptr != this) { MSE_THROW(msevector_range_error("invalid arguments - void insert_before() - msevector")); }
1679  typename base_class::const_iterator _P = pos;
1680  (*this).insert(_P, _Ilist);
1681  }
1682  ipointer insert_before(const cipointer &pos, size_type _M, const _Ty& _X) {
1683  msev_size_t original_pos = pos.position();
1684  insert_before(pos.const_item_pointer(), _M, _X);
1685  ipointer retval(*this); retval.advance(msev_int(original_pos));
1686  return retval;
1687  }
1688  ipointer insert_before(const cipointer &pos, _Ty&& _X) {
1689  msev_size_t original_pos = pos.position();
1691  ipointer retval(*this); retval.advance(msev_int(original_pos));
1692  return retval;
1693  }
1694  ipointer insert_before(const cipointer &pos, const _Ty& _X = _Ty()) { return insert_before(pos, 1, _X); }
1695  template<class _Iter
1696  //>typename std::enable_if<_mse_Is_iterator<_Iter>::value, typename base_class::iterator>::type
1697  , class = _mse_RequireInputIter<_Iter> >
1698  ipointer insert_before(const cipointer &pos, const _Iter &start, const _Iter &end) {
1699  msev_size_t original_pos = pos.position();
1700  insert_before(pos.const_item_pointer(), start, end);
1701  ipointer retval(*this); retval.advance(msev_int(original_pos));
1702  return retval;
1703  }
1704  template<class _Iter
1705  //>typename std::enable_if<_mse_Is_iterator<_Iter>::value, typename base_class::iterator>::type
1706  , class = _mse_RequireInputIter<_Iter> >
1707  ipointer insert_before_inclusive(const cipointer &pos, const _Iter &first, const _Iter &last) {
1708  auto end = last; end++;
1709  return insert_before(pos, first, end);
1710  }
1711  ipointer insert_before(const cipointer &pos, _XSTD initializer_list<typename base_class::value_type> _Ilist) { // insert initializer_list
1712  msev_size_t original_pos = pos.position();
1713  (*this).insert_before(pos.const_item_pointer(), _Ilist);
1714  ipointer retval(*this); retval.advance(msev_int(original_pos));
1715  return retval;
1716  }
1717  void insert_before(msev_size_t pos, _Ty&& _X) {
1718  typename base_class::const_iterator _P = (*this).begin() + msev_as_a_size_t(pos);
1719  (*this).insert(_P, std::move(_X));
1720  }
1721  void insert_before(msev_size_t pos, const _Ty& _X = _Ty()) {
1722  typename base_class::const_iterator _P = (*this).begin() + msev_as_a_size_t(pos);
1723  (*this).insert(_P, _X);
1724  }
1725  void insert_before(msev_size_t pos, size_t _M, const _Ty& _X) {
1726  typename base_class::const_iterator _P = (*this).begin() + msev_as_a_size_t(pos);
1727  (*this).insert(_P, _M, _X);
1728  }
1729  void insert_before(msev_size_t pos, _XSTD initializer_list<typename base_class::value_type> _Ilist) { // insert initializer_list
1730  typename base_class::const_iterator _P = (*this).begin() + msev_as_a_size_t(pos);
1731  (*this).insert(_P, _Ilist);
1732  }
1733  /* These insert() functions are just aliases for their corresponding insert_before() functions. */
1734  ipointer insert(const cipointer &pos, size_type _M, const _Ty& _X) { return insert_before(pos, _M, _X); }
1735  ipointer insert(const cipointer &pos, _Ty&& _X) { return insert_before(pos, std::move(_X)); }
1736  ipointer insert(const cipointer &pos, const _Ty& _X = _Ty()) { return insert_before(pos, _X); }
1737  template<class _Iter
1738  //>typename std::enable_if<_mse_Is_iterator<_Iter>::value, typename base_class::iterator>::type
1739  , class = _mse_RequireInputIter<_Iter> >
1740  ipointer insert(const cipointer &pos, const _Iter &start, const _Iter &end) { return insert_before(pos, start, end); }
1741  ipointer insert(const cipointer &pos, _XSTD initializer_list<typename base_class::value_type> _Ilist) { return insert_before(pos, _Ilist); }
1742  template<class ..._Valty>
1743 #if !(defined(GPP4P8_COMPATIBLE))
1744  void emplace(const mm_const_iterator_type &pos, _Valty&& ..._Val)
1745  { // insert by moving _Val at pos
1746 #else
1747  void emplace(const mm_iterator_type &pos, _Valty&& ..._Val)
1748  { // insert by moving _Val at pos
1749 #endif
1750  if (pos.m_owner_cptr != this) { MSE_THROW(msevector_range_error("invalid arguments - void emplace() - msevector")); }
1751  typename base_class::const_iterator _P = pos;
1752  auto retval = base_class::emplace(_P, std::forward<_Valty>(_Val)...);
1753  }
1754  template<class ..._Valty>
1755 #if !(defined(GPP4P8_COMPATIBLE))
1756  ipointer emplace(const cipointer &pos, _Valty&& ..._Val)
1757  { // insert by moving _Val at pos
1758 #else
1759  ipointer emplace(const ipointer &pos, _Valty&& ..._Val)
1760  { // insert by moving _Val at pos
1761 #endif
1762  msev_size_t original_pos = pos.position();
1763  (*this).emplace(pos.const_item_pointer(), std::forward<_Valty>(_Val)...);
1764  ipointer retval(*this); retval.advance(msev_int(original_pos));
1765  return retval;
1766  }
1767  void erase(const mm_const_iterator_type &pos) {
1768  if (pos.m_owner_cptr != this) { MSE_THROW(msevector_range_error("invalid arguments - void erase() - msevector")); }
1769  typename base_class::const_iterator _P = pos;
1770  (*this).erase(_P);
1771  }
1773  if (start.m_owner_cptr != this) { MSE_THROW(msevector_range_error("invalid arguments - void erase() - msevector")); }
1774  if (end.m_owner_cptr != this) { MSE_THROW(msevector_range_error("invalid arguments - void erase() - msevector")); }
1775  typename base_class::const_iterator _F = start;
1776  typename base_class::const_iterator _L = end;
1777  (*this).erase(_F, _L);
1778  }
1780  if (first.m_owner_cptr != this) { MSE_THROW(msevector_range_error("invalid arguments - void erase_inclusive() - msevector")); }
1781  if (last.m_owner_cptr != this) { MSE_THROW(msevector_range_error("invalid arguments - void erase_inclusive() - msevector")); }
1782  if (!(last.points_to_item())) { MSE_THROW(msevector_range_error("invalid argument - void erase_inclusive() - msevector")); }
1783  typename base_class::const_iterator _F = first;
1784  typename base_class::const_iterator _L = last;
1785  _L++;
1786  (*this).erase(_F, _L);
1787  }
1788  ipointer erase(const cipointer &pos) {
1789  auto retval_pos = pos;
1790  retval_pos.set_to_next();
1791  erase(pos.const_item_pointer());
1792  ipointer retval = (*this).ibegin();
1793  retval.advance(msev_int(retval_pos.position()));
1794  return retval;
1795  }
1796  ipointer erase(const cipointer &start, const cipointer &end) {
1797  auto retval_pos = end;
1798  retval_pos.set_to_next();
1799  erase(start.const_item_pointer(), end.const_item_pointer());
1800  ipointer retval = (*this).ibegin();
1801  retval.advance(msev_int(retval_pos.position()));
1802  return retval;
1803  }
1804  ipointer erase_inclusive(const cipointer &first, const cipointer &last) {
1805  auto end = last; end.set_to_next();
1806  return erase(first, end);
1807  }
1809  if (pos.m_owner_cptr != this) { MSE_THROW(msevector_range_error("invalid arguments - void erase_previous_item() - msevector")); }
1810  if (!(pos.has_previous())) { MSE_THROW(msevector_range_error("invalid arguments - void erase_previous_item() - msevector")); }
1811  typename base_class::const_iterator _P = pos;
1812  _P--;
1813  (*this).erase(_P);
1814  }
1817  ipointer retval = (*this).ibegin();
1818  retval.advance(pos.position());
1819  return retval;
1820  }
1821 
1822 
1823  /* ss_const_iterator_type is a bounds checked iterator. */
1825  public:
1826  typedef typename base_class::const_iterator::iterator_category iterator_category;
1827  typedef typename base_class::const_iterator::value_type value_type;
1828  //typedef typename base_class::const_iterator::difference_type difference_type;
1830  typedef difference_type distance_type; // retained
1831  typedef typename base_class::const_iterator::pointer pointer;
1832  typedef typename base_class::const_pointer const_pointer;
1833  typedef typename base_class::const_iterator::reference reference;
1834  typedef typename base_class::const_reference const_reference;
1835 
1837  void assert_valid_index() const {
1838  if (m_owner_cptr->size() < m_index) { MSE_THROW(msevector_range_error("invalid index - void assert_valid_index() const - ss_const_iterator_type - msevector")); }
1839  }
1840  void reset() { set_to_end_marker(); }
1841  bool points_to_an_item() const {
1842  if (m_owner_cptr->size() > m_index) { return true; }
1843  else {
1844  if (m_index == m_owner_cptr->size()) { return false; }
1845  else { MSE_THROW(msevector_range_error("attempt to use invalid ss_const_iterator_type - bool points_to_an_item() const - ss_const_iterator_type - msevector")); }
1846  }
1847  }
1848  bool points_to_end_marker() const {
1849  if (false == points_to_an_item()) {
1850  assert(m_index == m_owner_cptr->size());
1851  return true;
1852  }
1853  else { return false; }
1854  }
1855  bool points_to_beginning() const {
1856  if (0 == m_index) { return true; }
1857  else { return false; }
1858  }
1859  /* has_next_item_or_end_marker() is just an alias for points_to_an_item(). */
1861  /* has_next() is just an alias for points_to_an_item() that's familiar to java programmers. */
1862  bool has_next() const { return has_next_item_or_end_marker(); }
1863  bool has_previous() const {
1864  if (m_owner_cptr->size() < m_index) {
1865  MSE_THROW(msevector_range_error("attempt to use invalid ss_const_iterator_type - bool has_previous() const - ss_const_iterator_type - msevector"));
1866  }
1867  else if (1 <= m_index) {
1868  return true;
1869  }
1870  else {
1871  return false;
1872  }
1873  }
1875  m_index = 0;
1876  }
1878  m_index = m_owner_cptr->size();
1879  }
1880  void set_to_next() {
1881  if (points_to_an_item()) {
1882  m_index += 1;
1883  }
1884  else {
1885  MSE_THROW(msevector_range_error("attempt to use invalid const_item_pointer - void set_to_next() - ss_const_iterator_type - msevector"));
1886  }
1887  }
1889  if (has_previous()) {
1890  m_index -= 1;
1891  }
1892  else {
1893  MSE_THROW(msevector_range_error("attempt to use invalid const_item_pointer - void set_to_previous() - ss_const_iterator_type - msevector"));
1894  }
1895  }
1896  ss_const_iterator_type& operator ++() { (*this).set_to_next(); return (*this); }
1897  ss_const_iterator_type operator++(int) { ss_const_iterator_type _Tmp = *this; (*this).set_to_next(); return (_Tmp); }
1898  ss_const_iterator_type& operator --() { (*this).set_to_previous(); return (*this); }
1899  ss_const_iterator_type operator--(int) { ss_const_iterator_type _Tmp = *this; (*this).set_to_previous(); return (_Tmp); }
1901  auto new_index = msev_int(m_index) + n;
1902  if ((0 > new_index) || (m_owner_cptr->size() < msev_size_t(new_index))) {
1903  MSE_THROW(msevector_range_error("index out of range - void advance(difference_type n) - ss_const_iterator_type - msevector"));
1904  }
1905  else {
1906  m_index = msev_size_t(new_index);
1907  }
1908  }
1910  ss_const_iterator_type& operator +=(difference_type n) { (*this).advance(n); return (*this); }
1911  ss_const_iterator_type& operator -=(difference_type n) { (*this).regress(n); return (*this); }
1914  retval = (*this);
1915  retval.advance(n);
1916  return retval;
1917  }
1918  ss_const_iterator_type operator-(difference_type n) const { return ((*this) + (-n)); }
1920  if (rhs.m_owner_cptr != (*this).m_owner_cptr) { MSE_THROW(msevector_range_error("invalid argument - difference_type operator-(const ss_const_iterator_type &rhs) const - msevector::ss_const_iterator_type")); }
1921  auto retval = difference_type((*this).m_index) - difference_type(rhs.m_index);
1922  assert(difference_type((*m_owner_cptr).size()) >= retval);
1923  return retval;
1924  }
1926  return (*m_owner_cptr).at(msev_as_a_size_t((*this).m_index));
1927  }
1928  const_reference item() const { return operator*(); }
1930  return m_owner_cptr->at(msev_as_a_size_t(m_index - 1));
1931  }
1933  return &((*m_owner_cptr).at(msev_as_a_size_t((*this).m_index)));
1934  }
1935  const_reference operator[](difference_type _Off) const { return (*m_owner_cptr).at(msev_as_a_size_t(difference_type(m_index) + _Off)); }
1936  /*
1937  ss_const_iterator_type& operator=(const typename base_class::const_iterator& _Right_cref)
1938  {
1939  msev_int d = std::distance<typename base_class::iterator>(m_owner_cptr->cbegin(), _Right_cref);
1940  if ((0 <= d) && (m_owner_cptr->size() >= d)) {
1941  if (m_owner_cptr->size() == d) {
1942  assert(m_owner_cptr->cend() == _Right_cref);
1943  }
1944  m_index = msev_size_t(d);
1945  base_class::const_iterator::operator=(_Right_cref);
1946  }
1947  else {
1948  MSE_THROW(msevector_range_error("doesn't seem to be a valid assignment value - ss_const_iterator_type& operator=(const typename base_class::const_iterator& _Right_cref) - ss_const_iterator_type - msevector"));
1949  }
1950  return (*this);
1951  }
1952  */
1954  ((*this).m_owner_cptr) = _Right_cref.m_owner_cptr;
1955  (*this).m_index = _Right_cref.m_index;
1956  return (*this);
1957  }
1958  bool operator==(const ss_const_iterator_type& _Right_cref) const {
1959  if (this->m_owner_cptr != _Right_cref.m_owner_cptr) { MSE_THROW(msevector_range_error("invalid argument - ss_const_iterator_type& operator==(const ss_const_iterator_type& _Right) - ss_const_iterator_type - msevector")); }
1960  return (_Right_cref.m_index == m_index);
1961  }
1962  bool operator!=(const ss_const_iterator_type& _Right_cref) const { return (!(_Right_cref == (*this))); }
1963  bool operator<(const ss_const_iterator_type& _Right) const {
1964  if (this->m_owner_cptr != _Right.m_owner_cptr) { MSE_THROW(msevector_range_error("invalid argument - ss_const_iterator_type& operator<(const ss_const_iterator_type& _Right) - ss_const_iterator_type - msevector")); }
1965  return (m_index < _Right.m_index);
1966  }
1967  bool operator<=(const ss_const_iterator_type& _Right) const { return (((*this) < _Right) || (_Right == (*this))); }
1968  bool operator>(const ss_const_iterator_type& _Right) const { return (!((*this) <= _Right)); }
1969  bool operator>=(const ss_const_iterator_type& _Right) const { return (!((*this) < _Right)); }
1971  (*this) = _Right_cref;
1972  }
1973  void invalidate_inclusive_range(msev_size_t index_of_first, msev_size_t index_of_last) {
1974  if ((index_of_first <= (*this).m_index) && (index_of_last >= (*this).m_index)) {
1975  (*this).reset();
1976  }
1977  }
1978  void shift_inclusive_range(msev_size_t index_of_first, msev_size_t index_of_last, msev_int shift) {
1979  if ((index_of_first <= (*this).m_index) && (index_of_last >= (*this).m_index)) {
1980  auto new_index = (*this).m_index + shift;
1981  if ((0 > new_index) || (m_owner_cptr->size() < new_index)) {
1982  MSE_THROW(msevector_range_error("void shift_inclusive_range() - ss_const_iterator_type - msevector"));
1983  }
1984  else {
1985  (*this).m_index = msev_size_t(new_index);
1986  (*this).sync_const_iterator_to_index();
1987  }
1988  }
1989  }
1991  return m_index;
1992  }
1993  operator typename base_class::const_iterator() const {
1994  typename base_class::const_iterator retval = (*m_owner_cptr).cbegin();
1995  retval += msev_as_a_size_t(m_index);
1996  return retval;
1997  }
1998  private:
2000  assert(m_owner_cptr->size() >= (*this).m_index);
2001  //base_class::const_iterator::operator=(m_owner_cptr->cbegin());
2002  //base_class::const_iterator::operator+=(msev_as_a_size_t(m_index));
2003  }
2006  friend class /*_Myt*/msevector<_Ty, _A>;
2007  };
2008  /* ss_iterator_type is a bounds checked iterator. */
2010  public:
2011  typedef typename base_class::iterator::iterator_category iterator_category;
2012  typedef typename base_class::iterator::value_type value_type;
2013  //typedef typename base_class::iterator::difference_type difference_type;
2015  typedef difference_type distance_type; // retained
2016  typedef typename base_class::iterator::pointer pointer;
2017  typedef typename base_class::iterator::reference reference;
2018 
2020  void reset() { set_to_end_marker(); }
2021  bool points_to_an_item() const {
2022  if (m_owner_ptr->size() > m_index) { return true; }
2023  else {
2024  if (m_index == m_owner_ptr->size()) { return false; }
2025  else { MSE_THROW(msevector_range_error("attempt to use invalid ss_iterator_type - bool points_to_an_item() const - ss_iterator_type - msevector")); }
2026  }
2027  }
2028  bool points_to_end_marker() const {
2029  if (false == points_to_an_item()) {
2030  assert(m_index == m_owner_ptr->size());
2031  return true;
2032  }
2033  else { return false; }
2034  }
2035  bool points_to_beginning() const {
2036  if (0 == m_index) { return true; }
2037  else { return false; }
2038  }
2039  /* has_next_item_or_end_marker() is just an alias for points_to_an_item(). */
2041  /* has_next() is just an alias for points_to_an_item() that's familiar to java programmers. */
2042  bool has_next() const { return has_next_item_or_end_marker(); }
2043  bool has_previous() const {
2044  if (m_owner_ptr->size() < m_index) {
2045  MSE_THROW(msevector_range_error("attempt to use invalid ss_iterator_type - bool has_previous() const - ss_iterator_type - msevector"));
2046  } else if (1 <= m_index) {
2047  return true;
2048  }
2049  else {
2050  return false;
2051  }
2052  }
2054  m_index = 0;
2055  }
2057  m_index = m_owner_ptr->size();
2058  }
2059  void set_to_next() {
2060  if (points_to_an_item()) {
2061  m_index += 1;
2062  }
2063  else {
2064  MSE_THROW(msevector_range_error("attempt to use invalid item_pointer - void set_to_next() - ss_const_iterator_type - msevector"));
2065  }
2066  }
2068  if (has_previous()) {
2069  m_index -= 1;
2070  }
2071  else {
2072  MSE_THROW(msevector_range_error("attempt to use invalid item_pointer - void set_to_previous() - ss_iterator_type - msevector"));
2073  }
2074  }
2075  ss_iterator_type& operator ++() { (*this).set_to_next(); return (*this); }
2076  ss_iterator_type operator++(int) { ss_iterator_type _Tmp = *this; (*this).set_to_next(); return (_Tmp); }
2077  ss_iterator_type& operator --() { (*this).set_to_previous(); return (*this); }
2078  ss_iterator_type operator--(int) { ss_iterator_type _Tmp = *this; (*this).set_to_previous(); return (_Tmp); }
2080  auto new_index = msev_int(m_index) + n;
2081  if ((0 > new_index) || (m_owner_ptr->size() < msev_size_t(new_index))) {
2082  MSE_THROW(msevector_range_error("index out of range - void advance(difference_type n) - ss_iterator_type - msevector"));
2083  }
2084  else {
2085  m_index = msev_size_t(new_index);
2086  }
2087  }
2089  ss_iterator_type& operator +=(difference_type n) { (*this).advance(n); return (*this); }
2090  ss_iterator_type& operator -=(difference_type n) { (*this).regress(n); return (*this); }
2092  ss_iterator_type retval; retval.m_owner_ptr = m_owner_ptr;
2093  retval = (*this);
2094  retval.advance(n);
2095  return retval;
2096  }
2097  ss_iterator_type operator-(difference_type n) const { return ((*this) + (-n)); }
2099  if (rhs.m_owner_ptr != (*this).m_owner_ptr) { MSE_THROW(msevector_range_error("invalid argument - difference_type operator-(const ss_iterator_type& rhs) const - msevector::ss_iterator_type")); }
2100  auto retval = difference_type((*this).m_index) - difference_type(rhs.m_index);
2101  assert(int((*m_owner_ptr).size()) >= retval);
2102  return retval;
2103  }
2105  return (*m_owner_ptr).at(msev_as_a_size_t((*this).m_index));
2106  }
2107  reference item() const { return operator*(); }
2109  return m_owner_ptr->at(msev_as_a_size_t(m_index - 1));
2110  }
2112  return &((*m_owner_ptr).at(msev_as_a_size_t((*this).m_index)));
2113  }
2114  reference operator[](difference_type _Off) const { return (*m_owner_ptr).at(msev_as_a_size_t(difference_type(m_index) + _Off)); }
2115  /*
2116  ss_iterator_type& operator=(const typename base_class::iterator& _Right_cref)
2117  {
2118  msev_int d = std::distance<typename base_class::iterator>(m_owner_ptr->begin(), _Right_cref);
2119  if ((0 <= d) && (m_owner_ptr->size() >= d)) {
2120  if (m_owner_ptr->size() == d) {
2121  assert(m_owner_ptr->end() == _Right_cref);
2122  }
2123  m_index = msev_size_t(d);
2124  base_class::iterator::operator=(_Right_cref);
2125  }
2126  else {
2127  MSE_THROW(msevector_range_error("doesn't seem to be a valid assignment value - ss_iterator_type& operator=(const typename base_class::iterator& _Right_cref) - ss_const_iterator_type - msevector"));
2128  }
2129  return (*this);
2130  }
2131  */
2133  ((*this).m_owner_ptr) = _Right_cref.m_owner_ptr;
2134  (*this).m_index = _Right_cref.m_index;
2135  return (*this);
2136  }
2137  bool operator==(const ss_iterator_type& _Right_cref) const {
2138  if (this->m_owner_ptr != _Right_cref.m_owner_ptr) { MSE_THROW(msevector_range_error("invalid argument - ss_iterator_type& operator==(const ss_iterator_type& _Right) - ss_iterator_type - msevector")); }
2139  return (_Right_cref.m_index == m_index);
2140  }
2141  bool operator!=(const ss_iterator_type& _Right_cref) const { return (!(_Right_cref == (*this))); }
2142  bool operator<(const ss_iterator_type& _Right) const {
2143  if (this->m_owner_ptr != _Right.m_owner_ptr) { MSE_THROW(msevector_range_error("invalid argument - ss_iterator_type& operator<(const ss_iterator_type& _Right) - ss_iterator_type - msevector")); }
2144  return (m_index < _Right.m_index);
2145  }
2146  bool operator<=(const ss_iterator_type& _Right) const { return (((*this) < _Right) || (_Right == (*this))); }
2147  bool operator>(const ss_iterator_type& _Right) const { return (!((*this) <= _Right)); }
2148  bool operator>=(const ss_iterator_type& _Right) const { return (!((*this) < _Right)); }
2149  void set_to_item_pointer(const ss_iterator_type& _Right_cref) {
2150  (*this) = _Right_cref;
2151  }
2152  void invalidate_inclusive_range(msev_size_t index_of_first, msev_size_t index_of_last) {
2153  if ((index_of_first <= (*this).m_index) && (index_of_last >= (*this).m_index)) {
2154  (*this).reset();
2155  }
2156  }
2157  void shift_inclusive_range(msev_size_t index_of_first, msev_size_t index_of_last, msev_int shift) {
2158  if ((index_of_first <= (*this).m_index) && (index_of_last >= (*this).m_index)) {
2159  auto new_index = (*this).m_index + shift;
2160  if ((0 > new_index) || (m_owner_ptr->size() < new_index)) {
2161  MSE_THROW(msevector_range_error("void shift_inclusive_range() - ss_iterator_type - msevector"));
2162  }
2163  else {
2164  (*this).m_index = msev_size_t(new_index);
2165  (*this).sync_iterator_to_index();
2166  }
2167  }
2168  }
2170  return m_index;
2171  }
2172  operator ss_const_iterator_type() const {
2173  ss_const_iterator_type retval;
2174  if (nullptr != m_owner_ptr) {
2175  retval = m_owner_ptr->ss_cbegin();
2176  retval.advance(msev_int(m_index));
2177  }
2178  return retval;
2179  }
2180  operator typename base_class::iterator() const {
2181  typename base_class::iterator retval = (*m_owner_ptr).begin();
2182  retval += msev_as_a_size_t(m_index);
2183  return retval;
2184  }
2185 
2186  private:
2188  assert(m_owner_ptr->size() >= (*this).m_index);
2189  //base_class::iterator::operator=(m_owner_ptr->begin());
2190  //base_class::iterator::operator+=(msev_as_a_size_t(m_index));
2191  }
2194  friend class /*_Myt*/msevector<_Ty, _A>;
2195  };
2196  typedef std::reverse_iterator<ss_iterator_type> ss_reverse_iterator_type;
2197  typedef std::reverse_iterator<ss_const_iterator_type> ss_const_reverse_iterator_type;
2198 
2200  { // return base_class::iterator for beginning of mutable sequence
2201  ss_iterator_type retval; retval.m_owner_ptr = this;
2202  retval.set_to_beginning();
2203  return retval;
2204  }
2205 
2207  { // return base_class::iterator for beginning of nonmutable sequence
2208  ss_const_iterator_type retval; retval.m_owner_cptr = this;
2209  retval.set_to_beginning();
2210  return retval;
2211  }
2212 
2214  { // return base_class::iterator for end of mutable sequence
2215  ss_iterator_type retval; retval.m_owner_ptr = this;
2216  retval.set_to_end_marker();
2217  return retval;
2218  }
2219 
2221  { // return base_class::iterator for end of nonmutable sequence
2222  ss_const_iterator_type retval; retval.m_owner_cptr = this;
2223  retval.set_to_end_marker();
2224  return retval;
2225  }
2226 
2228  { // return base_class::iterator for beginning of nonmutable sequence
2229  ss_const_iterator_type retval; retval.m_owner_cptr = this;
2230  retval.set_to_beginning();
2231  return retval;
2232  }
2233 
2235  { // return base_class::iterator for end of nonmutable sequence
2236  ss_const_iterator_type retval; retval.m_owner_cptr = this;
2237  retval.set_to_end_marker();
2238  return retval;
2239  }
2240 
2242  { // return base_class::iterator for beginning of reversed nonmutable sequence
2243  return (ss_rbegin());
2244  }
2245 
2247  { // return base_class::iterator for end of reversed nonmutable sequence
2248  return (ss_rend());
2249  }
2250 
2252  { // return base_class::iterator for beginning of reversed mutable sequence
2253  return (reverse_iterator(ss_end()));
2254  }
2255 
2257  { // return base_class::iterator for beginning of reversed nonmutable sequence
2258  return (const_reverse_iterator(ss_end()));
2259  }
2260 
2262  { // return base_class::iterator for end of reversed mutable sequence
2263  return (reverse_iterator(ss_begin()));
2264  }
2265 
2267  { // return base_class::iterator for end of reversed nonmutable sequence
2268  return (const_reverse_iterator(ss_begin()));
2269  }
2270 
2271  msevector(const ss_const_iterator_type &start, const ss_const_iterator_type &end, const _A& _Al = _A())
2272  : base_class(_Al), m_mmitset(*this) {
2273  /*m_debug_size = size();*/
2274  assign(start, end);
2275  }
2277  if (start.m_owner_cptr != end.m_owner_cptr) { MSE_THROW(msevector_range_error("invalid arguments - void assign(const ss_const_iterator_type &start, const ss_const_iterator_type &end) - msevector")); }
2278  if (start > end) { MSE_THROW(msevector_range_error("invalid arguments - void assign(const ss_const_iterator_type &start, const ss_const_iterator_type &end) - msevector")); }
2279  typename base_class::const_iterator _F = start;
2280  typename base_class::const_iterator _L = end;
2281  (*this).assign(_F, _L);
2282  }
2284  auto end = last;
2285  end++; // this should include some checks
2286  (*this).assign(first, end);
2287  }
2289  if (pos.m_owner_cptr != this) { MSE_THROW(msevector_range_error("invalid argument - void insert_before() - msevector")); }
2290  pos.assert_valid_index();
2291  msev_size_t original_pos = pos.position();
2292  typename base_class::const_iterator _P = pos;
2293  (*this).insert(_P, _M, _X);
2294  ss_iterator_type retval = ss_begin();
2295  retval.advance(msev_int(original_pos));
2296  return retval;
2297  }
2299  if (pos.m_owner_cptr != this) { MSE_THROW(msevector_range_error("invalid argument - void insert_before() - msevector")); }
2300  pos.assert_valid_index();
2301  msev_size_t original_pos = pos.position();
2302  typename base_class::const_iterator _P = pos;
2303  (*this).insert(_P, std::move(_X));
2304  ss_iterator_type retval = ss_begin();
2305  retval.advance(msev_int(original_pos));
2306  return retval;
2307  }
2308  ss_iterator_type insert_before(const ss_const_iterator_type &pos, const _Ty& _X = _Ty()) { return (*this).insert(pos, 1, _X); }
2309  template<class _Iter
2310  //>typename std::enable_if<_mse_Is_iterator<_Iter>::value, typename base_class::iterator>::type
2311  , class = _mse_RequireInputIter<_Iter> >
2312  ss_iterator_type insert_before(const ss_const_iterator_type &pos, const _Iter &start, const _Iter &end) {
2313  if (pos.m_owner_cptr != this) { MSE_THROW(msevector_range_error("invalid argument - ss_iterator_type insert_before() - msevector")); }
2314  //if (start.m_owner_cptr != end.m_owner_cptr) { MSE_THROW(msevector_range_error("invalid arguments - void insert_before(const ss_const_iterator_type &pos, const ss_const_iterator_type &start, const ss_const_iterator_type &end) - msevector")); }
2315  pos.assert_valid_index();
2316  msev_size_t original_pos = pos.position();
2317  typename base_class::const_iterator _P = pos;
2318  (*this).insert(_P, start, end);
2319  ss_iterator_type retval = ss_begin();
2320  retval.advance(msev_int(original_pos));
2321  return retval;
2322  }
2324  if (start.m_owner_cptr != end.m_owner_cptr) { MSE_THROW(msevector_range_error("invalid arguments - void insert_before(const ss_const_iterator_type &pos, const ss_const_iterator_type &start, const ss_const_iterator_type &end) - msevector")); }
2325  end.assert_valid_index();
2326  if (start > end) { MSE_THROW(msevector_range_error("invalid arguments - void insert_before(const ss_const_iterator_type &pos, const ss_const_iterator_type &start, const ss_const_iterator_type &end) - msevector")); }
2327  typename base_class::const_iterator _S = start;
2328  typename base_class::const_iterator _E = end;
2329  return (*this).insert_before(pos, _S, _E);
2330  }
2331  ss_iterator_type insert_before(const ss_const_iterator_type &pos, const _Ty* start, const _Ty* end) {
2332  if (pos.m_owner_cptr != this) { MSE_THROW(msevector_range_error("invalid arguments - ss_iterator_type insert_before() - msevector")); }
2333  //if (start.m_owner_cptr != end.m_owner_cptr) { MSE_THROW(msevector_range_error("invalid arguments - void insert_before(const ss_const_iterator_type &pos, const ss_const_iterator_type &start, const ss_const_iterator_type &end) - msevector")); }
2334  if (start > end) { MSE_THROW(msevector_range_error("invalid arguments - ss_iterator_type insert_before() - msevector")); }
2335  pos.assert_valid_index();
2336  msev_size_t original_pos = pos.position();
2337  typename base_class::const_iterator _P = pos;
2338  (*this).insert(_P, start, end);
2339  ss_iterator_type retval = ss_begin();
2340  retval.advance(msev_int(original_pos));
2341  return retval;
2342  }
2343  template<class _Iter
2344  //>typename std::enable_if<_mse_Is_iterator<_Iter>::value, typename base_class::iterator>::type
2345  , class = _mse_RequireInputIter<_Iter> >
2346  ss_iterator_type insert_before_inclusive(const ss_iterator_type &pos, const _Iter &first, const _Iter &last) {
2347  auto end = last;
2348  end++; // this may include some checks
2349  return (*this).insert_before(pos, first, end);
2350  }
2351  ss_iterator_type insert_before(const ss_const_iterator_type &pos, _XSTD initializer_list<typename base_class::value_type> _Ilist) { // insert initializer_list
2352  if (pos.m_owner_ptr != this) { MSE_THROW(msevector_range_error("invalid arguments - void insert_before() - msevector")); }
2353  pos.assert_valid_index();
2354  msev_size_t original_pos = pos.position();
2355  typename base_class::const_iterator _P = pos;
2356  (*this).insert(_P, _Ilist);
2357  ss_iterator_type retval = ss_begin();
2358  retval.advance(msev_int(original_pos));
2359  return retval;
2360  }
2361  /* These insert() functions are just aliases for their corresponding insert_before() functions. */
2362  ss_iterator_type insert(const ss_const_iterator_type &pos, size_type _M, const _Ty& _X) { return insert_before(pos, _M, _X); }
2363  ss_iterator_type insert(const ss_const_iterator_type &pos, _Ty&& _X) { return insert_before(pos, std::move(_X)); }
2364  ss_iterator_type insert(const ss_const_iterator_type &pos, const _Ty& _X = _Ty()) { return insert_before(pos, _X); }
2365  template<class _Iter
2366  //>typename std::enable_if<_mse_Is_iterator<_Iter>::value, typename base_class::iterator>::type
2367  , class = _mse_RequireInputIter<_Iter> >
2368  ss_iterator_type insert(const ss_const_iterator_type &pos, const _Iter &start, const _Iter &end) { return insert_before(pos, start, end); }
2369  ss_iterator_type insert(const ss_const_iterator_type &pos, const _Ty* start, const _Ty* &end) { return insert_before(pos, start, end); }
2370  ss_iterator_type insert(const ss_const_iterator_type &pos, _XSTD initializer_list<typename base_class::value_type> _Ilist) { return insert_before(pos, _Ilist); }
2371  template<class ..._Valty>
2372 #if !(defined(GPP4P8_COMPATIBLE))
2373  ss_iterator_type emplace(const ss_const_iterator_type &pos, _Valty&& ..._Val)
2374  { // insert by moving _Val at pos
2375  if (pos.m_owner_cptr != this) { MSE_THROW(msevector_range_error("invalid arguments - void emplace() - msevector")); }
2376 #else
2377  ipointer emplace(const ipointer &pos, _Valty&& ..._Val)
2378  { // insert by moving _Val at pos
2379  if (pos.m_owner_ptr != this) { MSE_THROW(msevector_range_error("invalid arguments - void emplace() - msevector")); }
2380 #endif
2381  pos.assert_valid_index();
2382  msev_size_t original_pos = pos.position();
2383  typename base_class::const_iterator _P = pos;
2384  (*this).emplace(_P, std::forward<_Valty>(_Val)...);
2385  ss_iterator_type retval = ss_begin();
2386  retval.advance(msev_int(original_pos));
2387  return retval;
2388  }
2390  if (pos.m_owner_cptr != this) { MSE_THROW(msevector_range_error("invalid arguments - void erase() - msevector")); }
2391  if (!pos.points_to_an_item()) { MSE_THROW(msevector_range_error("invalid arguments - void erase() - msevector")); }
2392  auto pos_index = pos.position();
2393 
2394  typename base_class::const_iterator _P = pos;
2395  (*this).erase(_P);
2396 
2397  ss_iterator_type retval = (*this).ss_begin();
2398  retval.advance(typename ss_const_iterator_type::difference_type(pos_index));
2399  return retval;
2400  }
2402  if (start.m_owner_cptr != this) { MSE_THROW(msevector_range_error("invalid arguments - void erase() - msevector")); }
2403  if (end.m_owner_cptr != this) { MSE_THROW(msevector_range_error("invalid arguments - void erase() - msevector")); }
2404  if (start.position() > end.position()) { MSE_THROW(msevector_range_error("invalid arguments - void erase() - msevector")); }
2405  auto pos_index = start.position();
2406 
2407  typename base_class::const_iterator _F = start;
2408  typename base_class::const_iterator _L = end;
2409  (*this).erase(_F, _L);
2410 
2411  ss_iterator_type retval = (*this).ss_begin();
2412  retval.advance(typename ss_const_iterator_type::difference_type(pos_index));
2413  return retval;
2414  }
2416  auto end = last; end.set_to_next();
2417  return erase(first, end);
2418  }
2420  if (pos.m_owner_cptr != this) { MSE_THROW(msevector_range_error("invalid arguments - void erase_previous_item() - msevector")); }
2421  if (!(pos.has_previous())) { MSE_THROW(msevector_range_error("invalid arguments - void erase_previous_item() - msevector")); }
2422  typename base_class::const_iterator _P = pos;
2423  _P--;
2424  (*this).erase(_P);
2425  }
2426  };
2427 
2428 }
2429 
2430 #undef MSE_THROW
2431 
2432 #endif /*ndef MSEMSEVECTOR_H*/
msev_pointer(const msev_pointer< _Ty > &src)
Definition: msemsevector.h:82
bool operator!=(const msev_pointer _Right_cref) const
Definition: msemsevector.h:101
bool operator!() const
Definition: msemsevector.h:105
bool operator==(const msev_pointer _Right_cref) const
Definition: msemsevector.h:100
_Ty * operator->() const
Definition: msemsevector.h:90
_Ty & operator*() const
Definition: msemsevector.h:84
bool operator!=(const _Ty *_Right_cref) const
Definition: msemsevector.h:103
bool operator==(const _Ty *_Right_cref) const
Definition: msemsevector.h:102
msev_pointer< _Ty > & operator=(_Ty *ptr)
Definition: msemsevector.h:96
msev_pointer(_Ty *ptr)
Definition: msemsevector.h:81
bool operator!=(const cipointer &_Right_cref) const
cipointer & operator-=(difference_type n)
void regress(difference_type n)
cipointer & operator=(const cipointer &_Right_cref)
std::shared_ptr< mm_const_iterator_handle_type > m_handle_shptr
bool operator>=(const cipointer &_Right) const
bool operator<(const cipointer &_Right) const
bool has_next_item_or_end_marker() const
const_reference operator*() const
mm_const_iterator_type & const_item_pointer() const
bool operator>(const cipointer &_Right) const
mm_const_iterator_type::reference reference
mm_const_iterator_type::difference_type difference_type
mm_const_iterator_type & cip() const
difference_type operator-(const cipointer &_Right_cref) const
mm_const_iterator_type::const_reference const_reference
cipointer(const cipointer &src_cref)
void set_to_const_item_pointer(const cipointer &_Right_cref)
cipointer operator-(difference_type n) const
mm_const_iterator_type::const_pointer const_pointer
cipointer & operator+=(difference_type n)
mm_const_iterator_type::value_type value_type
cipointer operator+(difference_type n) const
bool points_to_end_marker() const
difference_type distance_type
mm_const_iterator_type::pointer pointer
mm_const_iterator_type::iterator_category iterator_category
bool points_to_an_item() const
const_reference item() const
bool operator<=(const cipointer &_Right) const
const_reference previous_item() const
const_reference operator[](difference_type _Off) const
msev_size_t position() const
bool operator==(const cipointer &_Right_cref) const
bool points_to_beginning() const
cipointer(const _Myt &owner_cref)
const_pointer operator->() const
void advance(difference_type n)
ipointer operator-(difference_type n) const
void advance(difference_type n)
ipointer(const ipointer &src_cref)
bool points_to_end_marker() const
void regress(difference_type n)
mm_iterator_type::value_type value_type
bool points_to_an_item() const
bool operator>(const ipointer &_Right) const
bool operator>=(const ipointer &_Right) const
bool operator==(const ipointer &_Right_cref) const
reference operator[](difference_type _Off) const
mm_iterator_type & item_pointer() const
difference_type distance_type
bool points_to_beginning() const
ipointer operator+(difference_type n) const
reference operator*() const
mm_iterator_type::pointer pointer
reference previous_item() const
bool has_next_item_or_end_marker() const
pointer operator->() const
ipointer & operator+=(difference_type n)
bool operator!=(const ipointer &_Right_cref) const
ipointer & operator-=(difference_type n)
mm_iterator_type::reference reference
mm_iterator_type & ip() const
ipointer & operator=(const ipointer &_Right_cref)
bool operator<=(const ipointer &_Right) const
void set_to_item_pointer(const ipointer &_Right_cref)
difference_type operator-(const ipointer &_Right_cref) const
ipointer(_Myt &owner_ref)
mm_iterator_type::difference_type difference_type
reference item() const
bool operator<(const ipointer &_Right) const
std::shared_ptr< mm_iterator_handle_type > m_handle_shptr
mm_iterator_type::iterator_category iterator_category
msev_size_t position() const
std::shared_ptr< mm_const_iterator_type > m_shptr
mm_const_iterator_handle_type(const CHashKey1 &key_cref, const std::shared_ptr< mm_const_iterator_type > &shptr_cref)
mm_const_iterator_type(const _Myt &owner_cref)
Definition: msemsevector.h:911
mm_const_iterator_type(const mm_const_iterator_type &src_cref)
Definition: msemsevector.h:913
const_reference previous_item() const
Definition: msemsevector.h:830
mm_const_iterator_type operator--(int)
Definition: msemsevector.h:794
difference_type operator-(const mm_const_iterator_type &rhs) const
Definition: msemsevector.h:820
base_class::const_reference const_reference
Definition: msemsevector.h:739
mm_const_iterator_type & operator++()
Definition: msemsevector.h:791
void set_to_const_item_pointer(const mm_const_iterator_type &_Right_cref)
Definition: msemsevector.h:881
base_class::const_iterator::reference reference
Definition: msemsevector.h:738
mm_const_iterator_type & operator+=(difference_type n)
Definition: msemsevector.h:811
bool operator<(const mm_const_iterator_type &_Right) const
Definition: msemsevector.h:874
bool operator==(const mm_const_iterator_type &_Right_cref) const
Definition: msemsevector.h:869
base_class::const_iterator::iterator_category iterator_category
Definition: msemsevector.h:731
mm_const_iterator_type & operator=(const mm_const_iterator_type &_Right_cref)
Definition: msemsevector.h:857
bool operator>(const mm_const_iterator_type &_Right) const
Definition: msemsevector.h:879
mm_const_iterator_type operator-(difference_type n) const
Definition: msemsevector.h:819
void invalidate_inclusive_range(msev_size_t index_of_first, msev_size_t index_of_last)
Definition: msemsevector.h:884
mm_const_iterator_type & operator--()
Definition: msemsevector.h:793
base_class::const_iterator::pointer const_pointer
Definition: msemsevector.h:737
mm_const_iterator_type & operator-=(difference_type n)
Definition: msemsevector.h:812
mm_const_iterator_type operator+(difference_type n) const
Definition: msemsevector.h:813
base_class::const_iterator::pointer pointer
Definition: msemsevector.h:736
bool operator<=(const mm_const_iterator_type &_Right) const
Definition: msemsevector.h:878
const_reference operator[](difference_type _Off) const
Definition: msemsevector.h:836
bool operator>=(const mm_const_iterator_type &_Right) const
Definition: msemsevector.h:880
base_class::const_iterator::value_type value_type
Definition: msemsevector.h:732
bool operator!=(const mm_const_iterator_type &_Right_cref) const
Definition: msemsevector.h:873
mm_const_iterator_type operator++(int)
Definition: msemsevector.h:792
const_reference operator*() const
Definition: msemsevector.h:826
void shift_inclusive_range(msev_size_t index_of_first, msev_size_t index_of_last, msev_int shift)
Definition: msemsevector.h:889
std::shared_ptr< mm_iterator_type > m_shptr
mm_iterator_handle_type(const CHashKey1 &key_cref, const std::shared_ptr< mm_iterator_type > &shptr_ref)
assignable_CMMConstIterators_value_type & operator=(const typename CMMConstIterators::value_type &rhs)
assignable_CMMConstIterators_value_type(const typename CMMConstIterators::value_type &src)
assignable_CMMIterators_value_type & operator=(const typename CMMIterators::value_type &rhs)
assignable_CMMIterators_value_type(const typename CMMIterators::value_type &src)
void release_const_item_pointer(mm_const_iterator_handle_type handle)
mm_iterator_set_type & operator=(const mm_iterator_set_type &src_cref)
mm_iterator_handle_type allocate_new_item_pointer()
assignable_CMMIterators_value_type m_fm1_key_mm_it_array[sc_fm1_max_mm_iterators]
CMMConstIterators * m_aux_mm_const_iterator_shptrs_ptr
void apply_to_all_mm_iterator_shptrs(const std::function< void(std::shared_ptr< mm_iterator_type > &)> &func_obj_ref)
void invalidate_inclusive_range(msev_size_t start_index, msev_size_t end_index)
mm_iterator_set_type & operator=(mm_iterator_set_type &&src)
void shift_inclusive_range(msev_size_t start_index, msev_size_t end_index, msev_int shift)
mm_const_iterator_handle_type allocate_new_const_item_pointer()
mm_iterator_set_type(const mm_iterator_set_type &&src)
void release_item_pointer(mm_iterator_handle_type handle)
mm_iterator_type & item_pointer(mm_iterator_handle_type handle)
void apply_to_all_mm_const_iterator_shptrs(const std::function< void(std::shared_ptr< mm_const_iterator_type > &)> &func_obj_ref)
assignable_CMMConstIterators_value_type m_fm1_key_mm_const_it_array[sc_fm1_max_mm_iterators]
mm_iterator_set_type(const mm_iterator_set_type &src)
mm_const_iterator_type & const_item_pointer(mm_const_iterator_handle_type handle) const
mm_iterator_type & operator-=(difference_type n)
mm_iterator_type operator+(difference_type n) const
mm_iterator_type & operator++()
Definition: msemsevector.h:985
void shift_inclusive_range(msev_size_t index_of_first, msev_size_t index_of_last, msev_int shift)
base_class::iterator::reference reference
Definition: msemsevector.h:933
void set_to_item_pointer(const mm_iterator_type &_Right_cref)
base_class::iterator::iterator_category iterator_category
Definition: msemsevector.h:927
void advance(difference_type n)
Definition: msemsevector.h:989
mm_iterator_type operator++(int)
Definition: msemsevector.h:986
void invalidate_inclusive_range(msev_size_t index_of_first, msev_size_t index_of_last)
reference operator[](difference_type _Off) const
bool operator<=(const mm_iterator_type &_Right) const
mm_iterator_type & operator=(const mm_iterator_type &_Right_cref)
mm_iterator_type & operator+=(difference_type n)
mm_iterator_type operator--(int)
Definition: msemsevector.h:988
mm_iterator_type(const mm_iterator_type &src_cref)
bool operator>(const mm_iterator_type &_Right) const
bool operator!=(const mm_iterator_type &_Right_cref) const
mm_iterator_type & operator--()
Definition: msemsevector.h:987
base_class::iterator::pointer pointer
Definition: msemsevector.h:932
bool operator>=(const mm_iterator_type &_Right) const
bool operator<(const mm_iterator_type &_Right) const
mm_iterator_type operator-(difference_type n) const
bool operator==(const mm_iterator_type &_Right_cref) const
difference_type operator-(const mm_iterator_type &rhs) const
base_class::iterator::value_type value_type
Definition: msemsevector.h:928
void set_to_const_item_pointer(const ss_const_iterator_type &_Right_cref)
bool operator>=(const ss_const_iterator_type &_Right) const
base_class::const_iterator::reference reference
bool operator>(const ss_const_iterator_type &_Right) const
msev_pointer< const _Myt > m_owner_cptr
base_class::const_pointer const_pointer
bool operator!=(const ss_const_iterator_type &_Right_cref) const
base_class::const_iterator::value_type value_type
void shift_inclusive_range(msev_size_t index_of_first, msev_size_t index_of_last, msev_int shift)
ss_const_iterator_type operator-(difference_type n) const
base_class::const_iterator::iterator_category iterator_category
ss_const_iterator_type & operator+=(difference_type n)
ss_const_iterator_type & operator--()
ss_const_iterator_type operator+(difference_type n) const
ss_const_iterator_type & operator++()
const_reference operator[](difference_type _Off) const
bool operator==(const ss_const_iterator_type &_Right_cref) const
const_reference previous_item() const
bool operator<=(const ss_const_iterator_type &_Right) const
bool operator<(const ss_const_iterator_type &_Right) const
ss_const_iterator_type & operator-=(difference_type n)
base_class::const_iterator::pointer pointer
ss_const_iterator_type & operator=(const ss_const_iterator_type &_Right_cref)
ss_const_iterator_type operator++(int)
void invalidate_inclusive_range(msev_size_t index_of_first, msev_size_t index_of_last)
base_class::const_reference const_reference
difference_type operator-(const ss_const_iterator_type &rhs) const
ss_const_iterator_type operator--(int)
ss_iterator_type operator++(int)
base_class::iterator::iterator_category iterator_category
void set_to_item_pointer(const ss_iterator_type &_Right_cref)
ss_iterator_type operator-(difference_type n) const
ss_iterator_type & operator+=(difference_type n)
ss_iterator_type & operator--()
reference operator[](difference_type _Off) const
ss_iterator_type & operator++()
bool operator<(const ss_iterator_type &_Right) const
msev_pointer< _Myt > m_owner_ptr
base_class::iterator::reference reference
bool operator>=(const ss_iterator_type &_Right) const
void advance(difference_type n)
difference_type operator-(const ss_iterator_type &rhs) const
void regress(difference_type n)
ss_iterator_type & operator=(const ss_iterator_type &_Right_cref)
bool operator==(const ss_iterator_type &_Right_cref) const
ss_iterator_type operator--(int)
bool operator>(const ss_iterator_type &_Right) const
bool operator<=(const ss_iterator_type &_Right) const
base_class::iterator::value_type value_type
_Myt::difference_type difference_type
base_class::iterator::pointer pointer
void shift_inclusive_range(msev_size_t index_of_first, msev_size_t index_of_last, msev_int shift)
bool operator!=(const ss_iterator_type &_Right_cref) const
ss_iterator_type operator+(difference_type n) const
ss_iterator_type & operator-=(difference_type n)
void invalidate_inclusive_range(msev_size_t index_of_first, msev_size_t index_of_last)
ss_iterator_type emplace(const ss_const_iterator_type &pos, _Valty &&..._Val)
void release_item_pointer(mm_iterator_handle_type handle) const
mm_const_iterator_handle_type allocate_new_const_item_pointer() const
msevector(const cipointer &start, const cipointer &end, const _A &_Al=_A())
void emplace_back(_Valty &&..._Val)
Definition: msemsevector.h:503
void assign(size_type _N, const _Ty &_X=_Ty())
Definition: msemsevector.h:346
void insert_before(const mm_const_iterator_type &pos, _Ty &&_X)
base_class::reference operator[](size_type _P)
Definition: msemsevector.h:254
void erase(const mm_const_iterator_type &start, const mm_const_iterator_type &end)
msevector(_It _F, _It _L, const _A &_Al=_A())
Definition: msemsevector.h:183
ss_iterator_type insert(const ss_const_iterator_type &pos, const _Ty *start, const _Ty *&end)
cipointer ibegin() const
void assign_inclusive(const mm_const_iterator_type &first, const mm_const_iterator_type &last)
ss_iterator_type insert_before(const ss_const_iterator_type &pos, const ss_const_iterator_type &start, const ss_const_iterator_type &end)
ss_iterator_type insert_before(const ss_const_iterator_type &pos, const _Iter &start, const _Iter &end)
ipointer insert(const cipointer &pos, ::std::initializer_list< typename base_class::value_type > _Ilist)
void resize(size_type _N, const _Ty &_X=_Ty())
Definition: msemsevector.h:233
ss_const_reverse_iterator_type ss_crend() const
void reserve(size_type _Count)
Definition: msemsevector.h:210
void insert_before(const mm_const_iterator_type &pos, const _Iter &start, const _Iter &end)
ipointer erase(const cipointer &pos)
base_class::const_reference front() const
Definition: msemsevector.h:261
msevector(const _A &_Al=_A())
Definition: msemsevector.h:165
std::vector< _Ty, _A > base_class
Definition: msemsevector.h:152
msevector(size_type _N)
Definition: msemsevector.h:169
ipointer insert_before(const cipointer &pos, size_type _M, const _Ty &_X)
ss_iterator_type insert(const ss_const_iterator_type &pos, _Ty &&_X)
void insert_before(msev_size_t pos, const _Ty &_X=_Ty())
ss_iterator_type insert_before(const ss_const_iterator_type &pos, const _Ty *start, const _Ty *end)
base_class::const_pointer const_pointer
Definition: msemsevector.h:161
void push_back(_Ty &&_X)
Definition: msemsevector.h:273
base_class::iterator insert(typename base_class::const_iterator _P, const _Ty &_X=_Ty())
Definition: msemsevector.h:354
void swap(base_class &_X)
Definition: msemsevector.h:642
ss_const_reverse_iterator_type ss_rbegin() const
ss_iterator_type erase(const ss_const_iterator_type &pos)
msevector(const ss_const_iterator_type &start, const ss_const_iterator_type &end, const _A &_Al=_A())
base_class::iterator insert(typename base_class::const_iterator _P, _Ty &&_X)
Definition: msemsevector.h:351
ipointer insert(const cipointer &pos, size_type _M, const _Ty &_X)
msev_int difference_type
Definition: msemsevector.h:159
ipointer ibegin()
msevector(base_class &&_X)
Definition: msemsevector.h:177
void insert_before(msev_size_t pos, ::std::initializer_list< typename base_class::value_type > _Ilist)
base_class::const_iterator _It
Definition: msemsevector.h:181
base_class::const_reference operator[](size_type _P) const
Definition: msemsevector.h:251
std::reverse_iterator< ss_const_iterator_type > ss_const_reverse_iterator_type
msevector< _Ty, _A > _Myt
Definition: msemsevector.h:153
cipointer ciend() const
ss_const_reverse_iterator_type ss_rend() const
void insert_before_inclusive(const mm_const_iterator_type &pos, const _Iter &first, const _Iter &last)
ss_iterator_type insert_before(const ss_const_iterator_type &pos, ::std::initializer_list< typename base_class::value_type > _Ilist)
std::reverse_iterator< ss_iterator_type > ss_reverse_iterator_type
cipointer cibegin() const
_Myt & operator=(const _Myt &_X)
Definition: msemsevector.h:205
void insert_before(const mm_const_iterator_type &pos, size_type _M, const _Ty &_X)
void assign_inclusive(const ss_const_iterator_type &first, const ss_const_iterator_type &last)
msevector(const _Myt &_X)
Definition: msemsevector.h:180
ipointer erase(const cipointer &start, const cipointer &end)
ss_iterator_type insert_before(const ss_const_iterator_type &pos, size_type _M, const _Ty &_X)
base_class::value_type value_type
Definition: msemsevector.h:155
ss_const_iterator_type ss_cbegin() const
void insert_before(const mm_const_iterator_type &pos, ::std::initializer_list< typename base_class::value_type > _Ilist)
msevector(_Iter _First, _Iter _Last)
Definition: msemsevector.h:188
msevector(_Iter _First, _Iter _Last, const _A &_Al)
Definition: msemsevector.h:193
void assign(_It _F, _It _L)
Definition: msemsevector.h:335
ss_iterator_type insert_before(const ss_const_iterator_type &pos, const _Ty &_X=_Ty())
ss_reverse_iterator_type ss_rbegin()
ipointer insert_before(const cipointer &pos, const _Iter &start, const _Iter &end)
ipointer emplace(const cipointer &pos, _Valty &&..._Val)
std::size_t CHashKey1
ipointer insert(const cipointer &pos, const _Iter &start, const _Iter &end)
void push_back(const _Ty &_X)
Definition: msemsevector.h:293
void assign(const ss_const_iterator_type &start, const ss_const_iterator_type &end)
ss_iterator_type ss_end()
_Myt & operator=(const base_class &_X)
Definition: msemsevector.h:194
ipointer insert_before(const cipointer &pos, _Ty &&_X)
void release_all_const_item_pointers() const
ipointer insert(const cipointer &pos, const _Ty &_X=_Ty())
void assign(_Iter _First, _Iter _Last)
Definition: msemsevector.h:341
base_class::iterator emplace(typename base_class::const_iterator _Where, _Valty &&..._Val)
Definition: msemsevector.h:527
ss_const_iterator_type ss_begin() const
msevector(const base_class &_X)
Definition: msemsevector.h:178
void insert_before(msev_size_t pos, size_t _M, const _Ty &_X)
base_class::const_reference back() const
Definition: msemsevector.h:269
ss_iterator_type insert(const ss_const_iterator_type &pos, const _Ty &_X=_Ty())
ipointer insert_before(const cipointer &pos, const _Ty &_X=_Ty())
void erase_inclusive(const mm_const_iterator_type &first, const mm_const_iterator_type &last)
void assign(const cipointer &start, const cipointer &end)
base_class::pointer pointer
Definition: msemsevector.h:160
msevector(const _Ty *_F, const _Ty *_L, const _A &_Al=_A())
Definition: msemsevector.h:184
msev_size_t size_type
Definition: msemsevector.h:157
void insert_before(msev_size_t pos, _Ty &&_X)
ipointer erase_inclusive(const cipointer &first, const cipointer &last)
msevector(size_type _N, const _Ty &_V, const _A &_Al=_A())
Definition: msemsevector.h:173
ss_iterator_type insert(const ss_const_iterator_type &pos, ::std::initializer_list< typename base_class::value_type > _Ilist)
ss_iterator_type erase(const ss_const_iterator_type &start, const ss_const_iterator_type &end)
void release_all_item_pointers() const
ss_const_reverse_iterator_type ss_crbegin() const
base_class::reference front()
Definition: msemsevector.h:257
base_class::reference back()
Definition: msemsevector.h:265
_Myt & operator=(::std::initializer_list< typename base_class::value_type > _Ilist)
Definition: msemsevector.h:657
void erase(const mm_const_iterator_type &pos)
msevector(_Myt &&_X)
Definition: msemsevector.h:179
ss_iterator_type ss_begin()
_Myt & operator=(_Myt &&_X)
Definition: msemsevector.h:200
ss_iterator_type insert(const ss_const_iterator_type &pos, size_type _M, const _Ty &_X)
ipointer iend()
base_class::iterator erase(typename base_class::const_iterator _P)
Definition: msemsevector.h:567
ss_iterator_type insert_before(const ss_const_iterator_type &pos, _Ty &&_X)
void insert_before(const mm_const_iterator_type &pos, const _Ty &_X=_Ty())
void emplace(const mm_const_iterator_type &pos, _Valty &&..._Val)
ss_iterator_type insert_before_inclusive(const ss_iterator_type &pos, const _Iter &first, const _Iter &last)
mm_iterator_type & item_pointer(mm_iterator_handle_type handle)
void assign(const mm_const_iterator_type &start, const mm_const_iterator_type &end)
msevector(::std::initializer_list< typename base_class::value_type > _Ilist, const _A &_Al=_A())
Definition: msemsevector.h:652
base_class::iterator insert(typename base_class::const_iterator _Where, ::std::initializer_list< typename base_class::value_type > _Ilist)
Definition: msemsevector.h:692
ipointer insert(const cipointer &pos, _Ty &&_X)
base_class::iterator insert(typename base_class::const_iterator _P, size_type _M, const _Ty &_X)
Definition: msemsevector.h:384
mm_const_iterator_type & const_item_pointer(mm_const_iterator_handle_type handle) const
cipointer iend() const
ipointer insert_before_inclusive(const cipointer &pos, const _Iter &first, const _Iter &last)
ss_iterator_type insert(const ss_const_iterator_type &pos, const _Iter &start, const _Iter &end)
base_class::iterator erase(typename base_class::const_iterator _F, typename base_class::const_iterator _L)
Definition: msemsevector.h:599
ipointer insert_before(const cipointer &pos, ::std::initializer_list< typename base_class::value_type > _Ilist)
void assign(::std::initializer_list< typename base_class::value_type > _Ilist)
Definition: msemsevector.h:662
ss_reverse_iterator_type ss_rend()
mm_iterator_set_type m_mmitset
mm_iterator_handle_type allocate_new_item_pointer() const
void assign_inclusive(const cipointer &first, const cipointer &last)
void shrink_to_fit()
Definition: msemsevector.h:222
base_class::const_reference const_reference
Definition: msemsevector.h:163
base_class::reference reference
Definition: msemsevector.h:162
void release_const_item_pointer(mm_const_iterator_handle_type handle) const
void erase_previous_item(const ss_const_iterator_type &pos)
base_class::iterator insert(typename base_class::const_iterator _Where, _Iter _First, _Iter _Last)
Definition: msemsevector.h:415
ss_const_iterator_type ss_end() const
void swap(_Myt &_X)
Definition: msemsevector.h:647
ipointer erase_previous_item(const cipointer &pos)
ss_iterator_type erase_inclusive(const ss_const_iterator_type &first, const ss_const_iterator_type &last)
void erase_previous_item(const mm_const_iterator_type &pos)
ss_const_iterator_type ss_cend() const
#define nullptr
Definition: localconsts.h:45
#define MSE_THROW(x)
Definition: msemsevector.h:44
#define MSE_MSEVECTOR_BASE_INTEGER_TYPE
Definition: msemsevector.h:56
#define _XSTD
Definition: msemsevector.h:114
bool move(InputEvent &event)
Definition: commands.cpp:44
int size()
Definition: emotedb.cpp:306
void clear()
Definition: playerinfo.cpp:452
size_t msev_as_a_size_t
Definition: msemsevector.h:64
typename std::enable_if< std::is_convertible< typename std::iterator_traits< _InIter >::iterator_category, std::input_iterator_tag >::value >::type _mse_RequireInputIter
Definition: msemsevector.h:140
long int msev_int
Definition: msemsevector.h:62
size_t msev_size_t
Definition: msemsevector.h:61
bool msev_bool
Definition: msemsevector.h:63
static const _Ty value
Definition: msemsevector.h:120
integral_constant< _Ty, _Val > type
Definition: msemsevector.h:123