DeSiGNAR  0.5a
Data Structures General Library
array.H
Go to the documentation of this file.
1 /*
2  This file is part of Designar.
3  Copyright (C) 2017 by Alejandro J. Mujica
4 
5  This program is free software: you can redistribute it and/or modify
6  it under the terms of the GNU General Public License as published by
7  the Free Software Foundation, either version 3 of the License, or
8  (at your option) any later version.
9 
10  This program is distributed in the hope that it will be useful,
11  but WITHOUT ANY WARRANTY; without even the implied warranty of
12  MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
13  GNU General Public License for more details.
14 
15  You should have received a copy of the GNU General Public License
16  along with this program. If not, see <http://www.gnu.org/licenses/>.
17 
18  Any user request of this software, write to
19 
20  Alejandro Mujica
21 
22  aledrums@gmail.com
23 */
24 
25 # ifndef DSGARRAY_H
26 # define DSGARRAY_H
27 
28 # include <setalgorithms.H>
29 # include <containeralgorithms.H>
30 # include <iterator.H>
31 
32 namespace Designar
33 {
34  template <class Derived, class ArrayType, typename T, bool RET_CPY>
35  class ArrayIterator : public RandomAccessIterator<Derived, T, RET_CPY>
36  {
37  friend class BasicIterator<Derived, T, RET_CPY>;
38  friend class RandomAccessIterator<Derived, T, RET_CPY>;
39 
40  protected:
41  ArrayType * array_ptr;
43 
45  {
46  return curr;
47  }
48 
49  public:
51  : array_ptr(nullptr), curr(0)
52  {
53  // empty
54  }
55 
56  ArrayIterator(const ArrayType & a)
57  : array_ptr(&const_cast<ArrayType &>(a)), curr(0)
58  {
59  // empty
60  }
61 
62  ArrayIterator(const ArrayType & a, nat_t c)
63  : array_ptr(&const_cast<ArrayType &>(a)), curr(c)
64  {
65  // empty
66  }
67 
69  : array_ptr(it.array_ptr), curr(it.curr)
70  {
71  // empty
72  }
73 
75  : ArrayIterator()
76  {
77  swap(it);
78  }
79 
81  {
82  if (this == &it)
83  return *this;
84 
85  array_ptr = it.array_ptr;
86  curr = it.curr;
87  return *this;
88  }
89 
91  {
92  swap(it);
93  return *this;
94  }
95 
96  void swap(ArrayIterator & it)
97  {
98  std::swap(array_ptr, it.array_ptr);
99  std::swap(curr, it.curr);
100  }
101 
102  bool has_current() const
103  {
104  return curr < array_ptr->size();
105  }
106 
107  void next()
108  {
109  if (not has_current())
110  return;
111 
112  ++curr;
113  }
114 
115  void next_n(nat_t p)
116  {
117  curr = std::min(curr + p, array_ptr->size());
118  }
119 
120  void prev()
121  {
122  if (curr == 0)
123  return;
124 
125  --curr;
126  }
127 
128  void prev_n(nat_t p)
129  {
130  if (p > curr)
131  {
132  curr = 0;
133  return;
134  }
135 
136  curr -= p;
137  }
138 
139  void move_to(nat_t p)
140  {
141  curr = std::min(p, array_ptr->size());
142  }
143 
144  void reset()
145  {
146  curr = 0;
147  }
148 
150  {
151  return curr;
152  }
153  };
154 
155  template <class ArrayType, typename T>
156  class TArrayIterator : public ArrayIterator<TArrayIterator<ArrayType, T>,
157  ArrayType, T, false>
158  {
160  ArrayType, T, false>;
161  using Base::Base;
162 
163  public:
165  {
166  if (not Base::has_current())
167  throw std::overflow_error("There is not current element");
168 
169  return (*Base::array_ptr)[Base::curr];
170  }
171 
172  const T & get_current() const
173  {
174  if (not Base::has_current())
175  throw std::overflow_error("There is not current element");
176 
177  return (*Base::array_ptr)[Base::curr];
178  }
179  };
180 
181  template <typename T>
183  {
184  nat_t cap;
185  T * array_ptr;
186 
187  void init(const T &);
188 
189  void copy(const FixedArray &);
190 
191  public:
192  using ItemType = T;
193  using KeyType = T;
194  using DataType = T;
195  using ValueType = T;
196  using SizeType = nat_t;
197 
198  nat_t item_to_pos(T & item)
199  {
200  return nat_t(&item) - nat_t(array_ptr);
201  }
202 
204  : cap(0), array_ptr(nullptr)
205  {
206  // empty
207  }
208 
210  : cap(c), array_ptr(new T[cap])
211  {
212  // empty
213  }
214 
215  FixedArray(nat_t c, const T & init_value)
216  : FixedArray(c)
217  {
218  init(init_value);
219  }
220 
222  : FixedArray(a.cap)
223  {
224  copy(a);
225  }
226 
228  : FixedArray()
229  {
230  swap(a);
231  }
232 
233  FixedArray(const std::initializer_list<T> &);
234 
236  {
237  delete [] array_ptr;
238  }
239 
241  {
242  if (this == &a)
243  return *this;
244 
245  delete []array_ptr;
246  cap = a.cap;
247  array_ptr = new T[cap];
248  copy(a);
249  return *this;
250  }
251 
253  {
254  swap(a);
255  return *this;
256  }
257 
258  void swap(FixedArray & a)
259  {
260  std::swap(cap, a.cap);
261  std::swap(array_ptr, a.array_ptr);
262  }
263 
264  void resize(nat_t);
265 
267  {
268  return cap;
269  }
270 
271  nat_t size() const
272  {
273  return get_capacity();
274  }
275 
276  T & at(nat_t i)
277  {
278  if (i >= cap)
279  throw std::out_of_range("Index out of range");
280 
281  return array_ptr[i];
282  }
283 
284  const T & at(nat_t i) const
285  {
286  if (i >= cap)
287  throw std::out_of_range("Index out of range");
288 
289  return array_ptr[i];
290  }
291 
293  {
294  return at(i);
295  }
296 
297  const T & operator [] (nat_t i) const
298  {
299  return at(i);
300  }
301 
302  class Iterator : public TArrayIterator<FixedArray, T>
303  {
305  using Base::Base;
306  };
307 
308  Iterator begin()
309  {
310  return Iterator(*this);
311  }
312 
313  Iterator begin() const
314  {
315  return Iterator(*this);
316  }
317 
318  Iterator end()
319  {
320  return Iterator(*this, cap);
321  }
322 
323  Iterator end() const
324  {
325  return Iterator(*this, cap);
326  }
327  };
328 
329  template <typename T>
330  void FixedArray<T>::init(const T & init_value)
331  {
332  for (nat_t i = 0; i < cap; ++i)
333  array_ptr[i] = init_value;
334  }
335 
336  template <typename T>
337  void FixedArray<T>::copy(const FixedArray & a)
338  {
340  memcpy(array_ptr, a.array_ptr, sizeof(T) * cap);
341  else
342  for (nat_t i = 0; i < cap; ++i)
343  array_ptr[i] = a.array_ptr[i];
344  }
345 
346  template <typename T>
348  {
349  if (c == cap)
350  return;
351 
352  T * new_array_ptr = new T[c];
353 
354  nat_t sz = std::min(c, cap);
355 
356  for (nat_t i = 0; i < sz; ++i)
357  new_array_ptr[i] = array_ptr[i];
358 
359  delete [] array_ptr;
360  cap = c;
361  array_ptr = new_array_ptr;
362  }
363 
364  template <typename T>
365  FixedArray<T>::FixedArray(const std::initializer_list<T> & l)
366  : FixedArray(l.size())
367  {
368  nat_t i = 0;
369 
370  for (const T & item : l)
371  array_ptr[i++] = item;
372  }
373 
374  template <typename T>
375  class DynArray : private FixedArray<T>,
376  public ContainerAlgorithms<DynArray<T>, T>
377  {
378  using BaseArray = FixedArray<T>;
379 
380  public:
381  using ItemType = T;
382  using KeyType = T;
383  using DataType = T;
384  using ValueType = T;
385  using SizeType = nat_t;
386 
387  private:
388  static constexpr nat_t MIN_SIZE = 32;
389  static constexpr real_t RESIZE_FACTOR = 0.4;
390 
391  nat_t num_items;
392 
393  void copy_array(const DynArray &);
394 
395  void resize_up()
396  {
397  if (num_items < BaseArray::get_capacity())
398  return;
399 
400  assert(BaseArray::get_capacity() * (1 + RESIZE_FACTOR) > num_items);
401 
402  BaseArray::resize(BaseArray::get_capacity() * (1 + RESIZE_FACTOR));
403  }
404 
405  void resize_down()
406  {
407  if (num_items > BaseArray::get_capacity() * RESIZE_FACTOR or
408  BaseArray::get_capacity() == MIN_SIZE)
409  return;
410 
411  assert(BaseArray::get_capacity() * (1 - RESIZE_FACTOR) > num_items);
412 
413  nat_t new_cap = std::max<real_t>(BaseArray::get_capacity() *
414  (1 - RESIZE_FACTOR), MIN_SIZE);
415 
416  BaseArray::resize(new_cap);
417  }
418 
419  void open_breach(nat_t);
420 
421  void close_breach(nat_t);
422 
423  public:
425  : BaseArray(cap), num_items(0)
426  {
427  // empty
428  }
429 
430  DynArray(nat_t cap, const T & init_val)
431  : BaseArray(cap, init_val), num_items(cap)
432  {
433  // empty
434  }
435 
437  : DynArray(MIN_SIZE)
438  {
439  // empty
440  }
441 
442  DynArray(const DynArray & a)
443  : BaseArray(a.get_capacity()), num_items(a.num_items)
444  {
445  copy_array(a);
446  }
447 
449  : BaseArray(), num_items(0)
450  {
451  swap(a);
452  }
453 
454  DynArray(const std::initializer_list<T> &);
455 
456  void swap(DynArray & a)
457  {
458  BaseArray::swap(a);
459  std::swap(num_items, a.num_items);
460  }
461 
463  {
464  return BaseArray::get_capacity();
465  }
466 
467  nat_t size() const
468  {
469  return num_items;
470  }
471 
472  bool is_empty() const
473  {
474  return num_items == 0;
475  }
476 
477  void clear()
478  {
479  num_items = 0;
480 
481  if (BaseArray::get_capacity() != MIN_SIZE)
482  {
483  DynArray new_array(MIN_SIZE);
484  BaseArray::swap(new_array);
485  }
486  }
487 
488  T & get_first()
489  {
490  if (num_items == 0)
491  throw std::underflow_error("Array is empty");
492 
493  return BaseArray::at(0);
494  }
495 
496  const T & get_first() const
497  {
498  if (num_items == 0)
499  throw std::underflow_error("Array is empty");
500 
501  return BaseArray::at(0);
502  }
503 
504  T & get_last()
505  {
506  if (num_items == 0)
507  throw std::overflow_error("Array is empty");
508 
509  return BaseArray::at(num_items - 1);
510  }
511 
512  const T & get_last() const
513  {
514  if (num_items == 0)
515  throw std::overflow_error("Array is empty");
516 
517  return BaseArray::at(num_items - 1);
518  }
519 
520  T & insert(nat_t pos, const T & item)
521  {
522  if (pos > num_items)
523  throw std::out_of_range("Index is out of range");
524 
525  open_breach(pos);
526 
527  BaseArray::at(pos) = item;
528 
529  ++num_items;
530 
531  resize_up();
532 
533  return BaseArray::at(pos);
534  }
535 
536  T & insert(nat_t pos, T && item)
537  {
538  if (pos > num_items)
539  throw std::out_of_range("Index is out of range");
540 
541  open_breach(pos);
542 
543  BaseArray::at(pos) = std::move(item);
544 
545  ++num_items;
546 
547  resize_up();
548 
549  return BaseArray::at(pos);
550  }
551 
552  T & insert(const T & item)
553  {
554  return insert(0, item);
555  }
556 
557  T & insert(T && item)
558  {
559  return insert(0, std::forward<T>(item));
560  }
561 
562  T & append(const T & item)
563  {
564  BaseArray::at(num_items++) = item;
565  resize_up();
566  return BaseArray::at(num_items - 1);
567  }
568 
569  T & append(T && item)
570  {
571  BaseArray::at(num_items++) = std::move(item);
572  resize_up();
573  return BaseArray::at(num_items - 1);
574  }
575 
577  {
578  if (pos >= num_items)
579  throw std::out_of_range("Index is out of range");
580 
581  T ret_val = std::move(BaseArray::at(pos));
582  BaseArray::at(pos) = std::move(BaseArray::at(--num_items));
583  return ret_val;
584  }
585 
586  T remove(T & item)
587  {
588  nat_t i = BaseArray::item_to_pos(item);
589 
590  if (i >= num_items)
591  throw std::logic_error("Item does not belong to array");
592 
593  return remove_pos(i);
594  }
595 
597  {
598  if (pos >= num_items)
599  throw std::out_of_range("Index is out of range");
600 
601  T ret_val = std::move(BaseArray::at(pos));
602 
603  --num_items;
604 
605  close_breach(pos);
606 
607  resize_down();
608 
609  return ret_val;;
610  }
611 
613  {
614  nat_t i = BaseArray::item_to_pos(item);
615 
616  if (i >= num_items)
617  throw std::logic_error("Item does not belong to array");
618 
619  return remove_pos_closing_breach(i);
620  }
621 
623  {
624  if (num_items == 0)
625  throw std::underflow_error("Array is empty");
626 
627  return remove_pos(0);
628  }
629 
631  {
632  T ret_val = std::move(BaseArray::at(--num_items));
633  resize_down();
634  return ret_val;
635  }
636 
638  {
639  if (this == &a)
640  return *this;
641 
642  (BaseArray &) *this = a;
643  num_items = a.num_items;
644  return *this;
645  }
646 
648  {
649  swap(a);
650  return *this;
651  }
652 
653  T & at(nat_t i)
654  {
655  if (i >= num_items)
656  throw std::out_of_range("Index is out of range");
657 
658  return BaseArray::at(i);
659  }
660 
661  const T & at(nat_t i) const
662  {
663  if (i >= num_items)
664  throw std::out_of_range("Index is out of range");
665 
666  return BaseArray::at(i);
667  }
668 
670  {
671  return at(i);
672  }
673 
674  const T & operator [] (nat_t i) const
675  {
676  return at(i);
677  }
678 
679  class Iterator : public TArrayIterator<DynArray, T>
680  {
682  using Base::Base;
683 
684  public:
685  T del()
686  {
687  if (not Base::has_current())
688  throw std::logic_error("There is not current element");
689 
690  return Base::array_ptr->remove_pos_closing_breach(Base::curr);
691  }
692  };
693 
695  {
696  return Iterator(*this);
697  }
698 
699  Iterator begin() const
700  {
701  return Iterator(*this);
702  }
703 
705  {
706  return Iterator(*this, num_items);
707  }
708 
709  Iterator end() const
710  {
711  return Iterator(*this, num_items);
712  }
713  };
714 
715  template <typename T>
716  DynArray<T>::DynArray(const std::initializer_list<T> & l)
717  : DynArray(l.size())
718  {
719  for (const T & item : l)
720  append(item);
721  }
722 
723  template <typename T>
724  void DynArray<T>::copy_array(const DynArray & a)
725  {
726  for (nat_t i = 0; i < num_items; ++i)
727  BaseArray::at(i) = a.at(i);
728  }
729 
730  template <typename T>
732  {
733  for (nat_t i = num_items; i > p; --i)
734  BaseArray::at(i) = std::move(BaseArray::at(i - 1));
735  }
736 
737  template <typename T>
739  {
740  for (nat_t i = p; i < num_items; ++i)
741  BaseArray::at(i) = std::move(BaseArray::at(i + 1));
742  }
743 
744  template <typename T, nat_t N = 2>
746  {
747  static_assert(N >= 2, "N must be greater than 1");
748 
749  class Slice
750  {
751  nat_t sz; // size of linear array
752  FixedArray<nat_t> exts; // extents
753  FixedArray<nat_t> strs; // strides
754 
755  void init();
756 
757  void swap(Slice & another)
758  {
759  std::swap(sz, another.sz);
760  std::swap(exts, another.exts);
761  std::swap(strs, another.strs);
762  }
763 
764  public:
765  Slice()
766  : sz(1), exts(N), strs(N)
767  {
768  init();
769  };
770 
771  Slice(const Slice & slice)
772  : sz(slice.sz), exts(slice.exts), strs(slice.strs)
773  {
774  // empty
775  }
776 
777  Slice(Slice && slice)
778  : Slice()
779  {
780  swap(slice);
781  }
782 
783  Slice(const std::initializer_list<nat_t> & l)
784  : sz(1), exts(l), strs(l.size())
785  {
786  init();
787  }
788 
789  template <typename... Dims>
790  Slice(Dims... dims)
791  : sz(1), exts({nat_t(dims)...}), strs(sizeof...(Dims))
792  {
793  static_assert(sizeof...(Dims) == N, "");
794  static_assert(AllAreConvertible<nat_t, Dims...>::value, "");
795  init();
796  }
797 
798  const FixedArray<nat_t> & extents() const
799  {
800  return exts;
801  }
802 
803  const FixedArray<nat_t> & strides() const
804  {
805  return strs;
806  }
807 
808  nat_t size() const
809  {
810  return sz;
811  }
812 
813  template <typename... Dims>
814  nat_t operator () (Dims...);
815 
816  Slice & operator = (const Slice & slice)
817  {
818  if (&slice == this)
819  return *this;
820 
821  sz = slice.sz;
822  exts = slice.exts;
823  strs = slice.strs;
824 
825  return *this;
826  }
827 
828  Slice & operator = (Slice && slice)
829  {
830  swap(slice);
831  return *this;
832  }
833  };
834 
835  public:
836  using ItemType = T;
837  using KeyType = T;
838  using DataType = T;
839  using ValueType = T;
840  using SizeType = nat_t;
841 
842  private:
843  Slice slice;
844  FixedArray<T> array;
845 
846  void swap(MultiDimArray & another)
847  {
848  std::swap(slice, another.slice);
849  std::swap(array, another.array);
850  }
851 
852  public:
853  MultiDimArray() = default;
854 
855  template <typename... Dims>
856  MultiDimArray(Dims... dims)
857  : slice(dims...), array(slice.size())
858  {
859  // empty
860  }
861 
863  : slice(mda.slice), array(mda.array)
864  {
865  // empty
866  }
867 
869  : MultiDimArray()
870  {
871  swap(mda);
872  }
873 
874  nat_t size(nat_t i) const
875  {
876  return slice.extents()[i];
877  }
878 
879  template <typename... Dims>
880  T & get(Dims... dims)
881  {
882  nat_t idx = slice(dims...);
883  if (idx >= slice.size())
884  throw std::overflow_error("Invalid position");
885  return array[idx];
886  }
887 
888  template <typename... Dims>
889  const T & get(Dims... dims) const
890  {
891  nat_t idx = slice(dims...);
892  if (idx >= slice.size())
893  throw std::overflow_error("Invalid position");
894  return array[idx];
895  }
896 
897  template <typename... Dims>
898  T & at(Dims... dims)
899  {
900  return get(dims...);
901  }
902 
903  template <typename... Dims>
904  const T & at(Dims... dims) const
905  {
906  return get(dims...);
907  }
908 
909  template <typename... Dims>
910  T & operator () (Dims... dims)
911  {
912  return get(dims...);
913  }
914 
915  template <typename... Dims>
916  const T & operator () (Dims... dims) const
917  {
918  return get(dims...);
919  }
920 
922  {
923  if (&mda == this)
924  return *this;
925 
926  slice = mda.slice;
927  array = mda.array;
928 
929  return *this;
930  }
931 
933  {
934  swap(mda);
935  return *this;
936  }
937 
938  class Iterator : public FixedArray<T>::Iterator
939  {
940  using Base = typename FixedArray<T>::Iterator;
941 
942  public:
944  : Base()
945  {
946  // empty
947  }
948 
950  : Base(a.array)
951  {
952  // empty
953  }
954 
956  : Base(a.array, c)
957  {
958  // empty
959  }
960 
961  Iterator(const Iterator & itor)
962  : Base(itor)
963  {
964  // empty
965  }
966 
968  : Iterator()
969  {
970  Base::swap(itor);
971  }
972  };
973 
975  {
976  return Iterator(*this);
977  }
978 
979  Iterator begin() const
980  {
981  return Iterator(*this);
982  }
983 
985  {
986  return Iterator(*this, slice.size());
987  }
988 
989  Iterator end() const
990  {
991  return Iterator(*this, slice.size());
992  }
993  };
994 
995  template <typename T, nat_t N>
997  {
998  for (nat_t i = 0; i < N; ++i)
999  sz *= exts[i];
1000 
1001  strs[N - 1] = 1;
1002 
1003  for (nat_t i = N - 1; i > 0; --i)
1004  strs[i - 1] = strs[i] * exts[i];
1005  }
1006 
1007  template <typename T, nat_t N>
1008  template <typename... Dims>
1010  {
1011  static_assert(sizeof...(Dims) == N, "");
1012  static_assert(AllAreConvertible<nat_t, Dims...>::value, "");
1013  FixedArray<nat_t> arr{nat_t(dims)...};
1014 
1015  nat_t ret = 0;
1016 
1017  for (size_t i = 0; i < N; ++i)
1018  ret += arr[i] * strs[i];
1019 
1020  return ret;
1021  }
1022 } // end namespace Designar
1023 
1024 # endif // DSGARRAY_H
Definition: array.H:302
T & at(Dims...dims)
Definition: array.H:898
const T & get_first() const
Definition: array.H:496
T ItemType
Definition: array.H:836
Iterator end()
Definition: array.H:704
void resize(nat_t)
Definition: array.H:347
T & get_current()
Definition: array.H:164
ArrayIterator()
Definition: array.H:50
T remove_pos_closing_breach(nat_t pos)
Definition: array.H:596
T DataType
Definition: array.H:194
nat_t size(nat_t i) const
Definition: array.H:874
T & append(T &&item)
Definition: array.H:569
T remove_last()
Definition: array.H:630
void reset()
Definition: array.H:144
FixedArray(nat_t c)
Definition: array.H:209
Iterator begin() const
Definition: array.H:699
const T & get_current() const
Definition: array.H:172
MultiDimArray(Dims...dims)
Definition: array.H:856
const T & get_last() const
Definition: array.H:512
T KeyType
Definition: array.H:837
Definition: iterator.H:132
DynArray(const DynArray &a)
Definition: array.H:442
Iterator end() const
Definition: array.H:709
double real_t
Definition: types.H:51
Iterator end()
Definition: array.H:318
ArrayIterator(const ArrayType &a, nat_t c)
Definition: array.H:62
T & insert(const T &item)
Definition: array.H:552
nat_t size() const
Definition: array.H:271
MultiDimArray(const MultiDimArray &mda)
Definition: array.H:862
T & insert(T &&item)
Definition: array.H:557
nat_t get_location() const
Definition: array.H:44
Definition: iterator.H:36
MultiDimArray(MultiDimArray &&mda)
Definition: array.H:868
T & insert(nat_t pos, const T &item)
Definition: array.H:520
T & get_first()
Definition: array.H:488
ArrayType * array_ptr
Definition: array.H:41
const T & at(nat_t i) const
Definition: array.H:661
nat_t size() const
Definition: array.H:467
nat_t get_capacity() const
Definition: array.H:462
Iterator end() const
Definition: array.H:989
T remove_closing_breach(T &item)
Definition: array.H:612
T & get_last()
Definition: array.H:504
T & at(nat_t i)
Definition: array.H:653
ArrayIterator(const ArrayIterator &it)
Definition: array.H:68
ArrayIterator(ArrayIterator &&it)
Definition: array.H:74
void swap(ArrayIterator &it)
Definition: array.H:96
T & append(const T &item)
Definition: array.H:562
ArrayIterator(const ArrayType &a)
Definition: array.H:56
T DataType
Definition: array.H:838
T remove_pos(nat_t pos)
Definition: array.H:576
void clear()
Definition: array.H:477
~FixedArray()
Definition: array.H:235
DynArray(DynArray &&a)
Definition: array.H:448
Iterator(const Iterator &itor)
Definition: array.H:961
void swap(FixedArray &a)
Definition: array.H:258
Iterator(const MultiDimArray &a)
Definition: array.H:949
DynArray & operator=(const DynArray &a)
Definition: array.H:637
void swap(DynArray &a)
Definition: array.H:456
bool has_current() const
Definition: array.H:102
Definition: array.H:375
T ItemType
Definition: array.H:192
Iterator(const MultiDimArray &a, nat_t c)
Definition: array.H:955
Iterator begin()
Definition: array.H:694
Iterator begin() const
Definition: array.H:979
FixedArray(nat_t c, const T &init_value)
Definition: array.H:215
T & insert(nat_t pos, T &&item)
Definition: array.H:536
nat_t item_to_pos(T &item)
Definition: array.H:198
Iterator end()
Definition: array.H:984
nat_t curr
Definition: array.H:42
T ValueType
Definition: array.H:839
Definition: containeralgorithms.H:33
bool is_empty() const
Definition: array.H:472
Iterator()
Definition: array.H:943
Iterator begin() const
Definition: array.H:313
DynArray(nat_t cap, const T &init_val)
Definition: array.H:430
RetType< RET_CPY, T, T & > operator[](nat_t i)
Definition: iterator.H:137
FixedArray(const FixedArray &a)
Definition: array.H:221
Iterator begin()
Definition: array.H:308
ArrayIterator & operator=(const ArrayIterator &it)
Definition: array.H:80
Definition: array.H:182
FixedArray()
Definition: array.H:203
T del()
Definition: array.H:685
T & operator[](nat_t i)
Definition: array.H:292
nat_t SizeType
Definition: array.H:840
Definition: array.H:938
Definition: array.H:32
nat_t get_capacity() const
Definition: array.H:266
FixedArray & operator=(const FixedArray &a)
Definition: array.H:240
T ValueType
Definition: array.H:195
Definition: array.H:745
unsigned long int nat_t
Definition: types.H:50
DynArray()
Definition: array.H:436
void prev()
Definition: array.H:120
Iterator begin()
Definition: array.H:974
void next()
Definition: array.H:107
DynArray(nat_t cap)
Definition: array.H:424
Value & value(MapKey< Key, Value > &item)
Definition: map.H:77
nat_t get_position() const
Definition: array.H:149
Definition: array.H:679
T remove_first()
Definition: array.H:622
Definition: typetraits.H:34
Iterator(Iterator &&itor)
Definition: array.H:967
void prev_n(nat_t p)
Definition: array.H:128
Iterator end() const
Definition: array.H:323
FixedArray(FixedArray &&a)
Definition: array.H:227
Definition: array.H:35
void next_n(nat_t p)
Definition: array.H:115
void move_to(nat_t p)
Definition: array.H:139
Definition: array.H:156
T KeyType
Definition: array.H:193
T & at(nat_t i)
Definition: array.H:276
const T & at(nat_t i) const
Definition: array.H:284
const T & at(Dims...dims) const
Definition: array.H:904