avltree
Version, currently 0.1.03 versions
- 0.1.2latestNov 9, 2024
- 0.1.1not indexedNov 10, 2024
- 0.1.0not indexedNov 10, 2024
github.com/ngng628/avltree
An implement of SortedSet, SortedMap and SortedMultiset using AVL tree.
Nothing has been indexed for 0.1.0 yet. The tag is recorded, its shard.yml has not been read, so the manifest and dependency list below are empty because they are unknown rather than because they are absent.
Installation
# Add this to your shard.yml
dependencies:
avltree:
github: ngng628/avltree
version: ~> 0.1.0Then run:
shards installshard.yml
No shard.yml has been indexed for 0.1.0. You can read it on the repository.
Dependencies
Unknown: the shard.yml for this version has not been read yet.
README
This README is the one indexed from the repository at its latest ref, not from the tag for this version.
AVLTree
An implement of SortedSet, SortedMap and SortedMultiset using AVL tree.
Each method is implemented to be as compliant as possible with the standard Set and Hash in the Crystal language.
:arrow_down: Installation
-
Add the dependency to your
shard.yml:dependencies: avltree: github: ngng628/avltree -
Run
shards install
:pencil2: Usage
require "avltree"
:bulb: Sample
If you want more details, please refer to the API documentation.
set = AVLTree::SortedSet(Int32).new
set << 3 << 1 << 4 << 1 << 5 << 9
set # => SortedSet{1, 3, 4, 5, 9}
set[0] # => 1
set[1] # => 3
set[2] # => 4 (SortedSet#[k] returns the kth object)
set.lower_bound(-1) # => 0
set.lower_bound(2) # => 1
set.lower_bound(3) # => 1
set.lower_bound(9) # => 4
set.lower_bound(10) # => 5
set.delete(1)
set # => SortedSet{3, 4, 5, 9}
map = AVLTree::SortedMap(String, Int32).new
map["alice"] = 10
map["alice"] # => 10
map["carol"] = 20
map["carol"] # => 20
map["bob"] = -10
map["bob"] # => -10
map.at(0) # => {"alice", 10}
map.at(1) # => {"bob", -10}
map.at(2) # => {"carol", 20} (at(k) returns the key-value pair to the kth key.)
map.lower_bound("a") # => 0
map.lower_bound("bob") # => 1
map.lower_bound("dave") # => 3
map.delete("alice")
map # {"bob" => -10, "carol" => 20}
map.delete_at(1)
map # {"bob" => -10}
mset = AVLTree::SortedMultiset(Int32).new
mset << 3 << 1 << 4 << 1 << 5 << 9
mset # => SortedMultiset{1, 1, 3, 4, 5, 9}
mset[0] # => 1
mset[1] # => 1
mset[2] # => 3 (SortedMultiset#[k] returns the kth object)
mset.lower_bound(-1) # => 0
mset.lower_bound(2) # => 2
mset.lower_bound(3) # => 2
mset.lower_bound(9) # => 5
mset.lower_bound(10) # => 6
mset.delete(1)
mset # => SortedMultiset{1, 3, 4, 5, 9}
:busts_in_silhouette: Contributing
- Fork it (https://github.com/ngng628/avltree/fork)
- Create your feature branch (
git checkout -b my-new-feature) - Commit your changes (
git commit -am ':sparkles: Add some feature')- Please follow the
.gitmessageformat for the commit message.
- Please follow the
- Push to the branch (
git push origin my-new-feature) - Create a new Pull Request
:desktop_computer: Contributors
- ngng628 - creator and maintainer
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.0- Tagged
- Nov 10, 2024
- Commit
9d50122f02df- Indexed
- not yet
Dependents
Repository
github.com/ngng628/avltree
Metadata
- Created
- Aug 12, 2026
- Updated
- Aug 18, 2026
- Synced
- Aug 18, 2026
- Versions
- 3