Data Structures Library for Rust
A comprehensive, zero-dependency collection of fundamental data structures for Rust. The crate is published on crates.io and documented on docs.rs.
Installation
Add the crate to your Cargo.toml:
[]
= "1.1.0"
Quick Start
use ;
let mut arr = new;
arr.append;
arr.append;
assert_eq!;
let mut heap = new;
heap.push;
heap.push;
assert_eq!;
let mut tree = new;
tree.insert;
tree.insert;
tree.insert;
assert_eq!;
let mut cache = new.unwrap;
cache.set;
cache.set;
cache.set; // evicts "a"
assert!;
let mut trie = new;
trie.insert;
trie.insert;
assert!;
Features
- Zero runtime dependencies: Uses only the Rust standard library
- Comprehensive coverage: Linear, hashing, trees, heaps, tries, graphs, caches, and probabilistic structures
- Generic APIs: Strongly-typed with trait bounds
- Well tested: Integration tests for common and edge cases
- Clear errors: Methods return
Result<T, Error>where appropriate
Supported Data Structures
Linear
DynamicArray: automatically resizing arraySinglyLinkedList,DoublyLinkedList,CircularLinkedList: linked listsStack: LIFO stackQueue: FIFO queue
Hashing
HashMap: key-value mapHashSet: unique value set
Trees
BinarySearchTree: standard binary search treeAvlTree: self-balancing AVL tree
Heaps
MinHeap,MaxHeap: binary heaps
Others
Trie: prefix treeAdjacencyListGraph,AdjacencyMatrixGraph: graph representationsLruCache: least-recently-used cacheBloomFilter: probabilistic membership filter
Usage Examples
Binary Search Tree
use BinarySearchTree;
let mut tree = new;
.iter.for_each;
assert!;
Graph
use AdjacencyListGraph;
let mut g = new;
g.add_edge;
g.add_edge;
assert_eq!;
Bloom Filter
use BloomFilter;
let mut bf = new.unwrap;
bf.add;
assert!;
assert!;
Development
License
MIT License. See LICENSE for details.