DeSiGNAR  0.5a
Data Structures General Library
nodesdef.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 DSGNODESDEF_H
26 # define DSGNODESDEF_H
27 
28 # include <types.H>
29 # include <iterator.H>
30 
31 namespace Designar
32 {
33 
34  template<typename T>
35  class SLNode
36  {
37  T item;
38  SLNode * next;
39 
40  public:
42  : item(), next(nullptr)
43  {
44  // empty
45  }
46 
47  SLNode(const T & i)
48  : item(i), next(nullptr)
49  {
50  // empty
51  }
52 
53  SLNode(T && i)
54  : item(std::forward<T>(i)), next(nullptr)
55  {
56  // empty
57  }
58 
59  SLNode(const SLNode &) = delete;
60 
61  SLNode & operator = (const SLNode &) = delete;
62 
63  bool is_empty() const
64  {
65  return next == nullptr;
66  }
67 
68  void reset()
69  {
70  next = nullptr;
71  }
72 
73  T & get_item()
74  {
75  return item;
76  }
77 
78  const T & get_item() const
79  {
80  return item;
81  }
82 
84  {
85  return next;
86  }
87 
88  const SLNode *& get_next() const
89  {
90  return next;
91  }
92 
93  void insert_next(SLNode * p)
94  {
95  assert(p != nullptr);
96  assert(p->is_empty());
97  p->next = next;
98  next = p;
99  }
100 
102  {
103  if (next == nullptr)
104  return nullptr;
105 
106  SLNode * ret_val = next;
107  next = ret_val->next;
108  ret_val->reset();
109  return ret_val;
110  }
111  };
112 
113  class DL
114  {
115  DL * next;
116  DL * prev;
117 
118  public:
119  DL()
120  : next(this), prev(this)
121  {
122  // empty
123  }
124 
125  DL(const DL &)
126  : DL()
127  {
128  // empty
129  }
130 
131  DL(DL && l)
132  : DL()
133  {
134  swap(l);
135  }
136 
137  DL & operator = (const DL &)
138  {
139  return *this;
140  }
141 
142  DL & operator = (DL && l)
143  {
144  swap(l);
145  return *this;
146  }
147 
148  void reset()
149  {
150  next = prev = this;
151  }
152 
153  bool is_empty() const
154  {
155  return next == prev and next == this;
156  }
157 
159  {
160  return next == prev;
161  }
162 
163  bool is_unitarian() const
164  {
165  return next == prev and next != this;
166  }
167 
169  {
170  return next;
171  }
172 
173  const DL *& get_next() const
174  {
175  return (const DL *&) next;
176  }
177 
179  {
180  return prev;
181  }
182 
183  const DL *& get_prev() const
184  {
185  return (const DL *&) prev;
186  }
187 
188  void insert_next(DL * node)
189  {
190  assert(node != nullptr);
191  assert(node->is_empty());
192  node->next = next;
193  node->prev = this;
194  next->prev = node;
195  next = node;
196  }
197 
198  void insert_prev(DL * node)
199  {
200  assert(node != nullptr);
201  assert(node->is_empty());
202  node->next = this;
203  node->prev = prev;
204  prev->next = node;
205  prev = node;
206  }
207 
208  void del()
209  {
210  next->prev = prev;
211  prev->next = next;
212  reset();
213  }
214 
216  {
217  DL * ret_val = next;
218  ret_val->del();
219  return ret_val;
220  }
221 
223  {
224  DL * ret_val = prev;
225  ret_val->del();
226  return ret_val;
227  }
228 
229  void swap(DL * node)
230  {
231  if (is_empty() and node->is_empty())
232  return;
233 
234  if (is_empty())
235  {
236  next = node->next;
237  prev = node->prev;
238  node->next->prev = node->prev->next = this;
239  node->reset();
240  return;
241  }
242 
243  if (node->is_empty())
244  {
245  node->next = next;
246  node->prev = prev;
247  next->prev = prev->next = node;
248  reset();
249  return;
250  }
251 
252  std::swap(next->prev, node->next->prev);
253  std::swap(prev->next, node->prev->next);
254  std::swap(next, node->next);
255  std::swap(prev, node->prev);
256  }
257 
258  void swap(DL & node)
259  {
260  swap(&node);
261  }
262 
263  void concat(DL * l)
264  {
265  if (l->is_empty())
266  return;
267 
268  if (this->is_empty())
269  {
270  this->next = l->next;
271  l->next->prev = this;
272  this->prev = l->prev;
273  l->prev->next = this;
274  }
275  else
276  {
277  this->prev->next = l->next;
278  l->next->prev = this->prev;
279  l->prev->next = this;
280  this->prev = l->prev;
281  }
282 
283  l->reset();
284  }
285 
286  void concat(DL & l)
287  {
288  concat(&l);
289  }
290 
291  void split(DL &, DL &);
292 
293  class Iterator
294  {
295  DL * head;
296  DL * curr;
297 
298  protected:
299  DL * get_head() const
300  {
301  return head;
302  }
303 
304  DL * get_location() const
305  {
306  return curr;
307  }
308 
309  public:
311  : head(nullptr), curr(nullptr)
312  {
313  // empty
314  }
315 
317  : head(h), curr(h->get_next())
318  {
319  // empty
320  }
321 
322  Iterator(DL * h, DL * c)
323  : head(h), curr(c)
324  {
325  // empty
326  }
327 
328  Iterator(const Iterator & it)
329  : head(it.head), curr(it.curr)
330  {
331  // empty
332  }
333 
335  : Iterator()
336  {
337  swap(it);
338  }
339 
341  {
342  if (this == &it)
343  return *this;
344 
345  head = it.head;
346  curr = it.curr;
347  return *this;
348  }
349 
351  {
352  swap(it);
353  return *this;
354  }
355 
356  void swap(Iterator & it)
357  {
358  std::swap(head, it.head);
359  std::swap(curr, it.curr);
360  }
361 
362  bool has_current() const
363  {
364  return curr != head;
365  }
366 
368  {
369  if (not has_current())
370  throw std::overflow_error("There is not current element");
371 
372  return curr;
373  }
374 
375  DL * get_current() const
376  {
377  if (not has_current())
378  throw std::overflow_error("There is not current element");
379 
380  return curr;
381  }
382 
383  void next()
384  {
385  if (not has_current())
386  return;
387 
388  curr = curr->get_next();
389  }
390 
391  void prev()
392  {
393  if (curr == head->get_next())
394  return;
395 
396  curr = curr->get_prev();
397  }
398 
399  void reset()
400  {
401  curr = head->get_next();
402  }
403 
404  DL * del()
405  {
406  DL * ret_val = curr;
407  curr = curr->get_next();
408  ret_val->del();
409  return ret_val;
410  }
411  };
412  };
413 
414  template <typename T>
415  class DLNode : public DL
416  {
417  T item;
418 
419  public:
421  : DL(), item()
422  {
423  // item
424  }
425 
426  DLNode(const T & i)
427  : DL(), item(i)
428  {
429  // empty
430  }
431 
432  DLNode(T && i)
433  : DL(), item(std::forward<T>(i))
434  {
435  // empty
436  }
437 
438  DLNode(const DLNode &) = delete;
439 
441  : DLNode()
442  {
443  DL::swap(n);
444  }
445 
446  DLNode & operator = (const DLNode &) = delete;
447 
449  {
450  DL::swap(n);
451  return *this;
452  }
453 
454  T & get_item()
455  {
456  return item;
457  }
458 
459  const T & get_item() const
460  {
461  return item;
462  }
463 
465  {
466  return (DLNode *&) DL::get_next();
467  }
468 
469  const DLNode *& get_next() const
470  {
471  return (const DLNode *&) DL::get_next();
472  }
473 
475  {
476  return (DLNode *&) DL::get_prev();
477  }
478 
479  const DLNode *& get_prev() const
480  {
481  return (const DLNode *&) DL::get_prev();
482  }
483 
485  {
486  return static_cast<DLNode *>(DL::remove_next());
487  }
488 
490  {
491  return static_cast<DLNode *>(DL::remove_prev());
492  }
493 
494  class Iterator : public DL::Iterator
495  {
496  using Base = DL::Iterator;
497  using Base::Base;
498 
499  public:
501  {
502  return static_cast<DLNode *>(Base::get_current());
503  }
504 
505  DLNode * get_current() const
506  {
507  return static_cast<DLNode *>(Base::get_current());
508  }
509 
511  {
512  return static_cast<DLNode *>(Base::del());
513  }
514 
515  DLNode * operator * ()
516  {
517  return get_current();
518  }
519 
520  DLNode * operator * () const
521  {
522  return get_current();
523  }
524  };
525  };
526 
527  template <typename Key>
528  class MTreeNode : private DLNode<Key>
529  {
530  struct SiblingInfo
531  {
532  unsigned int is_leftmost : 4;
533  unsigned int is_rightmost : 4;
534 
535  SiblingInfo()
536  : is_leftmost(true), is_rightmost(true)
537  {
538  // empty
539  }
540  };
541 
542  MTreeNode * parent = nullptr;
543  MTreeNode * first_child = nullptr;
544  SiblingInfo sibling_info;
545 
546  using Base = DLNode<Key>;
547 
548  static MTreeNode * to_treenode(Base * p)
549  {
550  return static_cast<MTreeNode *>(p);
551  }
552 
553  void insert_first_child(MTreeNode * c)
554  {
555  assert(first_child == nullptr);
556  c->parent = this;
557  first_child = c;
558  }
559 
560  public:
561  using KeyType = Key;
562  using ValueType = Key;
563  using ItemType = Key;
564 
565  MTreeNode() = default;
566 
567  MTreeNode(const Key & k)
568  : Base(k)
569  {
570  // empty
571  }
572 
573  MTreeNode(Key && k)
574  : Base(std::forward<Key>(k))
575  {
576  // empty
577  }
578 
579  Key & get_key()
580  {
581  return Base::get_item();
582  }
583 
584  const Key & get_key() const
585  {
586  return Base::get_item();
587  }
588 
590  {
591  return first_child;
592  }
593 
595  {
596  if (first_child == nullptr)
597  return nullptr;
598 
599  return to_treenode(first_child->get_prev());
600  }
601 
603  {
604  if (sibling_info.is_rightmost)
605  return nullptr;
606 
607  return to_treenode(const_cast<Base *>(Base::get_next()));
608  }
609 
611  {
612  if (sibling_info.is_leftmost)
613  return nullptr;
614 
615  return to_treenode(const_cast<Base *>(Base::get_prev()));
616  }
617 
618  bool is_leaf() const
619  {
620  return first_child == nullptr;
621  }
622 
623  bool has_siblings() const
624  {
625  return not Base::is_empty();
626  }
627 
628  bool has_parent() const
629  {
630  return parent != nullptr;
631  }
632 
633  bool has_children() const
634  {
635  return first_child != nullptr;
636  }
637 
639  {
640  sibling_info.is_leftmost = sibling_info.is_rightmost = true;
641  }
642 
643  void reset()
644  {
645  Base::reset();
646  parent = first_child = nullptr;
647  reset_sibling_info();
648  }
649 
651  {
652  assert(s != nullptr);
653  assert(not s->has_siblings());
654  assert(not s->has_parent());
655  Base::insert_next(s);
656  s->sibling_info.is_rightmost = sibling_info.is_rightmost;
657  s->sibling_info.is_leftmost = false;
658  sibling_info.is_rightmost = false;
659  s->parent = parent;
660  }
661 
663  {
664  assert(s != nullptr);
665  assert(not s->has_siblings());
666  assert(not s->has_parent());
667  Base::insert_prev(s);
668  s->sibling_info.is_leftmost = sibling_info.is_leftmost;
669  s->sibling_info.is_rightmost = false;
670  sibling_info.is_leftmost = false;
671  s->parent = parent;
672 
673  if (s->sibling_info.is_leftmost and parent)
674  parent->first_child = s;
675  }
676 
678  {
679  assert(c != nullptr);
680  assert(not c->has_siblings());
681  assert(not c->has_parent());
682 
683  if (first_child == nullptr)
684  insert_first_child(c);
685  else
686  first_child->add_left_sibling(c);
687  }
688 
690  {
691  assert(c != nullptr);
692  assert(not c->has_siblings());
693  assert(not c->has_parent());
694 
695  if (first_child == nullptr)
696  insert_first_child(c);
697  else
698  to_treenode(first_child->get_prev())->add_right_sibling(c);
699  }
700 
702  {
703  if (first_child == nullptr)
704  return nullptr;
705 
706  MTreeNode * ret_val = first_child;
707 
708  if (ret_val->sibling_info.is_rightmost)
709  first_child = nullptr;
710  else
711  {
712  first_child = to_treenode(ret_val->get_next());
713  first_child->sibling_info.is_leftmost = true;
714  ret_val->del();
715  }
716 
717  ret_val->parent = nullptr;
718  ret_val->reset_sibling_info();
719  return ret_val;
720  }
721 
723  {
724  if (first_child == nullptr)
725  return nullptr;
726 
727  MTreeNode * ret_val = to_treenode(first_child->get_prev());
728 
729  if (ret_val->sibling_info.is_leftmost)
730  first_child = nullptr;
731  else
732  {
733  ret_val->get_left_sibling()->sibling_info.is_rightmost = true;
734  ret_val->del();
735  }
736 
737  ret_val->parent = nullptr;
738  ret_val->reset_sibling_info();
739  return ret_val;
740  }
741 
743  public BidirectionalIterator<ChildrenIterator, MTreeNode *, true>
744  {
745  friend class BasicIterator<ChildrenIterator, MTreeNode *, true>;
746 
747  MTreeNode * first;
748  MTreeNode * curr;
749  nat_t pos;
750 
751  protected:
753  {
754  return curr;
755  }
756 
757  public:
759  : first(nullptr), curr(nullptr)
760  {
761  // empty
762  }
763 
765  : first(const_cast<MTreeNode *>(&node)->get_first_child()),
766  curr(first), pos(0)
767  {
768  // empty
769  }
770 
772  : first(it.first), curr(it.curr), pos(it.pos)
773  {
774  // empty
775  }
776 
778  : ChildrenIterator()
779  {
780  swap(it);
781  }
782 
784  {
785  if (this == &it)
786  return *this;
787 
788  first = it.first;
789  curr = it.curr;
790  pos = it.pos;
791 
792  return *this;
793  }
794 
796  {
797  swap(it);
798  return *this;
799  }
800 
802  {
803  std::swap(first, it.first);
804  std::swap(curr, it.curr);
805  std::swap(pos, it.pos);
806  }
807 
809  {
810  return pos;
811  }
812 
813  bool has_current() const
814  {
815  return curr != nullptr;
816  }
817 
819  {
820  if (not has_current())
821  throw std::overflow_error("There is not current element");
822 
823  return curr;
824  }
825 
827  {
828  if (not has_current())
829  throw std::overflow_error("There is not current element");
830 
831  return curr;
832  }
833 
834  void next()
835  {
836  if (not has_current())
837  throw std::out_of_range("There is not next element");
838 
839  ++pos;
840  curr = curr->get_right_sibling();
841  }
842 
843  void prev()
844  {
845  if (curr == first)
846  throw std::out_of_range("There is not previous element");
847 
848  --pos;
849 
850  if (curr == nullptr)
851  curr = to_treenode(first->get_prev());
852  else
853  curr = curr->get_left_sibling();
854  }
855  };
856 
857  template <class Op>
858  void for_each_child(Op &) const;
859 
860  template <class Op>
861  void for_each_child(Op && op = Op()) const
862  {
863  for_each_child<Op>(op);
864  }
865 
866  static void destroy_tree(MTreeNode *&);
867  };
868 
869  template <typename Key>
870  template <class Op>
871  void MTreeNode<Key>::for_each_child(Op & op) const
872  {
873  MTreeNode * ptr = first_child;
874 
875  while (ptr != nullptr)
876  {
877  op(ptr);
878  ptr = ptr->get_right_sibling();
879  }
880  }
881 
882  template <typename Key>
884  {
885  if (r == nullptr)
886  return;
887 
888  MTreeNode * fc = nullptr;
889 
890  while ((fc = r->remove_first_child()))
891  destroy_tree(fc);
892 
893  delete r;
894  r = nullptr;
895  }
896 
898 
900 
901  template <typename Key, class DerivedNodeType, BinTreeNodeNullValue NULL_VALUE>
903  {
904  static DerivedNodeType sentinel_node;
905 
906  public:
907  using KeyType = Key;
908 
909  static DerivedNodeType * const null;
910 
911  private:
912  Key key;
913  DerivedNodeType * lchild;
914  DerivedNodeType * rchild;
915 
916  public:
918  : key(), lchild(null), rchild(null)
919  {
920  // empty
921  }
922 
923  BaseBinTreeNode(const Key & k)
924  : key(k), lchild(null), rchild(null)
925  {
926  // empty
927  }
928 
929  BaseBinTreeNode(Key && k)
930  : key(std::forward<Key>(k)), lchild(null), rchild(null)
931  {
932  // empty
933  }
934 
936  : BaseBinTreeNode()
937  {
938  // empty
939  }
940 
941  BaseBinTreeNode(const BaseBinTreeNode &) = delete;
942 
943  BaseBinTreeNode & operator = (const BaseBinTreeNode &) = delete;
944 
945  Key & get_key()
946  {
947  return key;
948  }
949 
950  const Key & get_key() const
951  {
952  return key;
953  }
954 
955  DerivedNodeType *& get_lchild()
956  {
957  return lchild;
958  }
959 
960  DerivedNodeType *& get_rchild()
961  {
962  return rchild;
963  }
964 
965  void reset()
966  {
967  lchild = rchild = null;
968  }
969  };
970 
971  template <typename Key, class DerivedNodeType, BinTreeNodeNullValue NULL_VALUE>
974 
975  template <typename Key, class DerivedNodeType, BinTreeNodeNullValue NULL_VALUE>
976  DerivedNodeType * const
978  NULL_VALUE == BinTreeNodeNullValue::NULLPTR ? nullptr : &sentinel_node;
979 
980  template <class BinTreeNode>
981  inline typename BinTreeNode::KeyType & KEY(BinTreeNode * p)
982  {
983  return p->get_key();
984  }
985 
986  template <class BinTreeNode>
987  inline BinTreeNode *& L(BinTreeNode * p)
988  {
989  return p->get_lchild();
990  }
991 
992  template <class BinTreeNode>
993  inline BinTreeNode *& R(BinTreeNode * p)
994  {
995  return p->get_rchild();
996  }
997 
998  template <typename NodeInfo, class CommonGraphNodeArc>
999  class BaseGraphNode : public CommonGraphNodeArc
1000  {
1001  protected:
1002  NodeInfo info;
1005 
1007  : CommonGraphNodeArc(), info(), num_arcs(0), adjacent_arc_list()
1008  {
1009  // empty
1010  }
1011 
1012  BaseGraphNode(const NodeInfo & _info)
1013  : CommonGraphNodeArc(), info(_info), num_arcs(0), adjacent_arc_list()
1014  {
1015  // empty
1016  }
1017 
1018  BaseGraphNode(NodeInfo && _info)
1019  : CommonGraphNodeArc(), info(std::forward<NodeInfo>(_info)), num_arcs(0),
1020  adjacent_arc_list()
1021  {
1022  // empty
1023  }
1024 
1026  : CommonGraphNodeArc(), info(ptr->info), num_arcs(0), adjacent_arc_list()
1027  {
1028  // empty
1029  }
1030 
1031  public:
1032  NodeInfo & get_info()
1033  {
1034  return info;
1035  }
1036 
1037  const NodeInfo & get_info() const
1038  {
1039  return info;
1040  }
1041 
1043  {
1044  return num_arcs;
1045  }
1046  };
1047 
1048  template <class GraphNode, typename ArcInfo, class CommonGraphNodeArc>
1049  class BaseGraphArc : public CommonGraphNodeArc
1050  {
1051  protected:
1054  ArcInfo info;
1055 
1057  : src_node(nullptr), tgt_node(nullptr), info()
1058  {
1059  // empty
1060  }
1061 
1063  : src_node(src), tgt_node(tgt), info()
1064  {
1065  // empty
1066  }
1067 
1068  BaseGraphArc(GraphNode * src, GraphNode * tgt, const ArcInfo & _info)
1069  : src_node(src), tgt_node(tgt), info(_info)
1070  {
1071  // empty
1072  }
1073 
1074  BaseGraphArc(GraphNode * src, GraphNode * tgt, ArcInfo && _info)
1075  : src_node(src), tgt_node(tgt), info(std::forward<ArcInfo>(_info))
1076  {
1077  // empty
1078  }
1079 
1080  public:
1082  {
1083  return src_node;
1084  }
1085 
1087  {
1088  return src_node;
1089  }
1090 
1092  {
1093  return tgt_node;
1094  }
1095 
1097  {
1098  return tgt_node;
1099  }
1100 
1102  {
1103  if (node == get_src_node())
1104  return get_tgt_node();
1105 
1106  if (node == get_tgt_node())
1107  return get_src_node();
1108 
1109  throw std::logic_error("Arc is not adjacent to node");
1110  }
1111 
1113  {
1114  if (node == get_src_node())
1115  return get_tgt_node();
1116 
1117  if (node == get_tgt_node())
1118  return get_src_node();
1119 
1120  throw std::logic_error("Arc is not adjacent to node");
1121  }
1122 
1123  ArcInfo & get_info()
1124  {
1125  return info;
1126  }
1127 
1128  const ArcInfo & get_info() const
1129  {
1130  return info;
1131  }
1132  };
1133 
1134 } // end namespace Designar
1135 
1136 # endif // DSGNODESDEF_H
BaseGraphArc(GraphNode *src, GraphNode *tgt, const ArcInfo &_info)
Definition: nodesdef.H:1068
DL * remove_prev()
Definition: nodesdef.H:222
void swap(DL &node)
Definition: nodesdef.H:258
void insert_child(MTreeNode *c)
Definition: nodesdef.H:677
static DerivedNodeType *const null
Definition: nodesdef.H:909
BaseGraphNode(NodeInfo &&_info)
Definition: nodesdef.H:1018
DLNode * remove_next()
Definition: nodesdef.H:484
Key & get_key()
Definition: nodesdef.H:579
BaseGraphNode()
Definition: nodesdef.H:1006
const Key & get_key() const
Definition: nodesdef.H:950
Definition: nodesdef.H:999
ArcInfo info
Definition: nodesdef.H:1054
DL * get_head() const
Definition: nodesdef.H:299
NodeInfo & get_info()
Definition: nodesdef.H:1032
BaseGraphNode(const NodeInfo &_info)
Definition: nodesdef.H:1012
DLNode *& get_prev()
Definition: nodesdef.H:474
BaseBinTreeNode()
Definition: nodesdef.H:917
BaseGraphArc(GraphNode *src, GraphNode *tgt)
Definition: nodesdef.H:1062
Iterator()
Definition: nodesdef.H:310
GraphNode * get_src_node() const
Definition: nodesdef.H:1086
BaseBinTreeNode(Key &&k)
Definition: nodesdef.H:929
bool is_empty() const
Definition: nodesdef.H:153
Iterator(const Iterator &it)
Definition: nodesdef.H:328
DLNode * del()
Definition: nodesdef.H:510
Definition: nodesdef.H:113
MTreeNode * get_left_sibling() const
Definition: nodesdef.H:610
SLNode *& get_next()
Definition: nodesdef.H:83
T & get_item()
Definition: nodesdef.H:454
static void destroy_tree(MTreeNode *&)
Definition: nodesdef.H:883
void next()
Definition: nodesdef.H:383
DerivedNodeType *& get_lchild()
Definition: nodesdef.H:955
DLNode * remove_prev()
Definition: nodesdef.H:489
MTreeNode * get_current()
Definition: nodesdef.H:818
SLNode & operator=(const SLNode &)=delete
void append_child(MTreeNode *c)
Definition: nodesdef.H:689
bool has_current() const
Definition: nodesdef.H:813
void concat(DL &l)
Definition: nodesdef.H:286
void prev()
Definition: nodesdef.H:391
Definition: iterator.H:36
DLNode(const T &i)
Definition: nodesdef.H:426
DL * get_current() const
Definition: nodesdef.H:375
bool is_unitarian_or_empty() const
Definition: nodesdef.H:158
Key & get_key()
Definition: nodesdef.H:945
void insert_next(DL *node)
Definition: nodesdef.H:188
void insert_next(SLNode *p)
Definition: nodesdef.H:93
DL * del()
Definition: nodesdef.H:404
GraphNode * get_tgt_node()
Definition: nodesdef.H:1091
BinTreeNode *& R(BinTreeNode *p)
Definition: nodesdef.H:993
bool is_empty() const
Definition: nodesdef.H:63
BaseBinTreeNode(BinTreeNodeCtor)
Definition: nodesdef.H:935
GraphNode * src_node
Definition: nodesdef.H:1052
BaseGraphArc()
Definition: nodesdef.H:1056
Definition: nodesdef.H:902
GraphNode * get_tgt_node() const
Definition: nodesdef.H:1096
const T & get_item() const
Definition: nodesdef.H:78
const DL *& get_prev() const
Definition: nodesdef.H:183
T & get_item()
Definition: nodesdef.H:73
nat_t num_arcs
Definition: nodesdef.H:1003
const DLNode *& get_prev() const
Definition: nodesdef.H:479
void reset_sibling_info()
Definition: nodesdef.H:638
DL *& get_prev()
Definition: nodesdef.H:178
ChildrenIterator(const ChildrenIterator &it)
Definition: nodesdef.H:771
void del()
Definition: nodesdef.H:208
ArcInfo & get_info()
Definition: nodesdef.H:1123
Definition: nodesdef.H:742
nat_t get_position() const
Definition: nodesdef.H:808
Iterator(DL *h)
Definition: nodesdef.H:316
DL()
Definition: nodesdef.H:119
BaseGraphArc(GraphNode *src, GraphNode *tgt, ArcInfo &&_info)
Definition: nodesdef.H:1074
const ArcInfo & get_info() const
Definition: nodesdef.H:1128
void reset()
Definition: nodesdef.H:643
Key & key(MapKey< Key, Value > &item)
Definition: map.H:53
SLNode()
Definition: nodesdef.H:41
void reset()
Definition: nodesdef.H:965
bool is_unitarian() const
Definition: nodesdef.H:163
bool is_leaf() const
Definition: nodesdef.H:618
void add_left_sibling(MTreeNode *s)
Definition: nodesdef.H:662
BinTreeNodeNullValue
Definition: nodesdef.H:899
MTreeNode * remove_first_child()
Definition: nodesdef.H:701
void for_each_child(Op &&op=Op()) const
Definition: nodesdef.H:861
void for_each_child(Op &) const
Definition: nodesdef.H:871
Key KeyType
Definition: nodesdef.H:561
BinTreeNode *& L(BinTreeNode *p)
Definition: nodesdef.H:987
bool has_current() const
Definition: nodesdef.H:362
SLNode(T &&i)
Definition: nodesdef.H:53
DLNode(DLNode &&n)
Definition: nodesdef.H:440
ChildrenIterator(const MTreeNode &node)
Definition: nodesdef.H:764
DLNode * get_current() const
Definition: nodesdef.H:505
Definition: nodesdef.H:415
GraphNode * get_src_node()
Definition: nodesdef.H:1081
const SLNode *& get_next() const
Definition: nodesdef.H:88
MTreeNode * get_first_child() const
Definition: nodesdef.H:589
void swap(Iterator &it)
Definition: nodesdef.H:356
void reset()
Definition: nodesdef.H:68
GraphNode * get_connected_node(GraphNode *node)
Definition: nodesdef.H:1101
BaseBinTreeNode(const Key &k)
Definition: nodesdef.H:923
Definition: nodesdef.H:494
Key ValueType
Definition: nodesdef.H:562
DLNode * get_current()
Definition: nodesdef.H:500
MTreeNode(Key &&k)
Definition: nodesdef.H:573
MTreeNode * get_last_child() const
Definition: nodesdef.H:594
DL * remove_next()
Definition: nodesdef.H:215
DLNode *& get_next()
Definition: nodesdef.H:464
NodeInfo info
Definition: nodesdef.H:1002
SLNode(const T &i)
Definition: nodesdef.H:47
BinTreeNode::KeyType & KEY(BinTreeNode *p)
Definition: nodesdef.H:981
BinTreeNodeCtor
Definition: nodesdef.H:897
BaseGraphNode(BaseGraphNode *ptr)
Definition: nodesdef.H:1025
Definition: iterator.H:112
DerivedNodeType *& get_rchild()
Definition: nodesdef.H:960
DL * get_location() const
Definition: nodesdef.H:304
DL(const DL &)
Definition: nodesdef.H:125
MTreeNode * get_current() const
Definition: nodesdef.H:826
bool has_parent() const
Definition: nodesdef.H:628
const Key & get_key() const
Definition: nodesdef.H:584
Definition: array.H:32
Iterator(Iterator &&it)
Definition: nodesdef.H:334
unsigned long int nat_t
Definition: types.H:50
MTreeNode * get_right_sibling() const
Definition: nodesdef.H:602
Key ItemType
Definition: nodesdef.H:563
const NodeInfo & get_info() const
Definition: nodesdef.H:1037
const DLNode *& get_next() const
Definition: nodesdef.H:469
DLNode(T &&i)
Definition: nodesdef.H:432
void swap(ChildrenIterator &it)
Definition: nodesdef.H:801
bool has_children() const
Definition: nodesdef.H:633
DLNode()
Definition: nodesdef.H:420
DL adjacent_arc_list
Definition: nodesdef.H:1004
Definition: nodesdef.H:35
void add_right_sibling(MTreeNode *s)
Definition: nodesdef.H:650
ChildrenIterator()
Definition: nodesdef.H:758
void reset()
Definition: nodesdef.H:148
Definition: graph.H:42
MTreeNode(const Key &k)
Definition: nodesdef.H:567
GraphNode * get_connected_node(GraphNode *node) const
Definition: nodesdef.H:1112
DL * get_current()
Definition: nodesdef.H:367
bool has_siblings() const
Definition: nodesdef.H:623
MTreeNode * remove_last_child()
Definition: nodesdef.H:722
Iterator(DL *h, DL *c)
Definition: nodesdef.H:322
MTreeNode * get_location() const
Definition: nodesdef.H:752
Definition: nodesdef.H:1049
Definition: nodesdef.H:528
DL(DL &&l)
Definition: nodesdef.H:131
void concat(DL *l)
Definition: nodesdef.H:263
void next()
Definition: nodesdef.H:834
const T & get_item() const
Definition: nodesdef.H:459
void prev()
Definition: nodesdef.H:843
void reset()
Definition: nodesdef.H:399
DL *& get_next()
Definition: nodesdef.H:168
SLNode * remove_next()
Definition: nodesdef.H:101
void insert_prev(DL *node)
Definition: nodesdef.H:198
Definition: nodesdef.H:293
const DL *& get_next() const
Definition: nodesdef.H:173
nat_t get_num_arcs() const
Definition: nodesdef.H:1042
ChildrenIterator(ChildrenIterator &&it)
Definition: nodesdef.H:777
void swap(DL *node)
Definition: nodesdef.H:229
GraphNode * tgt_node
Definition: nodesdef.H:1053