trees-rs
LinksPlatform's Platform.Trees Rust Library.
This library provides low-level tree and linked list data structure traits for the Links Platform ecosystem in Rust.
Overview
platform-trees is a Rust implementation of tree and linked list methods used by the Links Platform. It provides generic traits that can be implemented for various storage backends, enabling efficient tree-based data structures with size-balanced tree algorithms.
Features
Tree Structures
-
RecursiveSizeBalancedTree- Base size-balanced binary tree trait with core operations:- Node navigation (
get_left,get_right,get_next,get_previous) - Tree rotations (
left_rotate,right_rotate) - Size management (
get_size,fix_size,inc_size,dec_size) - Tree queries (
contains,get_leftest,get_rightest)
- Node navigation (
-
IterativeSizeBalancedTree- Iterative size-balanced tree trait extendingRecursiveSizeBalancedTree:- Iterative
attachanddetachoperations - Avoids stack overflow on deep trees
- Maintains tree balance during modifications
- Iterative
Linked List Structures
-
LinkedList- Base doubly-linked list trait withget_previous,get_next,set_previous,set_next -
AbsoluteLinkedList- Linked list with absolute positioning:- Direct access to
firstandlastelements - Size tracking
- Direct access to
-
RelativeLinkedList- Linked list with head-relative positioning:- Multiple independent lists sharing storage
- Head parameter for list identification
-
AbsoluteCircularLinkedList- Circular doubly-linked list with absolute positioning:attach_before,attach_after,attach_as_first,attach_as_lastdetachoperation
-
RelativeCircularLinkedList- Circular doubly-linked list with head-relative positioning:- All circular list operations with head parameter
- Supports multiple circular lists in shared storage
Usage
Add the dependency to your Cargo.toml:
[]
= "0.1.0-beta.1"
Example: Implementing RecursiveSizeBalancedTree
use ;
use LinkType;
// Define your tree node storage
// Implement the RecursiveSizeBalancedTree trait for your storage type
// Implement IterativeSizeBalancedTree to get attach/detach operations
Example: Implementing LinkedList
use ;
use LinkType;
// Now AbsoluteCircularLinkedList methods are available
API Reference
Tree Traits
| Trait | Description |
|---|---|
RecursiveSizeBalancedTree<T> |
Base trait for size-balanced binary trees with rotation and navigation operations |
IterativeSizeBalancedTree<T> |
Extension trait providing iterative attach/detach without recursion |
List Traits
| Trait | Description |
|---|---|
LinkedList<T> |
Base trait for doubly-linked list navigation |
AbsoluteLinkedList<T> |
Linked list with global first/last/size |
RelativeLinkedList<T> |
Linked list with head-relative first/last/size |
AbsoluteCircularLinkedList<T> |
Circular list operations with absolute positioning |
RelativeCircularLinkedList<T> |
Circular list operations with relative positioning |
Dependencies
- platform-data - LinksPlatform's core data traits (provides
LinkType) - funty - Fundamental type unification
Related Projects
- linksplatform/Collections.Methods - C#/C++ implementation of these methods
- linksplatform/Data.Doublets - Doublets data structure using these tree methods
- linksplatform/mem-rs - Memory management for Links Platform Rust libraries
License
This project is released into the public domain under the Unlicense.
Support
Ask questions at stackoverflow.com/tags/links-platform (or with tag links-platform) to get our free support.
You can also get real-time support on our official Discord server.