-
Notifications
You must be signed in to change notification settings - Fork 31
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
Add sample program for iterators <-> paths, and documentation for it. Remove compiler warnings.
- Loading branch information
Showing
6 changed files
with
61 additions
and
6 deletions.
There are no files selected for viewing
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -1,3 +1,7 @@ | ||
2022-02-13 Kasper Peeters <[email protected]> | ||
|
||
* Include <string> to avoid compilation errors. | ||
|
||
2020-11-07 Kasper Peeters <[email protected]> | ||
|
||
* Release 3.17 | ||
|
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
|
@@ -4,3 +4,5 @@ test1 | |
test2 | ||
test3 | ||
test4 | ||
sample_path | ||
test_tree |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,27 @@ | ||
|
||
#include "tree.hh" | ||
#include <iostream> | ||
|
||
// Sample to demonstrate how to turn a tree iterator into a | ||
// path_t, which is a vector of integers indicating which | ||
// child is taken at any depth. | ||
|
||
int main(int argc, char **argv) | ||
{ | ||
tree<std::string> tr; | ||
|
||
tr.set_head("head"); | ||
auto i1 = tr.append_child(tr.begin(), "one"); | ||
auto i2 = tr.append_child(tr.begin(), "two"); | ||
auto i3 = tr.append_child(tr.begin(), "three"); | ||
auto i4 = tr.append_child(i2, "four"); | ||
auto i5 = tr.append_child(i2, "five"); | ||
|
||
auto path = tr.path_from_iterator(i5, tr.begin()); | ||
for(auto& p: path) | ||
std::cerr << p << "/"; | ||
std::cerr << std::endl; // prints '0/1/1/' | ||
|
||
auto fnd = tr.iterator_from_path(path, tr.begin()); | ||
std::cerr << *fnd << std::endl; // prints 'five' | ||
} |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters