ARB
AP_TreeSet.cxx
Go to the documentation of this file.
1 // =============================================================== //
2 // //
3 // File : AP_TreeSet.cxx //
4 // Purpose : function for sets of tree nodes //
5 // //
6 // Coded by Ralf Westram (coder@reallysoft.de) in January 2017 //
7 // http://www.arb-home.de/ //
8 // //
9 // =============================================================== //
10 
11 #include "AP_TreeSet.hxx"
12 
13 using namespace std;
14 
16  AP_tree *fnode = node->get_father();
17 
18  if (fnode && fnode->has_group_info() && !node->is_leaf() && node->is_keeled_group()) {
19  // do NOT add direct parent group to 'groups' (it's me!)
20  node = fnode;
21  fnode = node->get_father();
22  }
23 
24  while (fnode) {
25  if (fnode->has_group_info()) {
26  const TreeNode *keeledSon = fnode->keelTarget();
27  if (!keeledSon || keeledSon == node) {
28  groups.insert(fnode);
29  }
30  }
31  node = fnode;
32  fnode = node->get_father();
33  }
34 }
35 
36 void collect_contained_groups(AP_tree *node, AP_tree_set& groups) { // currently only used from testcode
37  if (!node->is_leaf()) {
38  if (node->has_group_info()) groups.insert(node);
39  collect_contained_groups(node->get_leftson(), groups);
40  collect_contained_groups(node->get_rightson(), groups);
41  }
42 }
bool has_group_info() const
Definition: TreeNode.h:403
std::set< AP_tree * > AP_tree_set
Definition: AP_TreeSet.hxx:21
STL namespace.
void collect_enclosing_groups(AP_tree *node, AP_tree_set &groups)
Definition: AP_TreeSet.cxx:15
bool is_keeled_group() const
Definition: TreeNode.h:434
bool is_leaf() const
Definition: TreeNode.h:171
void collect_contained_groups(AP_tree *node, AP_tree_set &groups)
Definition: AP_TreeSet.cxx:36
TreeNode * keelTarget()
Definition: TreeNode.h:407