{"id":20031747,"url":"https://github.com/astrodynamic/red-black-tree-library-in-cpp","last_synced_at":"2025-08-01T11:34:02.846Z","repository":{"id":162502170,"uuid":"637040324","full_name":"Astrodynamic/Red-black-tree-Library-in-CPP","owner":"Astrodynamic","description":"RBTree is a C++ template library for Red-Black Trees, a self-balancing binary search tree. It provides various methods to interact with the tree, including insertion, deletion, search, and iteration. The library is built using CMake and requires a C++17 compiler. To contribute to its development, clone the repository and submit a pull request.","archived":false,"fork":false,"pushed_at":"2023-05-06T10:29:24.000Z","size":9,"stargazers_count":0,"open_issues_count":0,"forks_count":0,"subscribers_count":1,"default_branch":"develop","last_synced_at":"2025-03-02T05:27:47.071Z","etag":null,"topics":["cmake","cpp","cpp17","header-only","header-only-library","library","makefile","stl-containers"],"latest_commit_sha":null,"homepage":"","language":"C++","has_issues":true,"has_wiki":null,"has_pages":null,"mirror_url":null,"source_name":null,"license":"mit","status":null,"scm":"git","pull_requests_enabled":true,"icon_url":"https://github.com/Astrodynamic.png","metadata":{"files":{"readme":"README.md","changelog":null,"contributing":null,"funding":null,"license":"LICENSE","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":"2023-05-06T10:17:37.000Z","updated_at":"2023-05-10T11:35:53.000Z","dependencies_parsed_at":null,"dependency_job_id":"e80a7a4f-241f-4699-adee-0612459f2b55","html_url":"https://github.com/Astrodynamic/Red-black-tree-Library-in-CPP","commit_stats":null,"previous_names":[],"tags_count":0,"template":false,"template_full_name":null,"purl":"pkg:github/Astrodynamic/Red-black-tree-Library-in-CPP","repository_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/Astrodynamic%2FRed-black-tree-Library-in-CPP","tags_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/Astrodynamic%2FRed-black-tree-Library-in-CPP/tags","releases_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/Astrodynamic%2FRed-black-tree-Library-in-CPP/releases","manifests_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/Astrodynamic%2FRed-black-tree-Library-in-CPP/manifests","owner_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/owners/Astrodynamic","download_url":"https://codeload.github.com/Astrodynamic/Red-black-tree-Library-in-CPP/tar.gz/refs/heads/develop","sbom_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/Astrodynamic%2FRed-black-tree-Library-in-CPP/sbom","host":{"name":"GitHub","url":"https://github.com","kind":"github","repositories_count":268215576,"owners_count":24214363,"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","status":"online","status_checked_at":"2025-08-01T02:00:08.611Z","response_time":67,"last_error":null,"robots_txt_status":"success","robots_txt_updated_at":"2025-07-24T06:49:26.215Z","robots_txt_url":"https://github.com/robots.txt","online":true,"can_crawl_api":true,"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":["cmake","cpp","cpp17","header-only","header-only-library","library","makefile","stl-containers"],"created_at":"2024-11-13T09:34:35.200Z","updated_at":"2025-08-01T11:34:02.790Z","avatar_url":"https://github.com/Astrodynamic.png","language":"C++","readme":"# RBTree Library\n\nRBTree is a C++ template library for working with Red-Black Trees. This README provides information on building and using the library, its dependencies, development, and licensing.\n\n## Build\n\nTo build the library, run the following commands:\n\n```\ncmake -S . -B ./build\ncmake --build ./build\n```\n\n## Usage\n\nTo use the library, include the header file `RBTree.h` and create an instance of the `RBTree` class.\n\n```cpp\n#include \u003ciostream\u003e\n#include \"RBTree.h\"\n\nint main() {\n    RBTree\u003cint\u003e tree;\n    tree.insert(1);\n    tree.insert(2);\n    tree.insert(3);\n    for (auto const\u0026 value: tree) {\n        std::cout \u003c\u003c value \u003c\u003c ' ';\n    }\n    return 0;\n}\n```\n\nThe RBTree class provides an implementation of a red-black tree, a self-balancing binary search tree. The following methods are available for the user to interact with:\n\n- `RBTree()`: Constructor that initializes an empty tree.\n- `RBTree(std::initializer_list\u003cT\u003e const \u0026list)`: Constructor that initializes the tree with the values from an initializer list.\n- `RBTree(const RBTree \u0026other)`: Copy constructor.\n- `RBTree(RBTree \u0026\u0026other) noexcept`: Move constructor.\n- `RBTree\u003cT\u003e \u0026operator=(const RBTree\u003cT\u003e \u0026other)`: Copy assignment operator.\n- `RBTree\u003cT\u003e \u0026operator=(RBTree\u003cT\u003e \u0026\u0026other)`: Move assignment operator.\n- `iterator begin() const`: Returns an iterator to the first element in the tree.\n- `iterator end() const`: Returns an iterator to the end of the tree.\n- `iterator find(const T \u0026value) const`: Returns an iterator to the node containing the given value, or end() if not found.\n- `iterator insert(const T \u0026value)`: Inserts a new node with the given value into the tree, and returns an iterator to the inserted node.\n- `size_t size() const`: Returns the number of elements in the tree.\n- `size_t max_size() const`: Returns the maximum number of elements the tree can hold.\n- `bool empty() const`: Returns true if the tree is empty, false otherwise.\n- `size_t count(const T \u0026key)`: Returns the number of nodes containing the given key in the tree.\n- `iterator lower_bound(const T \u0026value) const`: Returns an iterator to the first node with a value greater than or equal to the given value.\n- `iterator upper_bound(const T \u0026value) const`: Returns an iterator to the first node with a value strictly greater than the given value.\n- `std::pair\u003citerator, iterator\u003e equal_range(const T \u0026key)`: Returns a pair of iterators delimiting the range of nodes containing the given key.\n- `bool contains(const T \u0026value) const`: Returns true if the tree contains a node with the given value, false otherwise.\n- `void erase(iterator pos)`: Removes the node pointed to by the given iterator from the tree.\n- `void erase(const T \u0026value)`: Removes the node with the given value from the tree.\n- `void swap(RBTree \u0026other)`: Swaps the contents of this tree with another tree.\n- `void clear() noexcept`: Removes all nodes from the tree.\n- `void merge(RBTree \u0026other)`: Merges the contents of another tree with this tree.\n- `~RBTree()`: Destructor that deallocates all memory used by the tree.\n\nIn addition, the RBTree class provides several private helper methods for internal use, such as left_rotate, right_rotate, and insert_fixup.\n\n## Dependencies\n\nThe RBTree library depends on CMake 3.10 or later and a C++17 compiler.\n\n## Development\n\nTo contribute to the development of the RBTree library, clone the repository and submit a pull request. The library uses CMake for building and testing. You can run the following commands to run the tests:\n\n```\ncmake -S . -B ./build\ncmake --build ./build\ncd build/\nmake tests\n```\n\n## License\n\nThe RBTree library is licensed under the MIT License. See [LICENSE](LICENSE) for more information.","funding_links":[],"categories":[],"sub_categories":[],"project_url":"https://awesome.ecosyste.ms/api/v1/projects/github.com%2Fastrodynamic%2Fred-black-tree-library-in-cpp","html_url":"https://awesome.ecosyste.ms/projects/github.com%2Fastrodynamic%2Fred-black-tree-library-in-cpp","lists_url":"https://awesome.ecosyste.ms/api/v1/projects/github.com%2Fastrodynamic%2Fred-black-tree-library-in-cpp/lists"}