flat_tree
Version, currently 0.1.23 versions
- 0.1.2latestApr 8, 2021
- 0.1.1not indexedOct 25, 2023
- 0.1.0not indexedOct 25, 2023
github.com/dukenguyenxyz/flat_tree
Map a binary tree to a vector
6 stars
0 dependents
License: MIT
Installation
# Add this to your shard.yml
dependencies:
flat_tree:
github: dukenguyenxyz/flat_tree
version: ~> 0.1.2Then run:
shards installshard.yml
- Crystal
1.0.0- License
- MIT
- Author
- Duke Nguyen
Dependencies
This version declares no dependencies.
README
flat_tree
Map a binary tree to a vector. Port of mafintosh/flat-tree
Installation
-
Add the dependency to your
shard.yml:dependencies: flat_tree: github: dukeraphaelng/flat_tree -
Run
shards install
Usage
You can represent a binary tree in a simple flat list using the following structure
3
1 5
0 2 4 6 ...
This module exposes a series of functions to help you build and maintain this data structure
require "flat_tree"
list = [] of String
i = FlatTree.index(0_u64, 0_u64) # get array index for depth: 0, offset: 0
j = FlatTree.index(1_u64, 0_u64) # get array index for depth: 1, offset: 0
# use these indexes to store some data
list[i] = 'a'
list[j] = 'b'
list[FlatTree.parent(i)] = 'parent of a and b'
Contributing
- Fork it (https://github.com/dukeraphaelng/flat_tree/fork)
- Create your feature branch (
git checkout -b my-new-feature) - Commit your changes (
git commit -am 'Add some feature')
- This repository follows Conventional Commits
- Push to the branch (
git push origin my-new-feature) - Create a new Pull Request
Contributors
- Duke Nguyen - creator and maintainer
License
Documentation
Built from the current release. The first visit to a release nobody has asked for starts its build.
Links
This release
- Version
0.1.2- Tagged
- Apr 8, 2021
- Commit
c324d55802d3- Crystal
1.0.0- Indexed
- yes
Dependents
No indexed shard depends on this one yet.
Repository
github.com/dukenguyenxyz/flat_tree
Metadata
- Created
- Aug 12, 2026
- Updated
- Aug 12, 2026
- Synced
- Aug 12, 2026
- Versions
- 3