Open
Graph Drawing
Framework

 v. 2023.09 (Elderberry)
 

Loading...
Searching...
No Matches
Array.h
Go to the documentation of this file.
1
33#pragma once
34
35#include <ogdf/basic/Reverse.h>
36#include <ogdf/basic/comparer.h>
38#include <ogdf/basic/memory.h>
39
40#include <random>
41#include <type_traits>
42
43namespace ogdf {
44
45template<class E, class INDEX>
46class ArrayBuffer;
47
48template<class E, bool isConst>
49class ArrayReverseIteratorBase;
50template<class E>
51using ArrayConstIterator = const E*;
52template<class E>
53using ArrayIterator = E*;
54template<class E>
56template<class E>
58
60
68template<class E, bool isConst>
70 friend class ArrayReverseIteratorBase<E, !isConst>;
71
73 using Elem = typename std::conditional<isConst, const E, E>::type;
74
77
78public:
81
85
88
93
98
100 operator std::conditional<isConst, const E, E>*() const { return m_pX; }
101
104 return m_pX == it.m_pX;
105 }
106
109 return m_pX != it.m_pX;
110 }
111
113 Elem& operator*() const { return *m_pX; }
114
120
123 m_pX--;
124 return *this;
125 }
126
133
136 m_pX++;
137 return *this;
138 }
139
146
149 m_pX -= rhs;
150 return *this;
151 }
152
155 m_pX += rhs;
156 return *this;
157 }
158
163
170
175
177 template<bool isArgConst>
179 return rhs.m_pX - m_pX;
180 }
181
184
187
190
193
195 Elem& operator[](std::size_t idx) { return m_pX[-idx]; }
196
198 const Elem& operator[](std::size_t idx) const { return m_pX[-idx]; }
199
201};
202
204
213template<class E, class INDEX = int>
214class Array {
215public:
218 static const int maxSizeInsertionSort = 40;
219
221 using value_type = E;
223 using reference = E&;
225 using const_reference = const E&;
234
236 Array() { construct(0, -1); }
237
239 explicit Array(INDEX s) : Array(0, s - 1) { }
240
243 construct(a, b);
244 initialize();
245 }
246
248 Array(INDEX a, INDEX b, const E& x) {
249 construct(a, b);
250 initialize(x);
251 }
252
254
257 Array(std::initializer_list<E> initList) {
258 construct(0, ((INDEX)initList.size()) - 1);
260 }
261
264
266
272 , m_pStop(A.m_pStop)
273 , m_low(A.m_low)
274 , m_high(A.m_high) {
275 A.construct(0, -1);
276 }
277
280
283
289
291 INDEX low() const { return m_low; }
292
294 INDEX high() const { return m_high; }
295
297 INDEX size() const { return m_high - m_low + 1; }
298
300 bool empty() const { return size() == 0; }
301
304 OGDF_ASSERT(m_low <= i);
305 OGDF_ASSERT(i <= m_high);
306 return m_vpStart[i];
307 }
308
311 OGDF_ASSERT(m_low <= i);
312 OGDF_ASSERT(i <= m_high);
313 return m_vpStart[i];
314 }
315
317
322
324 iterator begin() { return m_pStart; }
325
327 const_iterator begin() const { return m_pStart; }
328
330 const_iterator cbegin() const { return m_pStart; }
331
333 iterator end() { return m_pStop; }
334
336 const_iterator end() const { return m_pStop; }
337
339 const_iterator cend() const { return m_pStop; }
340
343
345 const_reverse_iterator rbegin() const { return m_pStop - 1; }
346
348 const_reverse_iterator crbegin() const { return m_pStop - 1; }
349
352
354 const_reverse_iterator rend() const { return m_pStart - 1; }
355
357 const_reverse_iterator crend() const { return m_pStart - 1; }
358
360
365
367 void init() {
368 deconstruct();
369 construct(0, -1);
370 }
371
373
376 void init(INDEX s) { init(0, s - 1); }
377
379
382 void init(INDEX a, INDEX b) {
383 deconstruct();
384 construct(a, b);
385 initialize();
386 }
387
389 void init(INDEX a, INDEX b, const E& x) {
390 deconstruct();
391 construct(a, b);
392 initialize(x);
393 }
394
396 void fill(const E& x) {
397 E* pDest = m_pStop;
398 while (pDest > m_pStart) {
399 *--pDest = x;
400 }
401 }
402
404 void fill(INDEX i, INDEX j, const E& x) {
405 OGDF_ASSERT(m_low <= i);
406 OGDF_ASSERT(i <= m_high);
407 OGDF_ASSERT(m_low <= j);
408 OGDF_ASSERT(j <= m_high);
409
410 E *pI = m_vpStart + i, *pJ = m_vpStart + j + 1;
411 while (pJ > pI) {
412 *--pJ = x;
413 }
414 }
415
417
422 void grow(INDEX add, const E& x);
423
425
429 void grow(INDEX add);
430
432
437 void resize(INDEX newSize, const E& x) { grow(newSize - size(), x); }
438
440
445
448 deconstruct();
449 copy(A);
450 return *this;
451 }
452
454
458 deconstruct();
459
460 m_vpStart = A.m_vpStart;
461 m_pStart = A.m_pStart;
462 m_pStop = A.m_pStop;
463 m_low = A.m_low;
464 m_high = A.m_high;
465
466 A.construct(0, -1);
467 return *this;
468 }
469
473
475 bool operator==(const Array<E, INDEX>& L) const {
476 if (size() != L.size()) {
477 return false;
478 }
479
480 auto thisIterator = begin();
481 auto thatIterator = L.begin();
482
483 while (thisIterator != end() && thatIterator != L.end()) {
484 if (*thisIterator != *thatIterator) {
485 return false;
486 }
487 ++thisIterator;
488 ++thatIterator;
489 }
490
491 OGDF_ASSERT(thisIterator == end() && thatIterator == L.end());
492 return true;
493 }
494
496 bool operator!=(const Array<E, INDEX>& L) const { return !operator==(L); }
497
499
504
506 void swap(INDEX i, INDEX j) {
507 OGDF_ASSERT(m_low <= i);
508 OGDF_ASSERT(i <= m_high);
509 OGDF_ASSERT(m_low <= j);
510 OGDF_ASSERT(j <= m_high);
511
512 std::swap(m_vpStart[i], m_vpStart[j]);
513 }
514
517 std::minstd_rand rng(randomSeed());
518 permute(l, r, rng);
519 }
520
522 void permute() { permute(low(), high()); }
523
530 template<class RNG>
532
537 template<class RNG>
538 void permute(RNG& rng) {
539 if (!empty()) {
540 permute(low(), high(), rng);
541 }
542 }
543
545
550
552
556 inline int binarySearch(const E& e) const {
557 return binarySearch(low(), high(), e, StdComparer<E>());
558 }
559
561
565 inline int binarySearch(INDEX l, INDEX r, const E& e) const {
566 return binarySearch(l, r, e, StdComparer<E>());
567 }
568
570
574 template<class COMPARER>
575 inline int binarySearch(const E& e, const COMPARER& comp) const {
576 return binarySearch(low(), high(), e, comp);
577 }
578
580
584 template<class COMPARER>
585 INDEX binarySearch(INDEX l, INDEX r, const E& e, const COMPARER& comp) const {
586 if (r < l) {
587 return low() - 1;
588 }
589 while (r > l) {
590 INDEX m = (r + l) / 2;
591 if (comp.greater(e, m_vpStart[m])) {
592 l = m + 1;
593 } else {
594 r = m;
595 }
596 }
597 return comp.equal(e, m_vpStart[l]) ? l : low() - 1;
598 }
599
601
606 inline INDEX linearSearch(const E& e) const {
607 int i;
608 for (i = size(); i-- > 0;) {
609 if (e == m_pStart[i]) {
610 break;
611 }
612 }
613 return i + low();
614 }
615
617
622 template<class COMPARER>
623 INDEX linearSearch(const E& e, const COMPARER& comp) const {
624 int i;
625 for (i = size(); i-- > 0;) {
626 if (comp.equal(e, m_pStart[i])) {
627 break;
628 }
629 }
630 return i + low();
631 }
632
634 inline void quicksort() { quicksort(StdComparer<E>()); }
635
638
640
643 template<class COMPARER>
644 inline void quicksort(const COMPARER& comp) {
645 if (low() < high()) {
647 }
648 }
649
651
656 template<class COMPARER>
658 OGDF_ASSERT(low() <= l);
659 OGDF_ASSERT(l <= high());
660 OGDF_ASSERT(low() <= r);
661 OGDF_ASSERT(r <= high());
662 if (l < r) {
664 }
665 }
666
668
680
682
693 leftShift(ind);
694 fill(high() - ind.size(), high(), val);
695 }
696
698
699 template<class F, class I>
700 friend class ArrayBuffer; // for efficient ArrayBuffer::compact-method
701
702private:
708
711
714
716 void initialize(const E& x);
717
719 void initialize(std::initializer_list<E> initList);
720
723
725 void copy(const Array<E, INDEX>& A);
726
729
733 // If the element type is trivially copiable, just use realloc.
734 E* p = static_cast<E*>(realloc(m_pStart, sNew * sizeof(E)));
735 if (p == nullptr) {
737 }
738 m_pStart = p;
739 }
740
744 // If the element type is not trivially copiable,
745 // allocate a new block, move the elements, and free the old block.
746 E* p = static_cast<E*>(malloc(sNew * sizeof(E)));
747 if (p == nullptr) {
749 }
750
751 for (int i = 0; i < min(sOld, sNew); ++i) {
752 new (&p[i]) E(std::move(m_pStart[i]));
753 }
754
755 deconstruct();
756 m_pStart = p;
757 }
758
760 template<class COMPARER>
761 static void quicksortInt(E* pL, E* pR, const COMPARER& comp) {
762 size_t s = pR - pL;
763
764 // use insertion sort for small instances
765 if (s < maxSizeInsertionSort) {
766 for (E* pI = pL + 1; pI <= pR; pI++) {
767 E v = *pI;
768 E* pJ = pI;
769 while (--pJ >= pL && comp.less(v, *pJ)) {
770 *(pJ + 1) = *pJ;
771 }
772 *(pJ + 1) = v;
773 }
774 return;
775 }
776
777 E *pI = pL, *pJ = pR;
778 E x = *(pL + (s >> 1));
779
780 do {
781 while (comp.less(*pI, x)) {
782 pI++;
783 }
784 while (comp.less(x, *pJ)) {
785 pJ--;
786 }
787 if (pI <= pJ) {
788 std::swap(*pI++, *pJ--);
789 }
790 } while (pI <= pJ);
791
792 if (pL < pJ) {
794 }
795 if (pI < pR) {
797 }
798 }
799
801};
802
803// enlarges storage for array and moves old entries
804template<class E, class INDEX>
806 INDEX sOld = size(), sNew = sOld + add;
807
808 // expand allocated memory block
809 if (m_pStart != nullptr) {
810 expandArrayHelper(sOld, sNew);
811 } else {
812 m_pStart = static_cast<E*>(malloc(sNew * sizeof(E)));
813 if (m_pStart == nullptr) {
815 }
816 }
817
818 m_vpStart = m_pStart - m_low;
819 m_pStop = m_pStart + sNew;
820 m_high += add;
821}
822
823// enlarges array by add elements and sets new elements to x
824template<class E, class INDEX>
825void Array<E, INDEX>::grow(INDEX add, const E& x) {
826 if (add == 0) {
827 return;
828 }
829
830 INDEX sOld = size();
831 expandArray(add);
832
833 // initialize new array entries
834 for (E* pDest = m_pStart + sOld; pDest < m_pStop; pDest++) {
835 new (pDest) E(x);
836 }
837}
838
839// enlarges array by add elements (initialized with default constructor)
840template<class E, class INDEX>
842 if (add == 0) {
843 return;
844 }
845
846 INDEX sOld = size();
847 expandArray(add);
848
849 // initialize new array entries
850 for (E* pDest = m_pStart + sOld; pDest < m_pStop; pDest++) {
851 new (pDest) E;
852 }
853}
854
855template<class E, class INDEX>
857 m_low = a;
858 m_high = b;
859 INDEX s = b - a + 1;
860
861 if (s < 1) {
862 m_pStart = m_vpStart = m_pStop = nullptr;
863
864 } else {
865 m_pStart = static_cast<E*>(malloc(s * sizeof(E)));
866 if (m_pStart == nullptr) {
868 }
869
870 m_vpStart = m_pStart - a;
871 m_pStop = m_pStart + s;
872 }
873}
874
875template<class E, class INDEX>
877 E* pDest = m_pStart;
878 try {
879 for (; pDest < m_pStop; pDest++) {
880 new (pDest) E;
881 }
882 } catch (...) {
883 while (--pDest >= m_pStart) {
884 pDest->~E();
885 }
886 free(m_pStart);
887 throw;
888 }
889}
890
891template<class E, class INDEX>
893 E* pDest = m_pStart;
894 try {
895 for (; pDest < m_pStop; pDest++) {
896 new (pDest) E(x);
897 }
898 } catch (...) {
899 while (--pDest >= m_pStart) {
900 pDest->~E();
901 }
902 free(m_pStart);
903 throw;
904 }
905}
906
907template<class E, class INDEX>
908void Array<E, INDEX>::initialize(std::initializer_list<E> initList) {
909 E* pDest = m_pStart;
910 try {
911 for (const E& x : initList) {
912 new (pDest++) E(x);
913 }
914 } catch (...) {
915 while (--pDest >= m_pStart) {
916 pDest->~E();
917 }
918 free(m_pStart);
919 throw;
920 }
921}
922
923template<class E, class INDEX>
925 if (!std::is_trivially_destructible<E>::value) {
926 for (E* pDest = m_pStart; pDest < m_pStop; pDest++) {
927 pDest->~E();
928 }
929 }
930 free(m_pStart);
931}
932
933template<class E, class INDEX>
935 construct(array2.m_low, array2.m_high);
936
937 if (m_pStart != nullptr) {
938 E* pSrc = array2.m_pStop;
939 E* pDest = m_pStop;
940 while (pDest > m_pStart)
941#if 0
942 *--pDest = *--pSrc;
943#endif
944 new (--pDest) E(*--pSrc);
945 }
946}
947
948// permutes array a from a[l] to a[r] randomly
949template<class E, class INDEX>
950template<class RNG>
952 OGDF_ASSERT(low() <= l);
953 OGDF_ASSERT(l <= high());
954 OGDF_ASSERT(low() <= r);
955 OGDF_ASSERT(r <= high());
956
957 std::uniform_int_distribution<int> dist(0, r - l);
958
959 E *pI = m_vpStart + l, *pStart = m_vpStart + l, *pStop = m_vpStart + r;
960 while (pI <= pStop) {
961 std::swap(*pI++, *(pStart + dist(rng)));
962 }
963}
964
966template<class E, class INDEX>
967void print(std::ostream& os, const Array<E, INDEX>& a, char delim = ' ') {
968 for (int i = a.low(); i <= a.high(); i++) {
969 if (i > a.low()) {
970 os << delim;
971 }
972 os << a[i];
973 }
974}
975
977template<class E, class INDEX>
978std::ostream& operator<<(std::ostream& os, const ogdf::Array<E, INDEX>& a) {
979 print(os, a);
980 return os;
981}
982
983}
984
986
987namespace ogdf {
988
990template<class E, class INDEX>
992 const INDEX nInd = ind.size();
993 if (nInd == 0) {
994 return;
995 }
996
997 OGDF_ASSERT(ind[0] >= low());
998 OGDF_ASSERT(ind[0] <= high());
999
1000 INDEX j, current = ind[0];
1001 for (INDEX i = 0; i < nInd - 1; i++) {
1002 OGDF_ASSERT(ind[i + 1] >= low());
1003 OGDF_ASSERT(ind[i + 1] <= high());
1004
1005 const INDEX last = ind[i + 1];
1006 for (j = ind[i] + 1; j < last; j++) {
1007 m_vpStart[current++] = m_vpStart[j];
1008 }
1009 }
1010
1012 for (j = ind[nInd - 1] + 1; j < size(); j++) {
1013 m_vpStart[current++] = m_vpStart[j];
1014 }
1015}
1016
1017template<class E, class INDEX>
1019 construct(0, -1);
1020 A.compactCopy(*this);
1021}
1022
1023}
Declaration and implementation of ArrayBuffer class.
Implementation of the Reverse class for the reverse iteration of containers.
An array that keeps track of the number of inserted elements; also usable as an efficient stack.
Definition ArrayBuffer.h:56
The parameterized class Array implements dynamic arrays of type E.
Definition Array.h:214
iterator begin()
Returns an iterator to the first element.
Definition Array.h:324
const_reference operator[](INDEX i) const
Returns a reference to the element at position i.
Definition Array.h:303
void quicksort(const COMPARER &comp)
Sorts array using Quicksort and a user-defined comparer comp.
Definition Array.h:644
void resize(INDEX newSize, const E &x)
Resizes (enlarges or shrinks) the array to hold newSize elements and sets new elements to x.
Definition Array.h:437
reference operator[](INDEX i)
Returns a reference to the element at position i.
Definition Array.h:310
void grow(INDEX add, const E &x)
Enlarges the array by add elements and sets new elements to x.
Definition Array.h:825
void deconstruct()
Deallocates array.
Definition Array.h:924
void swap(INDEX i, INDEX j)
Swaps the elements at position i and j.
Definition Array.h:506
const_reverse_iterator rend() const
Returns a const reverse iterator to one before the first element.
Definition Array.h:354
E * m_pStop
Successor of last element (address of A[m_high+1]).
Definition Array.h:705
static const int maxSizeInsertionSort
Threshold used by quicksort() such that insertion sort is called for instances smaller than maxSizeIn...
Definition Array.h:218
INDEX high() const
Returns the maximal array index.
Definition Array.h:294
void permute(INDEX l, INDEX r)
Randomly permutes the subarray with index set [l..r].
Definition Array.h:516
reverse_iterator rbegin()
Returns an reverse iterator to the last element.
Definition Array.h:342
INDEX m_low
The lowest index.
Definition Array.h:706
reverse_iterator rend()
Returns an reverse iterator to one before the first element.
Definition Array.h:351
INDEX linearSearch(const E &e) const
Performs a linear search for element e.
Definition Array.h:606
void leftShift(ArrayBuffer< INDEX, INDEX > &ind)
Removes the components listed in ind by shifting the remaining components to the left.
Definition Array.h:991
Array(const ArrayBuffer< E, INDEX > &A)
Creates an array that is a copy of A. The array-size is set to be the number of elements (not the cap...
Definition Array.h:1018
INDEX binarySearch(INDEX l, INDEX r, const E &e, const COMPARER &comp) const
Performs a binary search for element e within the array section [l, ..., r] with comparer comp.
Definition Array.h:585
const_iterator cend() const
Returns a const iterator to one past the last element.
Definition Array.h:339
static void quicksortInt(E *pL, E *pR, const COMPARER &comp)
Internal Quicksort implementation with comparer template.
Definition Array.h:761
const_iterator begin() const
Returns a const iterator to the first element.
Definition Array.h:327
void grow(INDEX add)
Enlarges the array by add elements.
Definition Array.h:841
int binarySearch(const E &e, const COMPARER &comp) const
Performs a binary search for element e with comparer comp.
Definition Array.h:575
void permute(RNG &rng)
Randomly permutes the array using random number generator rng.
Definition Array.h:538
void construct(INDEX a, INDEX b)
Allocates new array with index set [a, ..., b].
Definition Array.h:856
iterator end()
Returns an iterator to one past the last element.
Definition Array.h:333
bool empty() const
Returns true iff there are no elements in the array.
Definition Array.h:300
void quicksort(INDEX l, INDEX r, const COMPARER &comp)
Sorts the subarray with index set [l, ..., r] using Quicksort and a user-defined comparer comp.
Definition Array.h:657
void init()
Reinitializes the array to an array with empty index set.
Definition Array.h:367
void fill(const E &x)
Sets all elements to x.
Definition Array.h:396
void initialize(const E &x)
Initializes elements with x.
Definition Array.h:892
void quicksort()
Sorts array using Quicksort.
Definition Array.h:634
void expandArray(INDEX add)
Used by grow() to enlarge the array.
Definition Array.h:805
const_reverse_iterator crend() const
Returns a const reverse iterator to one before the first element.
Definition Array.h:357
void init(INDEX a, INDEX b)
Reinitializes the array to an array with index set [a..b].
Definition Array.h:382
void expandArrayHelper(INDEX sOld, INDEX sNew)
Used by expandArray() to reallocate the array elements.
Definition Array.h:732
Array(INDEX a, INDEX b, const E &x)
Creates an array with index set [a..b] and initializes each element with x.
Definition Array.h:248
bool operator!=(const Array< E, INDEX > &L) const
Inequality operator.
Definition Array.h:496
E & reference
Provides a reference to an element stored in an array.
Definition Array.h:223
int binarySearch(const E &e) const
Performs a binary search for element e.
Definition Array.h:556
ArrayConstIterator< E > const_iterator
Provides a random-access iterator that can read a const element in an array.
Definition Array.h:227
Array< E, INDEX > & operator=(const Array< E, INDEX > &A)
Assignment operator.
Definition Array.h:447
INDEX low() const
Returns the minimal array index.
Definition Array.h:291
void initialize()
Initializes elements with default constructor.
Definition Array.h:876
void permute()
Randomly permutes the array.
Definition Array.h:522
void quicksort(INDEX l, INDEX r)
Sorts subarray with index set [l, ..., r] using Quicksort.
Definition Array.h:637
INDEX size() const
Returns the size (number of elements) of the array.
Definition Array.h:297
int binarySearch(INDEX l, INDEX r, const E &e) const
Performs a binary search for element e within the array section [l, ..., r] .
Definition Array.h:565
const_reverse_iterator crbegin() const
Returns a const reverse iterator to the last element.
Definition Array.h:348
~Array()
Destruction.
Definition Array.h:282
void leftShift(ArrayBuffer< INDEX, INDEX > &ind, const E &val)
Removes the components listed in ind by shifting the remaining components to the left.
Definition Array.h:692
void copy(const Array< E, INDEX > &A)
Constructs a new array which is a copy of A.
Definition Array.h:934
void resize(INDEX newSize)
Resizes (enlarges or shrinks) the array to hold newSize elements.
Definition Array.h:444
void init(INDEX a, INDEX b, const E &x)
Reinitializes the array to an array with index set [a..b] and sets all entries to x.
Definition Array.h:389
const_iterator end() const
Returns a const iterator to one past the last element.
Definition Array.h:336
void fill(INDEX i, INDEX j, const E &x)
Sets elements in the intervall [i..j] to x.
Definition Array.h:404
Array(Array< E, INDEX > &&A)
Creates an array containing the elements of A (move semantics).
Definition Array.h:269
INDEX m_high
The highest index.
Definition Array.h:707
void initialize(std::initializer_list< E > initList)
Initializes elements from given initializer list initList.
Definition Array.h:908
ArrayIterator< E > iterator
Provides a random-access iterator that can read or modify any element in an array.
Definition Array.h:229
bool operator==(const Array< E, INDEX > &L) const
Equality operator.
Definition Array.h:475
Array(INDEX a, INDEX b)
Creates an array with index set [a..b].
Definition Array.h:242
E * m_vpStart
The virtual start of the array (address of A[0]).
Definition Array.h:703
E * m_pStart
The real start of the array (address of A[m_low]).
Definition Array.h:704
Array()
Creates an array with empty index set.
Definition Array.h:236
E value_type
Represents the data type stored in an array element.
Definition Array.h:221
Array(const Array< E, INDEX > &A)
Creates an array that is a copy of A.
Definition Array.h:263
Array(INDEX s)
Creates an array with index set [0..s-1].
Definition Array.h:239
const_iterator cbegin() const
Returns a const iterator to the first element.
Definition Array.h:330
void init(INDEX s)
Reinitializes the array to an array with index set [0..s-1].
Definition Array.h:376
void permute(INDEX l, INDEX r, RNG &rng)
Randomly permutes the subarray with index set [l..r] using random number generator rng.
Definition Array.h:951
INDEX linearSearch(const E &e, const COMPARER &comp) const
Performs a linear search for element e with comparer comp.
Definition Array.h:623
const E & const_reference
Provides a reference to a const element stored in an array for reading and performing const operation...
Definition Array.h:225
Array< E, INDEX > & operator=(Array< E, INDEX > &&A)
Assignment operator (move semantics).
Definition Array.h:457
const_reverse_iterator rbegin() const
Returns a const reverse iterator to the last element.
Definition Array.h:345
Array(std::initializer_list< E > initList)
Creates an array containing the elements in the initializer list initList.
Definition Array.h:257
Random-access reverse iterator based on a pointer to an array element.
Definition Array.h:69
bool operator<=(ArrayReverseIteratorBase< E, isConst > &it) const
Less-than-or-equals operator.
Definition Array.h:189
ArrayReverseIteratorBase< E, isConst > operator-(const int &rhs)
Subtraction operator with int on the right-hand side.
Definition Array.h:172
friend ArrayReverseIteratorBase< E, isConst > operator+(const int &lhs, ArrayReverseIteratorBase< E, isConst > rhs)
Addition operator with int on the left-hand side. Returns the same result as addition with int on the...
Definition Array.h:166
const Elem & operator[](std::size_t idx) const
Const member access operator.
Definition Array.h:198
bool operator!=(const ArrayReverseIteratorBase< E, isConst > &it) const
Inequality operator.
Definition Array.h:108
ArrayReverseIteratorBase()
Constructs an invalid iterator.
Definition Array.h:87
int operator-(ArrayReverseIteratorBase< E, isArgConst > &rhs)
Subtraction operator.
Definition Array.h:178
ArrayReverseIteratorBase(E *pX)
Constructs an iterator that points to E* pX.
Definition Array.h:80
ArrayReverseIteratorBase(const E *pX)
Constructs an iterator that points to const E* pX.
Definition Array.h:84
ArrayReverseIteratorBase< E, isConst > & operator++()
Increment operator (prefix).
Definition Array.h:122
bool operator>=(ArrayReverseIteratorBase< E, isConst > &it) const
Greater-than-or-equals operator.
Definition Array.h:192
ArrayReverseIteratorBase< E, isConst > operator++(int)
Increment operator (postfix).
Definition Array.h:128
ArrayReverseIteratorBase(const ArrayReverseIteratorBase< E, isConst > &it)
Copy constructor. clang10 does not see the above templated one match this case and requires it explic...
Definition Array.h:96
bool operator==(const ArrayReverseIteratorBase< E, isConst > &it) const
Equality operator.
Definition Array.h:103
ArrayReverseIteratorBase< E, isConst > & operator=(const ArrayReverseIteratorBase< E, isConst > &it)
Assignment operator.
Definition Array.h:116
ArrayReverseIteratorBase< E, isConst > operator+(const int &rhs)
Addition operator with int on the right-hand side.
Definition Array.h:160
Elem * m_pX
The pointer to the array element.
Definition Array.h:76
bool operator>(ArrayReverseIteratorBase< E, isConst > &it) const
Greater-than operator.
Definition Array.h:186
ArrayReverseIteratorBase< E, isConst > & operator--()
Decrement operator (prefix).
Definition Array.h:135
Elem & operator*() const
Returns the element this iterator points to.
Definition Array.h:113
ArrayReverseIteratorBase< E, isConst > operator--(int)
Decrement operator (postfix).
Definition Array.h:141
Elem & operator[](std::size_t idx)
Member access operator.
Definition Array.h:195
ArrayReverseIteratorBase(const ArrayReverseIteratorBase< E, isArgConst > &it)
Constructs an iterator that is a copy of it.
Definition Array.h:91
ArrayReverseIteratorBase< E, isConst > & operator+=(const int &rhs)
Compound assignment operator (+).
Definition Array.h:148
ArrayReverseIteratorBase< E, isConst > & operator-=(const int &rhs)
Compound assignment operator (-).
Definition Array.h:154
bool operator<(ArrayReverseIteratorBase< E, isConst > &it) const
Less-than operator.
Definition Array.h:183
typename std::conditional< isConst, const E, E >::type Elem
The underlying element, depending on isConst.
Definition Array.h:73
Exception thrown when not enough memory is available to execute an algorithm.
Definition exceptions.h:203
Standard comparer (valid as a static comparer).
Definition comparer.h:59
Declarations for Comparer objects.
Definition of exception classes.
#define OGDF_THROW(CLASS)
Replacement for throw.
Definition exceptions.h:63
#define OGDF_ASSERT(expr)
Assert condition expr. See doc/build.md for more information.
Definition basic.h:41
#define OGDF_NEW_DELETE
Makes the class use OGDF's memory allocator.
Definition memory.h:84
long unsigned int randomSeed()
Returns a random value suitable as initial seed for a random number engine.
int r[]
Declaration of memory manager for allocating small pieces of memory.
static MultilevelBuilder * getDoubleFactoredZeroAdjustedMerger()
The namespace for all OGDF objects.
std::ostream & operator<<(std::ostream &os, const ogdf::Array< E, INDEX > &a)
Prints array a to output stream os.
Definition Array.h:978
E * ArrayIterator
Definition Array.h:53
const E * ArrayConstIterator
Definition Array.h:51
void print(std::ostream &os, const Array< E, INDEX > &a, char delim=' ')
Prints array a to output stream os using delimiter delim.
Definition Array.h:967