|
Last change
on this file was
17180,
checked in by westram, 7 years ago
|
- full update from 'trunk' into 'alilink'
- fix reintegration problems
- adds:
|
|
File size:
1.6 KB
|
| Line | |
|---|
| 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 | |
|---|
| 15 | void collect_enclosing_groups(AP_tree *node, AP_tree_set& groups) { |
|---|
| 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 | } |
|---|
Note: See
TracBrowser
for help on using the repository browser.