{"id":19389450,"url":"https://github.com/linksplatform/trees-rs","last_synced_at":"2026-04-02T17:04:18.978Z","repository":{"id":49952180,"uuid":"518474654","full_name":"linksplatform/trees-rs","owner":"linksplatform","description":null,"archived":false,"fork":false,"pushed_at":"2026-03-24T14:04:06.000Z","size":124,"stargazers_count":0,"open_issues_count":1,"forks_count":0,"subscribers_count":1,"default_branch":"main","last_synced_at":"2026-03-25T11:53:18.920Z","etag":null,"topics":[],"latest_commit_sha":null,"homepage":null,"language":"Rust","has_issues":true,"has_wiki":null,"has_pages":null,"mirror_url":null,"source_name":null,"license":"unlicense","status":null,"scm":"git","pull_requests_enabled":true,"icon_url":"https://github.com/linksplatform.png","metadata":{"files":{"readme":"README.md","changelog":"changelog.d/20251228_012915_test_coverage_and_ci.md","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,"zenodo":null,"notice":null,"maintainers":null,"copyright":null,"agents":null,"dco":null,"cla":null}},"created_at":"2022-07-27T13:42:05.000Z","updated_at":"2026-03-24T14:04:13.000Z","dependencies_parsed_at":"2023-11-27T16:41:33.391Z","dependency_job_id":null,"html_url":"https://github.com/linksplatform/trees-rs","commit_stats":null,"previous_names":[],"tags_count":2,"template":false,"template_full_name":null,"purl":"pkg:github/linksplatform/trees-rs","repository_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/linksplatform%2Ftrees-rs","tags_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/linksplatform%2Ftrees-rs/tags","releases_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/linksplatform%2Ftrees-rs/releases","manifests_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/linksplatform%2Ftrees-rs/manifests","owner_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/owners/linksplatform","download_url":"https://codeload.github.com/linksplatform/trees-rs/tar.gz/refs/heads/main","sbom_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/linksplatform%2Ftrees-rs/sbom","scorecard":null,"host":{"name":"GitHub","url":"https://github.com","kind":"github","repositories_count":286080680,"owners_count":31168414,"icon_url":"https://github.com/github.png","version":null,"created_at":"2022-05-30T11:31:42.601Z","updated_at":"2026-03-29T21:28:10.185Z","status":"ssl_error","status_checked_at":"2026-03-29T21:23:32.226Z","response_time":89,"last_error":"SSL_connect returned=1 errno=0 peeraddr=140.82.121.5:443 state=error: unexpected eof while reading","robots_txt_status":"success","robots_txt_updated_at":"2025-07-24T06:49:26.215Z","robots_txt_url":"https://github.com/robots.txt","online":false,"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":[],"created_at":"2024-11-10T10:16:17.689Z","updated_at":"2026-04-02T17:04:18.971Z","avatar_url":"https://github.com/linksplatform.png","language":"Rust","funding_links":[],"categories":[],"sub_categories":[],"readme":"[![Unlicense](https://img.shields.io/badge/license-Unlicense-blue.svg)](http://unlicense.org/)\n[![Crates.io](https://img.shields.io/crates/v/platform-trees?label=crates.io\u0026style=flat)](https://crates.io/crates/platform-trees)\n[![CI/CD Pipeline](https://github.com/linksplatform/trees-rs/workflows/CI%2FCD%20Pipeline/badge.svg)](https://github.com/linksplatform/trees-rs/actions?workflow=CI%2FCD+Pipeline)\n[![Docs.rs](https://docs.rs/platform-trees/badge.svg)](https://docs.rs/platform-trees)\n\n# [Trees](https://github.com/linksplatform/trees-rs) for Rust\n\nLinksPlatform's `platform-trees` crate — tree and linked list data\nstructure traits for the Links platform.\n\nCrates.io package: [platform-trees](https://crates.io/crates/platform-trees)\n\n## Overview\n\nThis crate provides generic traits for size-balanced binary trees and\ncircular linked lists used throughout the LinksPlatform ecosystem:\n\n- **`RecursiveSizeBalancedTree\u003cT\u003e`** — Base size-balanced binary tree\n  trait with node navigation, tree rotations, size management, and\n  tree queries (`contains`, `get_leftest`, `get_rightest`).\n- **`IterativeSizeBalancedTree\u003cT\u003e`** — Extends\n  `RecursiveSizeBalancedTree` with iterative `attach` and `detach`\n  operations that avoid stack overflow on deep trees.\n- **`LinkedList\u003cT\u003e`** — Base doubly-linked list trait with\n  `get_previous`, `get_next`, `set_previous`, `set_next`.\n- **`AbsoluteLinkedList\u003cT\u003e`** — Linked list with direct access to\n  `first` and `last` elements and size tracking.\n- **`RelativeLinkedList\u003cT\u003e`** — Linked list with head-relative\n  positioning, supporting multiple independent lists sharing storage.\n- **`AbsoluteCircularLinkedList\u003cT\u003e`** — Circular doubly-linked list\n  with absolute positioning: `attach_before`, `attach_after`,\n  `attach_as_first`, `attach_as_last`, `detach`.\n- **`RelativeCircularLinkedList\u003cT\u003e`** — Circular doubly-linked list\n  with head-relative positioning, supporting multiple circular lists\n  in shared storage.\n\n## Installation\n\nAdd to your `Cargo.toml`:\n\n```toml\n[dependencies]\nplatform-trees = \"0.1.0-beta.1\"\n```\n\n## Usage\n\n### Implementing `RecursiveSizeBalancedTree`\n\n```rust\nuse platform_trees::{IterativeSizeBalancedTree, RecursiveSizeBalancedTree};\n\nstruct MyTreeStorage {\n    nodes: Vec\u003cNode\u003e,\n}\n\nstruct Node {\n    left: usize,\n    right: usize,\n    size: usize,\n}\n\nimpl RecursiveSizeBalancedTree\u003cusize\u003e for MyTreeStorage {\n    unsafe fn get_mut_left_reference(\u0026mut self, node: usize) -\u003e *mut usize {\n        \u0026mut self.nodes[node].left\n    }\n\n    unsafe fn get_mut_right_reference(\u0026mut self, node: usize) -\u003e *mut usize {\n        \u0026mut self.nodes[node].right\n    }\n\n    unsafe fn get_left_reference(\u0026self, node: usize) -\u003e *const usize {\n        \u0026self.nodes[node].left\n    }\n\n    unsafe fn get_right_reference(\u0026self, node: usize) -\u003e *const usize {\n        \u0026self.nodes[node].right\n    }\n\n    unsafe fn get_left(\u0026self, node: usize) -\u003e usize {\n        self.nodes[node].left\n    }\n\n    unsafe fn get_right(\u0026self, node: usize) -\u003e usize {\n        self.nodes[node].right\n    }\n\n    unsafe fn get_size(\u0026self, node: usize) -\u003e usize {\n        self.nodes[node].size\n    }\n\n    unsafe fn set_left(\u0026mut self, node: usize, left: usize) {\n        self.nodes[node].left = left;\n    }\n\n    unsafe fn set_right(\u0026mut self, node: usize, right: usize) {\n        self.nodes[node].right = right;\n    }\n\n    unsafe fn set_size(\u0026mut self, node: usize, size: usize) {\n        self.nodes[node].size = size;\n    }\n\n    unsafe fn first_is_to_the_left_of_second(\u0026self, first: usize, second: usize) -\u003e bool {\n        first \u003c second\n    }\n\n    unsafe fn first_is_to_the_right_of_second(\u0026self, first: usize, second: usize) -\u003e bool {\n        first \u003e second\n    }\n}\n\nimpl IterativeSizeBalancedTree\u003cusize\u003e for MyTreeStorage {}\n```\n\n### Implementing `LinkedList`\n\n```rust\nuse platform_trees::{LinkedList, AbsoluteLinkedList, AbsoluteCircularLinkedList};\n\nstruct MyListStorage {\n    elements: Vec\u003cListElement\u003e,\n    first: usize,\n    last: usize,\n    size: usize,\n}\n\nstruct ListElement {\n    prev: usize,\n    next: usize,\n}\n\nimpl LinkedList\u003cusize\u003e for MyListStorage {\n    fn get_previous(\u0026self, element: usize) -\u003e usize {\n        self.elements[element].prev\n    }\n\n    fn get_next(\u0026self, element: usize) -\u003e usize {\n        self.elements[element].next\n    }\n\n    fn set_previous(\u0026mut self, element: usize, previous: usize) {\n        self.elements[element].prev = previous;\n    }\n\n    fn set_next(\u0026mut self, element: usize, next: usize) {\n        self.elements[element].next = next;\n    }\n}\n\nimpl AbsoluteLinkedList\u003cusize\u003e for MyListStorage {\n    fn get_first(\u0026self) -\u003e usize { self.first }\n    fn get_last(\u0026self) -\u003e usize { self.last }\n    fn get_size(\u0026self) -\u003e usize { self.size }\n\n    fn set_first(\u0026mut self, element: usize) { self.first = element; }\n    fn set_last(\u0026mut self, element: usize) { self.last = element; }\n    fn set_size(\u0026mut self, size: usize) { self.size = size; }\n}\n\nimpl AbsoluteCircularLinkedList\u003cusize\u003e for MyListStorage {}\n```\n\n## Depend on\n\n- [num-traits](https://crates.io/crates/num-traits)\n- [platform-num](https://crates.io/crates/platform-num)\n  ([Numbers](https://github.com/linksplatform/Numbers))\n\n## Dependent libraries\n\n- [doublets](https://crates.io/crates/doublets)\n  ([doublets-rs](https://github.com/linksplatform/doublets-rs))\n\n## License\n\nThis crate is released to the **public domain** under the [Unlicense](http://unlicense.org/).\n\nThe Unlicense is the most permissive license available — it places no\nrestrictions whatsoever on users. You are free to copy, modify, publish,\nuse, compile, sell, or distribute this software for any purpose,\ncommercial or non-commercial, in any way you choose, with no conditions\nattached.\n\nUnlike LGPL, which forces users to redistribute modifications under the\nsame license and comply with specific obligations (linking restrictions,\nsource disclosure for modifications), the Unlicense imposes\n**no obligations at all**. It is truly free as in freedom.\n","project_url":"https://awesome.ecosyste.ms/api/v1/projects/github.com%2Flinksplatform%2Ftrees-rs","html_url":"https://awesome.ecosyste.ms/projects/github.com%2Flinksplatform%2Ftrees-rs","lists_url":"https://awesome.ecosyste.ms/api/v1/projects/github.com%2Flinksplatform%2Ftrees-rs/lists"}