{"id":22376749,"url":"https://github.com/benami171/template_tree_container","last_synced_at":"2025-06-24T16:37:24.199Z","repository":{"id":246689229,"uuid":"816865811","full_name":"benami171/Template_Tree_Container","owner":"benami171","description":"Implementation of a template K-ary Tree container, with template iterators and template nodes. Used QT as GUI to print the tree.","archived":false,"fork":false,"pushed_at":"2024-09-15T15:10:25.000Z","size":1910,"stargazers_count":1,"open_issues_count":0,"forks_count":0,"subscribers_count":1,"default_branch":"main","last_synced_at":"2025-06-16T04:18:06.874Z","etag":null,"topics":["containers","cpp","gui","iterators","templates","tree-structure"],"latest_commit_sha":null,"homepage":"","language":"C++","has_issues":true,"has_wiki":null,"has_pages":null,"mirror_url":null,"source_name":null,"license":null,"status":null,"scm":"git","pull_requests_enabled":true,"icon_url":"https://github.com/benami171.png","metadata":{"files":{"readme":"README.md","changelog":null,"contributing":null,"funding":null,"license":null,"code_of_conduct":null,"threat_model":null,"audit":null,"citation":null,"codeowners":null,"security":null,"support":null,"governance":null,"roadmap":null,"authors":null,"dei":null,"publiccode":null,"codemeta":null}},"created_at":"2024-06-18T14:46:47.000Z","updated_at":"2024-09-15T15:10:28.000Z","dependencies_parsed_at":"2024-06-29T17:54:45.563Z","dependency_job_id":"6b57dcb0-e012-4c3b-81a1-ffa0b4a0ce24","html_url":"https://github.com/benami171/Template_Tree_Container","commit_stats":null,"previous_names":["benami171/system_programming2_exe4","benami171/template_tree_container"],"tags_count":0,"template":false,"template_full_name":null,"purl":"pkg:github/benami171/Template_Tree_Container","repository_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/benami171%2FTemplate_Tree_Container","tags_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/benami171%2FTemplate_Tree_Container/tags","releases_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/benami171%2FTemplate_Tree_Container/releases","manifests_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/benami171%2FTemplate_Tree_Container/manifests","owner_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/owners/benami171","download_url":"https://codeload.github.com/benami171/Template_Tree_Container/tar.gz/refs/heads/main","sbom_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/benami171%2FTemplate_Tree_Container/sbom","host":{"name":"GitHub","url":"https://github.com","kind":"github","repositories_count":261715356,"owners_count":23198747,"icon_url":"https://github.com/github.png","version":null,"created_at":"2022-05-30T11:31:42.601Z","updated_at":"2022-07-04T15:15:14.044Z","host_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub","repositories_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories","repository_names_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repository_names","owners_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/owners"}},"keywords":["containers","cpp","gui","iterators","templates","tree-structure"],"created_at":"2024-12-04T22:11:13.890Z","updated_at":"2025-06-24T16:37:24.145Z","avatar_url":"https://github.com/benami171.png","language":"C++","funding_links":[],"categories":[],"sub_categories":[],"readme":"# Iterators and Templates on trees.\nIn this project i implemented a template container that represents a K-ary tree that can hold Nodes of any type.\n\n## How to run:\n- run main program: in order to compile and run the program, type `qmake myProg.pro -config Prog` and than `make tree`.\n- run tests: in order to compile and run the tests, type `qmake myProg.pro -config Test` and than `make test`.\n\n## All the different classes and their hierarchy\n- `tree.hpp` - a Template K-ary tree container, has a `Node\u003cT\u003e* root`. uses the `iterators.hpp` to travers the tree in different ways (depends what K is the tree).\nthe `tree` class uses the `type_traits` library to use compile-time type manipulation based on certain conditions (see `Explenation about the tree container usage with iterators` below for additional explenation).\nIn order to print the tree using gui we used `QT` library.\n- `node.hpp` - a Template Node class to hold any type.\n- `complex.hpp` - represents complex numbers, can be used by `node.hpp` to store complex numbers as data.\n- We have 6 different iterator classes inside the file `iterators.hpp`:\n- `in_order_iterator` - Traverses Binary tree in in-order way, for any (K!=2)-Tree will travers the tree using dfs.\n- `pre_order_iterator` - Traverses Binary tree in pre-order way, for any (K!=2)-Tree will travers the tree using dfs.\n- `post_order_iterator` - Traverses Binary tree in post-order way, for any (K!=2)-Tree will travers the tree using dfs.\n- `min_heap_iterator` - Turns a Binary tree to a minimum heap and travers it ,for any (K!=2)-Tree will travers the tree using dfs.\n- `dfs_iterator` - Works on any K-tree.\n- `bfs_iterator` - Works on any K-tree.\n\n### Explenation about the tree container usage with iterators.\n- A template class that represents a K-ary tree (Binary by default), holds an access to the root node and its `K` value that represents the highest degree that a node can have in the tree.\n- during Compile-time the program will detect which type of tree the iterator gets called on, and if the iterators `in_order_iterator`, `pre_order_iterator` or `post_order_iterator` was called with a K!=2-Tree, it will direct the type of iterator to be `dfs_iterator` in Compile-time.\n\n- How it does it:\n- in the Tree class, we have used `type_traits` in this way:\n```cpp\n    using iterator_pre_order = typename std::conditional\u003cK == BINARY, pre_order_iterator\u003cT\u003e, dfs_iterator\u003cT\u003e\u003e::type;\n    using iterator_post_order = typename std::conditional\u003cK == BINARY, post_order_iterator\u003cT\u003e, dfs_iterator\u003cT\u003e\u003e::type;\n    using iterator_in_order = typename std::conditional\u003cK == BINARY, in_order_iterator\u003cT\u003e, dfs_iterator\u003cT\u003e\u003e::type;\n    using iterator_min_heap = typename std::conditional\u003cK == BINARY, min_heap_iterator\u003cT\u003e, dfs_iterator\u003cT\u003e\u003e::type;\n```\n\n- So for example when we call `in_order_iterator` in the main, on 3-Ary array :\n```cpp\n    Tree\u003cdouble, 3\u003e three_ary_tree;\n    for (auto node = three_ary_tree.begin_pre_order(); node != three_ary_tree.end_pre_order();++node) {\n        cout \u003c\u003c node-\u003eget_value() \u003c\u003c \" \";\n    }\n```\nIt will travers the tree using `bfs_iterator` and not `pre_order_iterator`.\n\n- For further information and usage examples check out `main.cpp` ,`tree.hpp` ,`node.hpp` ,`iterators.hpp` and `complex.hpp`.\n- You can see the different tests in the `test.cpp` class.\n\n\n","project_url":"https://awesome.ecosyste.ms/api/v1/projects/github.com%2Fbenami171%2Ftemplate_tree_container","html_url":"https://awesome.ecosyste.ms/projects/github.com%2Fbenami171%2Ftemplate_tree_container","lists_url":"https://awesome.ecosyste.ms/api/v1/projects/github.com%2Fbenami171%2Ftemplate_tree_container/lists"}