Open
Graph Drawing
Framework

 v. snapshot-2017-02-16
 

List.h
Go to the documentation of this file.
1 
32 #pragma once
33 
35 #include <random>
36 
37 namespace ogdf {
38 
39 template<class E> class List;
40 template<class E> class ListPure;
41 template<class E, bool isConst> class ListIteratorBase;
42 template<class E> using ListConstIterator = ListIteratorBase<E, true>;
43 template<class E> using ListIterator = ListIteratorBase<E, false>;
44 
46 template<class E>
47 class ListElement {
48  friend class ListPure<E>;
49  friend class List<E>;
50  friend class ListIteratorBase<E, true>;
51  friend class ListIteratorBase<E, false>;
52 
55  E m_x;
56 #ifdef OGDF_DEBUG
57  ListPure<E> *m_list;
58 #endif
59 
61  ListElement(ListPure<E> *list, const E &x, ListElement<E> *next, ListElement<E> *prev)
62  : m_next(next), m_prev(prev), m_x(x) {
63 #ifdef OGDF_DEBUG
64  m_list = list;
65 #endif
66  }
68  ListElement(ListPure<E> *list, const E &x) : ListElement(list, x, nullptr, nullptr) { }
70  template<class ... Args>
71  ListElement(ListPure<E> *list, ListElement<E> *next, ListElement<E> *prev, Args && ... args)
72  : ListElement(list, E(std::forward<Args>(args)...), next, prev) { }
73 
75 };
76 
78 
86 template<class E, bool isConst> class ListIteratorBase {
87  friend class ListIteratorBase<E, !isConst>;
88  friend class ListPure<E>;
90  using ListElem = typename std::conditional<isConst, const ListElement<E>, ListElement<E>>::type;
93 
95  ListElem *m_pX;
96 
98  operator ListElem *() { return m_pX; }
99 
100 public:
102  ListIteratorBase(ListElem *pX) : m_pX(pX) { }
103 
106 
110 
112  bool valid() const { return m_pX != nullptr; }
113 
114 #ifdef OGDF_DEBUG
115  ListPure<E> *listOf() {
118  OGDF_ASSERT(valid());
119  return m_pX->m_list;
120  }
121 #endif
122  bool operator==(const ListIteratorBase<E, isConst> &it) const {
124  return m_pX == it.m_pX;
125  }
126 
128  bool operator!=(const ListIteratorBase<E, isConst> &it) const {
129  return m_pX != it.m_pX;
130  }
131 
133  ListIteratorBase<E, isConst> succ() const { return m_pX->m_next; }
134 
136  ListIteratorBase<E, isConst> pred() const { return m_pX->m_prev; }
137 
139  Elem &operator*() const { return m_pX->m_x; }
140 
143  m_pX = it.m_pX;
144  return *this;
145  }
146 
149  m_pX = m_pX->m_next;
150  return *this;
151  }
152 
155  ListIteratorBase<E, isConst> it = *this;
156  m_pX = m_pX->m_next;
157  return it;
158  }
159 
162  m_pX = m_pX->m_prev;
163  return *this;
164  }
165 
168  ListIteratorBase<E, isConst> it = *this;
169  m_pX = m_pX->m_prev;
170  return it;
171  }
172 
174 };
175 
177 
186 template<class E> class ListPure {
187 protected:
190 
191 public:
193  using value_type = E;
195  using reference = E&;
197  using const_reference = const E&;
202 
204  ListPure() : m_head(nullptr), m_tail(nullptr) { }
205 
207  ListPure(std::initializer_list<E> init) : m_head(nullptr), m_tail(nullptr) {
208  for (const E &x : init)
209  pushBack(x);
210  }
211 
213  ListPure(const ListPure<E> &L) : m_head(nullptr), m_tail(nullptr) {
214  copy(L);
215  }
216 
218 
221  ListPure(ListPure<E> &&L) : m_head(L.m_head), m_tail(L.m_tail) {
222  L.m_head = L.m_tail = nullptr;
223  }
224 
226  virtual ~ListPure() { clear(); }
227 
228 
234 
236  bool empty() const { return m_head == nullptr; }
237 
239 
243  virtual int size() const {
244  int count = 0;
245  for (ListElement<E> *pX = m_head; pX; pX = pX->m_next)
246  ++count;
247  return count;
248  }
249 
251 
255  OGDF_ASSERT(m_head != nullptr);
256  return m_head->m_x;
257  }
258 
260 
264  OGDF_ASSERT(m_head != nullptr);
265  return m_head->m_x;
266  }
267 
269 
273  OGDF_ASSERT(m_tail != nullptr);
274  return m_tail->m_x;
275  }
276 
278 
282  OGDF_ASSERT(m_tail != nullptr);
283  return m_tail->m_x;
284  }
285 
287 
290  const_iterator get(int pos) const {
291  ListElement<E> *pX;
292  for(pX = m_head; pX != nullptr; pX = pX->m_next)
293  if (pos-- == 0) break;
294  return pX;
295  }
296 
298 
301  iterator get(int pos) {
302  ListElement<E> *pX;
303  for(pX = m_head; pX != nullptr; pX = pX->m_next)
304  if (pos-- == 0) break;
305  return pX;
306  }
307 
309 
312  int pos(const_iterator it) const {
313  OGDF_ASSERT(it.listOf() == this);
314  int p = 0;
315  for(ListElement<E> *pX = m_head; pX != nullptr; pX = pX->m_next, ++p)
316  if (pX == it) break;
317  return p;
318  }
319 
320 
322 
327 
329 
332  iterator begin() { return m_head; }
333 
335 
338  const_iterator begin() const { return m_head; }
339 
341 
344  const_iterator cbegin() const { return m_head; }
345 
347 
350  iterator end() { return iterator(); }
351 
353 
356  const_iterator end() const { return const_iterator(); }
357 
359 
362  const_iterator cend() const { return const_iterator(); }
363 
365 
368  iterator rbegin() { return m_tail; }
369 
371 
374  const_iterator rbegin() const { return m_tail; }
375 
377 
380  const_iterator crbegin() const { return m_tail; }
381 
383 
386  iterator rend() { return iterator(); }
387 
389 
392  const_iterator rend() const { return const_iterator(); }
393 
395 
398  const_iterator crend() const { return const_iterator(); }
399 
401 
405  OGDF_ASSERT(!it.valid() || it.listOf() == this);
406  const ListElement<E> *pX = it;
407  return (pX && pX->m_next) ? pX->m_next : m_head;
408  }
409 
411 
415  OGDF_ASSERT(!it.valid() || it.listOf() == this);
416  ListElement<E> *pX = it;
417  return (pX && pX->m_next) ? pX->m_next : m_head;
418  }
419 
421 
425  OGDF_ASSERT(!it.valid() || it.listOf() == this);
426  const ListElement<E> *pX = it;
427  return (pX && pX->m_prev) ? pX->m_prev : m_tail;
428  }
429 
431 
435  OGDF_ASSERT(!it.valid() || it.listOf() == this);
436  ListElement<E> *pX = it;
437  return (pX && pX->m_prev) ? pX->m_prev : m_tail;
438  }
439 
440 
442 
447 
450  clear(); copy(L);
451  return *this;
452  }
453 
455 
459  clear();
460  m_head = L.m_head;
461  m_tail = L.m_tail;
462  L.m_head = L.m_tail = nullptr;
463  reassignListRefs();
464  return *this;
465  }
466 
468  bool operator==(const ListPure<E> &L) const {
469  ListElement<E> *pX = m_head, *pY = L.m_head;
470  while(pX != nullptr && pY != nullptr) {
471  if(pX->m_x != pY->m_x)
472  return false;
473  pX = pX->m_next;
474  pY = pY->m_next;
475  }
476  return (pX == nullptr && pY == nullptr);
477  }
478 
480  bool operator!=(const ListPure<E> &L) const {
481  return !operator==(L);
482  }
483 
485 
490 
492  iterator pushFront(const E &x) {
493  ListElement<E> *pX = new ListElement<E>(this, x, m_head, nullptr);
494  if (m_head)
495  m_head = m_head->m_prev = pX;
496  else
497  m_head = m_tail = pX;
498  return m_head;
499  }
500 
502 
505  template<class ... Args>
506  iterator emplaceFront(Args && ... args) {
507  ListElement<E> *pX = new ListElement<E>(this, m_head, nullptr, std::forward<Args>(args)...);
508  if (m_head)
509  m_head = m_head->m_prev = pX;
510  else
511  m_head = m_tail = pX;
512  return m_head;
513  }
514 
516  iterator pushBack(const E &x) {
517  ListElement<E> *pX = new ListElement<E>(this, x, nullptr, m_tail);
518  if (m_head)
519  m_tail = m_tail->m_next = pX;
520  else
521  m_tail = m_head = pX;
522  return m_tail;
523  }
524 
526 
529  template<class ... Args>
530  iterator emplaceBack(Args && ... args) {
531  ListElement<E> *pX = new ListElement<E>(this, nullptr, m_tail, std::forward<Args>(args)...);
532  if (m_head)
533  m_tail = m_tail->m_next = pX;
534  else
535  m_tail = m_head = pX;
536  return m_tail;
537  }
538 
540 
548  OGDF_ASSERT(it.listOf() == this);
549  ListElement<E> *pY = it, *pX;
550  if (dir == Direction::after) {
551  ListElement<E> *pYnext = pY->m_next;
552  pY->m_next = pX = new ListElement<E>(this, x, pYnext, pY);
553  if (pYnext) pYnext->m_prev = pX;
554  else m_tail = pX;
555  } else {
556  ListElement<E> *pYprev = pY->m_prev;
557  pY->m_prev = pX = new ListElement<E>(this, x, pY, pYprev);
558  if (pYprev) pYprev->m_next = pX;
559  else m_head = pX;
560  }
561  return pX;
562  }
563 
565 
568  iterator insertBefore(const E &x, iterator it) {
569  OGDF_ASSERT(it.listOf() == this);
570  ListElement<E> *pY = it, *pX;
571  ListElement<E> *pYprev = pY->m_prev;
572  pY->m_prev = pX = new ListElement<E>(this, x, pY, pYprev);
573  if (pYprev) pYprev->m_next = pX;
574  else m_head = pX;
575  return pX;
576  }
577 
579 
582  iterator insertAfter(const E &x, iterator it) {
583  OGDF_ASSERT(it.listOf() == this);
584  ListElement<E> *pY = it, *pX;
585  ListElement<E> *pYnext = pY->m_next;
586  pY->m_next = pX = new ListElement<E>(this, x, pYnext, pY);
587  if (pYnext) pYnext->m_prev = pX;
588  else m_tail = pX;
589  return pX;
590  }
591 
593 
598 
600 
603  void popFront() {
604  OGDF_ASSERT(m_head != nullptr);
605  ListElement<E> *pX = m_head;
606  m_head = m_head->m_next;
607  delete pX;
608  if (m_head) m_head->m_prev = nullptr;
609  else m_tail = nullptr;
610  }
611 
613 
617  E el = front();
618  popFront();
619  return el;
620  }
621 
623 
626  void popBack() {
627  OGDF_ASSERT(m_tail != nullptr);
628  ListElement<E> *pX = m_tail;
629  m_tail = m_tail->m_prev;
630  delete pX;
631  if (m_tail) m_tail->m_next = nullptr;
632  else m_head = nullptr;
633  }
634 
636 
640  E el = back();
641  popBack();
642  return el;
643  }
644 
646 
649  void del(iterator it) {
650  OGDF_ASSERT(it.listOf() == this);
651  ListElement<E> *pX = it, *pPrev = pX->m_prev, *pNext = pX->m_next;
652  delete pX;
653  if (pPrev) pPrev->m_next = pNext;
654  else m_head = pNext;
655  if (pNext) pNext->m_prev = pPrev;
656  else m_tail = pPrev;
657  }
658 
660 
666  bool removeFirst(const E &x) {
667  for(ListElement<E> *pX = m_head; pX != nullptr; pX = pX->m_next)
668  if(pX->m_x == x) {
669  del(pX); return true;
670  }
671  return false;
672  }
673 
675  void clear() {
676  if (m_head == nullptr) return;
677 
678  if (!std::is_trivially_destructible<E>::value) {
679  for(ListElement<E> *pX = m_head; pX != nullptr; pX = pX->m_next)
680  pX->m_x.~E();
681  }
682  OGDF_ALLOCATOR::deallocateList(sizeof(ListElement<E>),m_head,m_tail);
683 
684  m_head = m_tail = nullptr;
685  }
686 
688 
693 
695 
698  void exchange(iterator it1, iterator it2) {
699  OGDF_ASSERT(it1.valid());
700  OGDF_ASSERT(it2.valid());
701  OGDF_ASSERT(it1 != it2);
702  ListElement<E> *pX = it1, *pY = it2;
703 
704  std::swap(pX->m_next,pY->m_next);
705  std::swap(pX->m_prev,pY->m_prev);
706 #ifdef OGDF_DEBUG
707  std::swap(pX->m_list,pY->m_list);
708 #endif
709 
710  if(pX->m_next == pX) {
711  pX->m_next = pY; pY->m_prev = pX;
712  }
713  if(pX->m_prev == pX) {
714  pX->m_prev = pY; pY->m_next = pX;
715  }
716 
717  if(pX->m_prev) pX->m_prev->m_next = pX;
718  else m_head = pX;
719 
720  if(pY->m_prev) pY->m_prev->m_next = pY;
721  else m_head = pY;
722 
723  if(pX->m_next) pX->m_next->m_prev = pX;
724  else m_tail = pX;
725 
726  if(pY->m_next) pY->m_next->m_prev = pY;
727  else m_tail = pY;
728  }
729 
731 
735  OGDF_ASSERT(it.listOf() == this);
736  // remove it
737  ListElement<E> *pX = it, *pPrev = pX->m_prev, *pNext = pX->m_next;
738  //already at front
739  if (!pPrev) return;
740 
741  //update old position
742  if (pPrev) pPrev->m_next = pNext;
743  if (pNext) pNext->m_prev = pPrev;
744  else m_tail = pPrev;
745  // insert it at front
746  pX->m_prev = nullptr;
747  pX->m_next = m_head;
748  m_head = m_head->m_prev = pX;
749  }
750 
752 
755  void moveToBack(iterator it) {
756  OGDF_ASSERT(it.listOf() == this);
757  // remove it
758  ListElement<E> *pX = it, *pPrev = pX->m_prev, *pNext = pX->m_next;
759  //already at back
760  if (!pNext) return;
761 
762  //update old position
763  if (pPrev) pPrev->m_next = pNext;
764  else m_head = pNext;
765  if (pNext) pNext->m_prev = pPrev;
766  // insert it at back
767  pX->m_prev = m_tail;
768  pX->m_next = nullptr;
769  m_tail = m_tail->m_next = pX;
770  }
771 
773 
776  void moveToSucc(iterator it, iterator itBefore) {
777  OGDF_ASSERT(it.listOf() == this);
778  OGDF_ASSERT(itBefore.listOf() == this);
779  // move it
780  ListElement<E> *pX = it, *pPrev = pX->m_prev, *pNext = pX->m_next;
781  //the same of already in place
782  ListElement<E> *pY = itBefore;
783  if(pX == pY || pPrev == pY) return;
784 
785  // update old position
786  if (pPrev) pPrev->m_next = pNext;
787  else m_head = pNext;
788  if (pNext) pNext->m_prev = pPrev;
789  else m_tail = pPrev;
790  // move it after itBefore
791  ListElement<E> *pYnext = pX->m_next = pY->m_next;
792  (pX->m_prev = pY)->m_next = pX;
793  if (pYnext) pYnext->m_prev = pX;
794  else m_tail = pX;
795  }
796 
798 
801  void moveToPrec(iterator it, iterator itAfter) {
802  OGDF_ASSERT(it.listOf() == this);
803  OGDF_ASSERT(itAfter.listOf() == this);
804  // move it
805  ListElement<E> *pX = it, *pPrev = pX->m_prev, *pNext = pX->m_next;
806  //the same of already in place
807  ListElement<E> *pY = itAfter;
808  if(pX == pY || pNext == pY) return;
809 
810  // update old position
811  if (pPrev) pPrev->m_next = pNext;
812  else m_head = pNext;
813  if (pNext) pNext->m_prev = pPrev;
814  else m_tail = pPrev;
815  // move it before itAfter
816  ListElement<E> *pYprev = pX->m_prev = pY->m_prev;
817  (pX->m_next = pY)->m_prev = pX;
818  if (pYprev) pYprev->m_next = pX;
819  else m_head = pX;
820  }
821 
823 
827  OGDF_ASSERT(it.listOf() == this);
828  OGDF_ASSERT(this != &L2);
829  // remove it
830  ListElement<E> *pX = it, *pPrev = pX->m_prev, *pNext = pX->m_next;
831  if (pPrev) pPrev->m_next = pNext;
832  else m_head = pNext;
833  if (pNext) pNext->m_prev = pPrev;
834  else m_tail = pPrev;
835  // insert it at front of L2
836  pX->m_prev = nullptr;
837  if ((pX->m_next = L2.m_head) != nullptr)
838  L2.m_head = L2.m_head->m_prev = pX;
839  else
840  L2.m_head = L2.m_tail = pX;
841 
842 #ifdef OGDF_DEBUG
843  pX->m_list = &L2;
844 #endif
845  }
846 
848 
852  OGDF_ASSERT(it.listOf() == this);
853  OGDF_ASSERT(this != &L2);
854  // remove it
855  ListElement<E> *pX = it, *pPrev = pX->m_prev, *pNext = pX->m_next;
856  if (pPrev) pPrev->m_next = pNext;
857  else m_head = pNext;
858  if (pNext) pNext->m_prev = pPrev;
859  else m_tail = pPrev;
860  // insert it at back of L2
861  pX->m_next = nullptr;
862  if ((pX->m_prev = L2.m_tail) != nullptr)
863  L2.m_tail = L2.m_tail->m_next = pX;
864  else
865  L2.m_head = L2.m_tail = pX;
866 
867 #ifdef OGDF_DEBUG
868  pX->m_list = this;
869 #endif
870  }
871 
873 
877  void moveToSucc(iterator it, ListPure<E> &L2, iterator itBefore) {
878  OGDF_ASSERT(it.listOf() == this);
879  OGDF_ASSERT(itBefore.listOf() == &L2);
880  OGDF_ASSERT(this != &L2);
881  // remove it
882  ListElement<E> *pX = it, *pPrev = pX->m_prev, *pNext = pX->m_next;
883  if (pPrev) pPrev->m_next = pNext;
884  else m_head = pNext;
885  if (pNext) pNext->m_prev = pPrev;
886  else m_tail = pPrev;
887  // insert it in list L2 after itBefore
888  ListElement<E> *pY = itBefore;
889  ListElement<E> *pYnext = pX->m_next = pY->m_next;
890  (pX->m_prev = pY)->m_next = pX;
891  if (pYnext) pYnext->m_prev = pX;
892  else L2.m_tail = pX;
893 
894 #ifdef OGDF_DEBUG
895  pX->m_list = &L2;
896 #endif
897  }
898 
900 
904  void moveToPrec(iterator it, ListPure<E> &L2, iterator itAfter) {
905  OGDF_ASSERT(it.listOf() == this);
906  OGDF_ASSERT(itAfter.listOf() == &L2);
907  OGDF_ASSERT(this != &L2);
908  // remove it
909  ListElement<E> *pX = it, *pPrev = pX->m_prev, *pNext = pX->m_next;
910  if (pPrev) pPrev->m_next = pNext;
911  else m_head = pNext;
912  if (pNext) pNext->m_prev = pPrev;
913  else m_tail = pPrev;
914  // insert it in list L2 after itBefore
915  ListElement<E> *pY = itAfter;
916  ListElement<E> *pYprev = pX->m_prev = pY->m_prev;
917  (pX->m_next = pY)->m_prev = pX;
918  if (pYprev) pYprev->m_next = pX;
919  else L2.m_head = pX;
920 
921 #ifdef OGDF_DEBUG
922  pX->m_list = &L2;
923 #endif
924  }
925 
927  void conc(ListPure<E> &L2) {
928  OGDF_ASSERT(this != &L2);
929  if (m_head)
930  m_tail->m_next = L2.m_head;
931  else
932  m_head = L2.m_head;
933  if (L2.m_head) {
934  L2.m_head->m_prev = m_tail;
935  m_tail = L2.m_tail;
936  }
937 
938  reassignListRefs(L2.m_head);
939 
940  L2.m_head = L2.m_tail = nullptr;
941  }
942 
944  void concFront(ListPure<E> &L2) {
945  OGDF_ASSERT(this != &L2);
946  if (m_head)
947  m_head->m_prev = L2.m_tail;
948  else
949  m_tail = L2.m_tail;
950  if (L2.m_head) {
951  L2.m_tail->m_next = m_head;
952  m_head = L2.m_head;
953  }
954 
955  reassignListRefs(L2.m_head);
956 
957  L2.m_head = L2.m_tail = nullptr;
958  }
959 
961  void swap(ListPure<E> &other) {
962  std::swap(m_head, other.m_head);
963  std::swap(m_tail, other.m_tail);
964 
965  reassignListRefs();
966  other.reassignListRefs();
967  }
968 
970 
980  OGDF_ASSERT(!it.valid() || it.listOf() == this);
981  if (&L1 != this) L1.clear();
982  if (&L2 != this) L2.clear();
983 
984  if (it.valid()){
985  L1.m_head = m_head;
986  L2.m_tail = m_tail;
987  if (dir == Direction::before){
988  L2.m_head = it;
989  L1.m_tail = L2.m_head->m_prev;
990  }
991  else {
992  L1.m_tail = it;
993  L2.m_head = L1.m_tail->m_next;
994  }
995  L2.m_head->m_prev = L1.m_tail->m_next = nullptr;
996 
997  } else {
998  L1.m_head = L1.m_tail = nullptr;
999  L2.m_head = m_head;
1000  L2.m_tail = m_tail;
1001  }
1002 
1003  if (this != &L1 && this != &L2) {
1004  m_head = m_tail = nullptr;
1005  }
1006 
1007  L1.reassignListRefs();
1008  L2.reassignListRefs();
1009  }
1010 
1013  OGDF_ASSERT(it.listOf() == this);
1014  OGDF_ASSERT(this != &L2);
1015  L2.clear();
1016  ListElement<E> *pX = it;
1017  if (pX != m_tail) {
1018  (L2.m_head = pX->m_next)->m_prev = nullptr;
1019  pX->m_next = nullptr;
1020  L2.m_tail = m_tail;
1021  m_tail = pX;
1022  }
1023 
1024  L2.reassignListRefs();
1025  }
1026 
1029  OGDF_ASSERT(it.listOf() == this);
1030  OGDF_ASSERT(this != &L2);
1031  L2.clear();
1032  ListElement<E> *pX = it;
1033  L2.m_head = pX; L2.m_tail = m_tail;
1034  if ((m_tail = pX->m_prev) == nullptr)
1035  m_head = nullptr;
1036  else
1037  m_tail->m_next = nullptr;
1038  pX->m_prev = nullptr;
1039 
1040  L2.reassignListRefs();
1041  }
1042 
1044  void reverse() {
1045  ListElement<E> *pX = m_head;
1046  m_head = m_tail;
1047  m_tail = pX;
1048  while(pX) {
1049  ListElement<E> *pY = pX->m_next;
1050  pX->m_next = pX->m_prev;
1051  pX = pX->m_prev = pY;
1052  }
1053  }
1054 
1056 
1061 
1063  ListConstIterator<E> search(const E& e) const {
1065  for (i = begin(); i.valid(); ++i)
1066  if (*i == e) return i;
1067  return i;
1068  }
1069 
1071  ListIterator<E> search(const E& e) {
1072  ListIterator<E> i;
1073  for (i = begin(); i.valid(); ++i)
1074  if (*i == e) return i;
1075  return i;
1076  }
1077 
1079  template<class COMPARER>
1080  ListConstIterator<E> search(const E &e, const COMPARER &comp) const {
1082  for (i = begin(); i.valid(); ++i)
1083  if (comp.equal(*i, e)) return i;
1084  return i;
1085  }
1086 
1088  template<class COMPARER>
1089  ListIterator<E> search(const E &e, const COMPARER &comp) {
1090  ListIterator<E> i;
1091  for (i = begin(); i.valid(); ++i)
1092  if (comp.equal(*i, e)) return i;
1093  return i;
1094  }
1095 
1097  void quicksort() {
1098  ogdf::quicksortTemplate(*this);
1099  }
1100 
1102  template<class COMPARER>
1103  void quicksort(const COMPARER &comp) {
1104  ogdf::quicksortTemplate(*this,comp);
1105  }
1106 
1108 
1115  void bucketSort(int l, int h, BucketFunc<E> &f);
1116 
1118 
1123 
1133  std::function<bool(const E&)> includeElement = [](const E&) { return true; },
1134  bool isFastTest = true) const {
1135  return chooseIteratorFrom(*this, includeElement, isFastTest);
1136  }
1137 
1140  std::function<bool(const E&)> includeElement = [](const E&) { return true; },
1141  bool isFastTest = true) {
1142  return chooseIteratorFrom(*this, includeElement, isFastTest);
1143  }
1144 
1154  std::function<bool(const E&)> includeElement = [](const E&) { return true; },
1155  bool isFastTest = true) const {
1156  const_iterator result = chooseIterator(includeElement, isFastTest);
1157  OGDF_ASSERT(result.valid());
1158  return *result;
1159  }
1160 
1163  std::function<bool(const E&)> includeElement = [](const E&) { return true; },
1164  bool isFastTest = true) {
1165  iterator result = chooseIterator(includeElement, isFastTest);
1166  OGDF_ASSERT(result.valid());
1167  return *result;
1168  }
1169 
1171  void permute() {
1172  std::minstd_rand rng(randomSeed());
1173  permute(size(), rng);
1174  }
1175 
1177  template<class RNG>
1178  void permute(RNG &rng) {
1179  permute(size(), rng);
1180  }
1181 
1183 
1184 protected:
1185  void copy(const ListPure<E> &L) {
1186  for(ListElement<E> *pX = L.m_head; pX != nullptr; pX = pX->m_next)
1187  pushBack(pX->m_x);
1188  }
1189 
1190  template<class RNG>
1191 
1193  void permute(const int n, RNG &rng);
1194 
1196  inline void reassignListRefs(ListElement<E> *start = nullptr) {
1197 #ifdef OGDF_DEBUG
1198  for(auto e = start == nullptr ? m_head : start; e != nullptr; e = e->m_next) {
1199  e->m_list = this;
1200  }
1201 #endif
1202  }
1203 
1205 };
1206 
1208 
1217 template<class E>
1218 class List : private ListPure<E> {
1219  int m_count;
1220 
1221 public:
1222  using typename ListPure<E>::value_type;
1223  using typename ListPure<E>::reference;
1224  using typename ListPure<E>::const_reference;
1225  using typename ListPure<E>::const_iterator;
1226  using typename ListPure<E>::iterator;
1227 
1229  List() : m_count(0) { }
1230 
1232  List(std::initializer_list<E> init) : ListPure<E>(init), m_count((int)init.size()) { }
1233 
1235  List(const List<E> &L) : ListPure<E>(L), m_count(L.m_count) { }
1236 
1238 
1241  List(List<E> &&L) : ListPure<E>(std::move(L)), m_count(L.m_count) {
1242  L.m_count = 0;
1243  }
1244 
1250 
1252 
1255  int size() const { return m_count; }
1256 
1258  const ListPure<E> &getListPure() const { return *this; }
1259 
1261 
1266 
1270  m_count = L.m_count;
1271  return *this;
1272  }
1273 
1275 
1279  m_count = L.m_count;
1281  L.m_count = 0;
1282  return *this;
1283  }
1284 
1286  bool operator==(const List<E> &L) const {
1287  return (m_count == L.m_count) && ListPure<E>::operator==(L);
1288  }
1289 
1291  bool operator!=(const List<E> &L) const {
1292  return !operator==(L);
1293  }
1294 
1296 
1301 
1303  iterator pushFront(const E &x) {
1304  ++m_count;
1305  return ListPure<E>::pushFront(x);
1306  }
1307 
1309  template<class ... Args>
1310  iterator emplaceFront(Args && ... args) {
1311  ++m_count;
1312  return ListPure<E>::emplaceFront(std::forward<Args>(args)...);
1313  }
1314 
1316  iterator pushBack(const E &x) {
1317  ++m_count;
1318  return ListPure<E>::pushBack(x);
1319  }
1320 
1322  template<class ... Args>
1323  iterator emplaceBack(Args && ... args) {
1324  ++m_count;
1325  return ListPure<E>::emplaceBack(std::forward<Args>(args)...);
1326  }
1327 
1330  ++m_count;
1331  return ListPure<E>::insert(x,it,dir);
1332  }
1333 
1335  iterator insertBefore(const E &x, iterator it) {
1336  ++m_count;
1337  return ListPure<E>::insertBefore(x,it);
1338  }
1339 
1341  iterator insertAfter(const E &x, iterator it) {
1342  ++m_count;
1343  return ListPure<E>::insertAfter(x,it);
1344  }
1345 
1347 
1352 
1354  void popFront() {
1355  --m_count;
1357  }
1358 
1361  E el = front();
1362  popFront();
1363  return el;
1364  }
1365 
1367  void popBack() {
1368  --m_count;
1370  }
1371 
1374  E el = back();
1375  popBack();
1376  return el;
1377  }
1378 
1380  void del(iterator it) {
1381  --m_count;
1382  ListPure<E>::del(it);
1383  }
1384 
1386  bool removeFirst(const E &x) {
1387  bool hasRemoved = ListPure<E>::removeFirst(x);
1388  if(hasRemoved)
1389  --m_count;
1390  return hasRemoved;
1391  }
1392 
1394  void clear() {
1395  m_count = 0;
1397  }
1398 
1400 
1405 
1407  void moveToFront(iterator it, List<E> &L2) {
1408  ListPure<E>::moveToFront(it,L2);
1409  --m_count; ++L2.m_count;
1410  }
1411 
1413  void moveToBack(iterator it, List<E> &L2) {
1414  ListPure<E>::moveToBack(it,L2);
1415  --m_count; ++L2.m_count;
1416  }
1417 
1419  void moveToSucc(iterator it, List<E> &L2, iterator itBefore) {
1420  ListPure<E>::moveToSucc(it,L2,itBefore);
1421  --m_count; ++L2.m_count;
1422  }
1423 
1425  void moveToPrec(iterator it, List<E> &L2, iterator itAfter) {
1426  ListPure<E>::moveToPrec(it,L2,itAfter);
1427  --m_count; ++L2.m_count;
1428  }
1429 
1431  void conc(List<E> &L2) {
1432  ListPure<E>::conc(L2);
1433  m_count += L2.m_count;
1434  L2.m_count = 0;
1435  }
1436 
1438  void concFront(List<E> &L2) {
1440  m_count += L2.m_count;
1441  L2.m_count = 0;
1442  }
1443 
1445  void swap(List<E> &other) {
1446  ListPure<E>::swap(other);
1447  std::swap(m_count, other.m_count);
1448  }
1449 
1452  ListPure<E>::split(it,L1,L2,dir);
1453  int countL = m_count, countL1 = 0;
1454  for(ListElement<E> *pX = L1.m_head; pX != nullptr; pX = pX->m_next)
1455  ++countL1;
1456 
1457  L1.m_count = countL1;
1458  L2.m_count = countL - countL1;
1459  if (this->m_head == nullptr) m_count = 0;
1460  }
1461 
1462  using ListPure<E>::empty;
1463  using ListPure<E>::front;
1464  using ListPure<E>::back;
1465  using ListPure<E>::get;
1466  using ListPure<E>::pos;
1467  using ListPure<E>::begin;
1468  using ListPure<E>::cbegin;
1469  using ListPure<E>::end;
1470  using ListPure<E>::cend;
1471  using ListPure<E>::rbegin;
1472  using ListPure<E>::crbegin;
1473  using ListPure<E>::rend;
1474  using ListPure<E>::crend;
1477  using ListPure<E>::exchange;
1482  using ListPure<E>::reverse;
1483  using ListPure<E>::search;
1484  using ListPure<E>::quicksort;
1488  using ListPure<E>::permute;
1489 
1491 };
1492 
1493 template<class E>
1495 {
1496  if (m_head == m_tail) return;
1497 
1498  Array<ListElement<E> *> head(l,h,nullptr), tail(l,h);
1499 
1500  ListElement<E> *pX;
1501  for (pX = m_head; pX; pX = pX->m_next) {
1502  int i = f.getBucket(pX->m_x);
1503  if (head[i])
1504  tail[i] = ((pX->m_prev = tail[i])->m_next = pX);
1505  else
1506  head[i] = tail[i] = pX;
1507  }
1508 
1509  ListElement<E> *pY = nullptr;
1510  for (int i = l; i <= h; i++) {
1511  pX = head[i];
1512  if (pX) {
1513  if (pY) {
1514  (pY->m_next = pX)->m_prev = pY;
1515  } else
1516  (m_head = pX)->m_prev = nullptr;
1517  pY = tail[i];
1518  }
1519  }
1520 
1521  m_tail = pY;
1522  pY->m_next = nullptr;
1523 }
1524 
1525 template<class E>
1526 template<class RNG>
1527 void ListPure<E>::permute(const int n, RNG &rng)
1528 {
1529  //if n==0 do nothing
1530  if (n == 0) { return; }
1531 
1532  Array<ListElement<E> *> A(n+2);
1533  A[0] = A[n+1] = nullptr;
1534 
1535  int i = 1;
1536  ListElement<E> *pX;
1537  for (pX = m_head; pX; pX = pX->m_next)
1538  A[i++] = pX;
1539 
1540  A.permute(1,n,rng);
1541 
1542  for (i = 1; i <= n; i++) {
1543  pX = A[i];
1544  pX->m_next = A[i+1];
1545  pX->m_prev = A[i-1];
1546  }
1547 
1548  m_head = A[1];
1549  m_tail = A[n];
1550 }
1551 
1553 template<class E>
1554 void print(ostream &os, const ListPure<E> &L, char delim = ' ')
1555 {
1556  typename ListPure<E>::const_iterator pX = L.begin();
1557  if (pX.valid()) {
1558  os << *pX;
1559  for(++pX; pX.valid(); ++pX)
1560  os << delim << *pX;
1561  }
1562 }
1563 
1565 template<class E>
1566 void print(ostream &os, const List<E> &L, char delim = ' ')
1567 {
1568  print(os, L.getListPure(), delim);
1569 }
1570 
1572 template<class E>
1573 ostream &operator<<(ostream &os, const ListPure<E> &L)
1574 {
1575  print(os,L);
1576  return os;
1577 }
1578 
1580 template<class E>
1581 ostream &operator<<(ostream &os, const List<E> &L)
1582 {
1583  return os << L.getListPure();
1584 }
1585 
1586 template<class E, class Master>
1587 class ListContainer : public List<E> {
1588  friend Master;
1589 
1590 public:
1593 
1595  iterator begin() const { return List<E>::cbegin(); }
1596 
1598  iterator end() const { return List<E>::cend(); }
1599 
1601  iterator rbegin() const { return List<E>::crbegin(); }
1602 
1604  iterator rend() const { return List<E>::crend(); }
1605 
1607  int size() const { return List<E>::size(); }
1608 };
1609 
1610 }
void concFront(ListPure< E > &L2)
Prepends L2 to this list and makes L2 empty.
Definition: List.h:944
void clear()
Removes all elements from the list.
Definition: List.h:1394
const_iterator cend() const
Returns a const iterator to one-past-last element of the list.
Definition: List.h:362
E & reference
Provides a reference to an element stored in a list.
Definition: List.h:195
ListConstIterator< E > search(const E &e, const COMPARER &comp) const
Scans the list for the specified element (using the user-defined comparer) and returns an iterator to...
Definition: List.h:1080
ListElement< E > * m_tail
Pointer to last element.
Definition: List.h:189
bool operator!=(const ListIteratorBase< E, isConst > &it) const
Inequality operator.
Definition: List.h:128
void moveToBack(iterator it)
Moves it to the end of the list.
Definition: List.h:755
iterator pushFront(const E &x)
Adds element x at the beginning of the list.
Definition: List.h:492
ListIteratorBase()
Constructs an invalid iterator.
Definition: List.h:105
ListPure(ListPure< E > &&L)
Constructs a doubly linked list containing the elements of L (move semantics).
Definition: List.h:221
The parameterized class Array implements dynamic arrays of type E.
Definition: Array.h:56
ListElement< E > * m_prev
Pointer to predecessor element.
Definition: List.h:54
bool operator==(const ListPure< E > &L) const
Equality operator.
Definition: List.h:468
ListIteratorBase< E, isConst > operator--(int)
Decrement operator (postfix).
Definition: List.h:167
void quicksortTemplate(LIST &L)
iterator pushBack(const E &x)
Adds element x at the end of the list.
Definition: List.h:1316
void moveToPrec(iterator it, List< E > &L2, iterator itAfter)
Moves it before itAfter.
Definition: List.h:1425
iterator cyclicSucc(iterator it)
Returns an iterator to the cyclic successor of it.
Definition: List.h:414
ListIteratorBase(ListElem *pX)
Constructs an iterator that points to pX.
Definition: List.h:102
void conc(List< E > &L2)
Appends L2 to this list and makes L2 empty.
Definition: List.h:1431
bool removeFirst(const E &x)
Removes the first occurrence of x (if any) from the list.
Definition: List.h:666
void splitAfter(iterator it, ListPure< E > &L2)
Splits the list after it.
Definition: List.h:1012
iterator pushBack(const E &x)
Adds element x at the end of the list.
Definition: List.h:516
iterator emplaceBack(Args &&... args)
Adds a new element at the end of the list.
Definition: List.h:1323
void popFront()
Removes the first element from the list.
Definition: List.h:1354
Doubly linked lists.
Definition: List.h:40
const E & const_reference
Provides a reference to a const element stored in a list for reading and performing const operations...
Definition: List.h:197
void split(iterator it, ListPure< E > &L1, ListPure< E > &L2, Direction dir=Direction::before)
Splits the list at element it into lists L1 and L2.
Definition: List.h:979
iterator begin()
Returns an iterator to the first element of the list.
Definition: List.h:332
iterator begin() const
Returns an iterator to the first element in the container.
Definition: List.h:1595
void split(iterator it, List< E > &L1, List< E > &L2, Direction dir=Direction::before)
Splits the list at element it into lists L1 and L2.
Definition: List.h:1451
iterator insertAfter(const E &x, iterator it)
Inserts element x after it.
Definition: List.h:1341
List< E > & operator=(List< E > &&L)
Assignment operator (move semantics).
Definition: List.h:1278
const_iterator cyclicSucc(const_iterator it) const
Returns a const iterator to the cyclic successor of it.
Definition: List.h:404
ListIteratorBase< E, isConst > operator++(int)
Increment operator (postfix).
Definition: List.h:154
E popBackRet()
Removes the last element from the list and returns it.
Definition: List.h:1373
void moveToFront(iterator it)
Moves it to the begin of the list.
Definition: List.h:734
iterator chooseIterator(std::function< bool(const E &)> includeElement=[](const E &) { return true;}, bool isFastTest=true)
Returns an iterator to a random element.
Definition: List.h:1139
void moveToSucc(iterator it, List< E > &L2, iterator itBefore)
Moves it after itBefore.
Definition: List.h:1419
CONTAINER::iterator chooseIteratorFrom(CONTAINER &container, std::function< bool(const TYPE &)> includeElement=[](const TYPE &) { return true;}, bool isFastTest=true)
Returns an iterator to a random element in the container.
void conc(ListPure< E > &L2)
Appends L2 to this list and makes L2 empty.
Definition: List.h:927
void moveToSucc(iterator it, ListPure< E > &L2, iterator itBefore)
Moves it to list L2 and inserts it after itBefore.
Definition: List.h:877
const_iterator cyclicPred(const_iterator it) const
Returns a const iterator to the cyclic predecessor of it.
Definition: List.h:424
ListIteratorBase< E, isConst > pred() const
Returns predecessor iterator.
Definition: List.h:136
virtual int size() const
Returns the number of elements in the list.
Definition: List.h:243
ListIterator< E > search(const E &e)
Scans the list for the specified element and returns an iterator to the first occurrence in the list...
Definition: List.h:1071
ListElement(ListPure< E > *list, const E &x)
Constructs a ListElement.
Definition: List.h:68
bool operator==(const List< E > &L) const
Equality operator.
Definition: List.h:1286
void permute(INDEX l, INDEX r)
Randomly permutes the subarray with index set [l..r].
Definition: Array.h:326
iterator cyclicPred(iterator it)
Returns an iterator to the cyclic predecessor of it.
Definition: List.h:434
void del(iterator it)
Removes it from the list.
Definition: List.h:649
void popBack()
Removes the last element from the list.
Definition: List.h:1367
ListIteratorBase< E, isConst > succ() const
Returns successor iterator.
Definition: List.h:133
void bucketSort(int l, int h, BucketFunc< E > &f)
Sorts the list using bucket sort.
Definition: List.h:1494
List(std::initializer_list< E > init)
Constructs a doubly linked list containing the elements in init.
Definition: List.h:1232
ListElem * m_pX
pointer to list element
Definition: List.h:95
void del(iterator it)
Removes it from the list.
Definition: List.h:1380
ListIteratorBase< E, isConst > & operator=(const ListIteratorBase< E, isConst > &it)
Assignment operator.
Definition: List.h:142
ListPure(std::initializer_list< E > init)
Constructs a doubly linked list containing the elements in init.
Definition: List.h:207
const_reference chooseElement(std::function< bool(const E &)> includeElement=[](const E &) { return true;}, bool isFastTest=true) const
Returns a random element.
Definition: List.h:1153
void moveToBack(iterator it, List< E > &L2)
Moves it to the end of the list.
Definition: List.h:1413
long unsigned int randomSeed()
Returns a random value suitable as initial seed for a random number engine.
reference front()
Returns a reference to the first element.
Definition: List.h:263
ListElement< E > * m_next
Pointer to successor element.
Definition: List.h:53
void reverse()
Reverses the order of the list elements.
Definition: List.h:1044
ListIteratorBase< E, isConst > & operator--()
Decrement operator (prefix).
Definition: List.h:161
void quicksort(const COMPARER &comp)
Sorts the list using Quicksort and comparer comp.
Definition: List.h:1103
void quicksort()
Sorts the list using Quicksort.
Definition: List.h:1097
const ListPure< E > & getListPure() const
Conversion to const ListPure.
Definition: List.h:1258
reference chooseElement(std::function< bool(const E &)> includeElement=[](const E &) { return true;}, bool isFastTest=true)
Returns a random element.
Definition: List.h:1162
ListIterator< E > search(const E &e, const COMPARER &comp)
Scans the list for the specified element (using the user-defined comparer) and returns an iterator to...
Definition: List.h:1089
iterator pushFront(const E &x)
Adds element x at the beginning of the list.
Definition: List.h:1303
bool operator!=(const ListPure< E > &L) const
Inequality operator.
Definition: List.h:480
iterator emplaceBack(Args &&... args)
Adds a new element at the end of the list.
Definition: List.h:530
reference back()
Returns a reference to the last element.
Definition: List.h:281
iterator rend() const
Returns an iterator to the one-before-first element in the container.
Definition: List.h:1604
static void copy(const T &from, T &to)
Definition: Alg.h:61
const_reference front() const
Returns a const reference to the first element.
Definition: List.h:254
iterator emplaceFront(Args &&... args)
Adds a new element at the beginning of the list.
Definition: List.h:506
iterator end() const
Returns an iterator to the one-past-last element in the container.
Definition: List.h:1598
void swap(List< E > &other)
Exchanges the contents of this list and other in constant time.
Definition: List.h:1445
void moveToPrec(iterator it, iterator itAfter)
Moves it before itAfter.
Definition: List.h:801
List(List< E > &&L)
Constructs a doubly linked list containing the elements of L (move semantics).
Definition: List.h:1241
void swap(ListPure< E > &other)
Exchanges the contents of this list and other in constant time.
Definition: List.h:961
ListElement(ListPure< E > *list, const E &x, ListElement< E > *next, ListElement< E > *prev)
Constructs a ListElement.
Definition: List.h:61
E popBackRet()
Removes the last element from the list and returns it.
Definition: List.h:639
E m_x
Stores the content.
Definition: List.h:55
Doubly linked lists (maintaining the length of the list).
Definition: List.h:39
ListPure(const ListPure< E > &L)
Constructs a doubly linked list that is a copy of L.
Definition: List.h:213
Structure for elements of doubly linked lists.
Definition: List.h:47
iterator end()
Returns an iterator to one-past-last element of the list.
Definition: List.h:350
void clear()
Removes all elements from the list.
Definition: List.h:675
const_iterator cbegin() const
Returns a const iterator to the first element of the list.
Definition: List.h:344
Direction
Definition: basic.h:132
ListIteratorBase(const ListIteratorBase< E, isArgConst > &it)
Constructs an iterator that is a copy of it.
Definition: List.h:109
E popFrontRet()
Removes the first element from the list and returns it.
Definition: List.h:1360
void moveToBack(iterator it, ListPure< E > &L2)
Moves it to the end of L2.
Definition: List.h:851
void exchange(iterator it1, iterator it2)
Exchanges the positions of it1 and it2 in the list.
Definition: List.h:698
E popFrontRet()
Removes the first element from the list and returns it.
Definition: List.h:616
const_iterator begin() const
Returns a const iterator to the first element of the list.
Definition: List.h:338
Encapsulates a pointer to a list element.
Definition: List.h:41
#define OGDF_NEW_DELETE
Makes the class use OGDF&#39;s memory allocator.
Definition: memory.h:84
const T & move(const T &v)
Definition: backward.hpp:243
void reassignListRefs(ListElement< E > *start=nullptr)
Sets the debug reference of all list elements starting at start to this.
Definition: List.h:1196
Implementation of algorithms as templates working with different list types.
iterator insert(const E &x, iterator it, Direction dir=Direction::after)
Inserts element x before or after it.
Definition: List.h:1329
Abstract base class for bucket functions.
Definition: basic.h:255
iterator insert(const E &x, iterator it, Direction dir=Direction::after)
Inserts element x before or after it.
Definition: List.h:547
void bucketSort(Array< E > &a, int min, int max, BucketFunc< E > &f)
Bucket-sort array a using bucket assignment f; the values of f must be in the interval [min...
Definition: SList.h:1093
iterator rbegin() const
Returns an iterator to the last element in the container.
Definition: List.h:1601
void moveToFront(iterator it, List< E > &L2)
Moves it to the begin of the list.
Definition: List.h:1407
iterator insertBefore(const E &x, iterator it)
Inserts element x before it.
Definition: List.h:568
Elem & operator*() const
Returns a reference to the element content.
Definition: List.h:139
typename std::conditional< isConst, const ogdf::ClusterGraphObserver *, ogdf::ClusterGraphObserver * >::type Elem
The underlying type, depending on isConst.
Definition: List.h:92
int pos(const_iterator it) const
Returns the position (starting with 0) of iterator it in the list.
Definition: List.h:312
bool removeFirst(const E &x)
Removes the first occurrence of x (if any) from the list.
Definition: List.h:1386
void moveToFront(iterator it, ListPure< E > &L2)
Moves it to the begin of L2.
Definition: List.h:826
void moveToSucc(iterator it, iterator itBefore)
Moves it after itBefore.
Definition: List.h:776
iterator rbegin()
Returns an iterator to the last element of the list.
Definition: List.h:368
int size() const
Returns the number of elements in the list.
Definition: List.h:1255
void splitBefore(iterator it, ListPure< E > &L2)
Splits the list before it.
Definition: List.h:1028
const_iterator rend() const
Returns a const iterator to one-before-first element of the list.
Definition: List.h:392
E value_type
Represents the data type stored in a list element.
Definition: List.h:193
int m_count
The length of the list.
Definition: List.h:1219
List(const List< E > &L)
Constructs a doubly linked list that is a copy of L.
Definition: List.h:1235
void popFront()
Removes the first element from the list.
Definition: List.h:603
virtual int getBucket(const E &x)=0
Returns the bucket of x.
ListIteratorBase< E, isConst > & operator++()
Increment operator (prefix).
Definition: List.h:148
iterator emplaceFront(Args &&... args)
Adds a new element at the beginning of the list.
Definition: List.h:1310
virtual ~ListPure()
Destructor.
Definition: List.h:226
iterator insertBefore(const E &x, iterator it)
Inserts element x before it.
Definition: List.h:1335
const_iterator crend() const
Returns a const iterator to one-before-first element of the list.
Definition: List.h:398
const_iterator chooseIterator(std::function< bool(const E &)> includeElement=[](const E &) { return true;}, bool isFastTest=true) const
Returns an iterator to a random element.
Definition: List.h:1132
const_iterator end() const
Returns a const iterator to one-past-last element of the list.
Definition: List.h:356
void popBack()
Removes the last element from the list.
Definition: List.h:626
void concFront(List< E > &L2)
Prepends L2 to this list and makes L2 empty.
Definition: List.h:1438
List()
Constructs an empty doubly linked list.
Definition: List.h:1229
The namespace for all OGDF objects.
ListPure()
Constructs an empty doubly linked list.
Definition: List.h:204
void permute(RNG &rng)
Randomly permutes the elements in the list using random number generator rng.
Definition: List.h:1178
iterator insertAfter(const E &x, iterator it)
Inserts element x after it.
Definition: List.h:582
void copy(const ListPure< E > &L)
Definition: List.h:1185
List< E > & operator=(const List< E > &L)
Assignment operator.
Definition: List.h:1268
bool operator!=(const List< E > &L) const
Inequality operator.
Definition: List.h:1291
ListElement(ListPure< E > *list, ListElement< E > *next, ListElement< E > *prev, Args &&... args)
Constructs a ListElement with given arguments args for constructor of element type.
Definition: List.h:71
const_iterator crbegin() const
Returns a const iterator to the last element of the list.
Definition: List.h:380
ListConstIterator< E > search(const E &e) const
Scans the list for the specified element and returns an iterator to the first occurrence in the list...
Definition: List.h:1063
ListPure< E > & operator=(ListPure< E > &&L)
Assignment operator (move semantics).
Definition: List.h:458
ListElement< E > * m_head
Pointer to first element.
Definition: List.h:188
void print(ostream &os, const Array< E, INDEX > &a, char delim=' ')
Prints array a to output stream os using delimiter delim.
Definition: Array.h:753
bool operator==(const Tuple2< E1, E2 > &t1, const Tuple2< E1, E2 > &t2)
Equality operator for 2-tuples.
Definition: tuples.h:75
bool empty() const
Returns true iff the list is empty.
Definition: List.h:236
bool valid() const
Returns true iff the iterator points to an element.
Definition: List.h:112
int size() const
Returns the number of elements in the container.
Definition: List.h:1607
iterator rend()
Returns an iterator to one-before-first element of the list.
Definition: List.h:386
void moveToPrec(iterator it, ListPure< E > &L2, iterator itAfter)
Moves it to list L2 and inserts it before itAfter.
Definition: List.h:904
void permute()
Randomly permutes the elements in the list.
Definition: List.h:1171
#define OGDF_ASSERT(expr)
Assert condition expr. See doc/build.md for more information.
Definition: basic.h:41
const_iterator rbegin() const
Returns a const iterator to the last element of the list.
Definition: List.h:374
ListPure< E > & operator=(const ListPure< E > &L)
Assignment operator.
Definition: List.h:449
const_reference back() const
Returns a const reference to the last element.
Definition: List.h:272