Ecosyste.ms: Awesome
An open API service indexing awesome lists of open source software.
https://github.com/ureeves/whistlinoak
Annotated even-arity trees backed by arbitrary memories
https://github.com/ureeves/whistlinoak
Last synced: 4 days ago
JSON representation
Annotated even-arity trees backed by arbitrary memories
- Host: GitHub
- URL: https://github.com/ureeves/whistlinoak
- Owner: ureeves
- License: apache-2.0
- Created: 2022-08-05T22:45:07.000Z (over 2 years ago)
- Default Branch: master
- Last Pushed: 2022-10-21T20:31:36.000Z (about 2 years ago)
- Last Synced: 2024-11-08T21:40:45.557Z (10 days ago)
- Language: Rust
- Homepage:
- Size: 31.3 KB
- Stars: 0
- Watchers: 1
- Forks: 0
- Open Issues: 2
-
Metadata Files:
- Readme: README.md
- License: LICENSE-APACHE
Awesome Lists containing this project
README
# Whistlin'Oak
[![Repository](https://img.shields.io/badge/github-whistlinoak-darkgreen?logo=github)](https://github.com/ureeves/whistlinoak)
![Build Status](https://github.com/ureeves/whistlinoak/workflows/build/badge.svg)
[![Documentation](https://img.shields.io/badge/docs-whistlinoak-orange?logo=rust)](https://docs.rs/whistlinoak/)Annotated even-arity trees backed by arbitrary memories.
## Usage
```toml
whistlinoak = "0.2"
```## Example
```rust
use whistlinoak::{Annotation, Tree};struct Cardinality(usize);
impl Annotation for Cardinality {
fn compute(leaf: &T) -> Self {
Cardinality(1)
}fn combine<'a>(annotations: impl Iterator) -> Self
where
Self: 'a
{
Self(annotations.fold(0, |curr, c| curr + c.0))
}
}let mut tree = Tree::::new();
let n_leaves = 1000;
for i in 0..n_leaves {
tree.push(i).unwrap();
}assert_eq!(tree.len(), n_leaves);
assert_eq!(tree.root().0, n_leaves);
```