Tree Lib is the kotlin library for working with 3 different binary tree implementations: Binary Search Tree (BST), AVL-Tree (AVL) and Red-Black Tree (RB).
To init an object, you must provide key and value type.
val treeExample: BSTree<<Key>, <Value>>
for example
val treeExample = BSTree<String, Double>()
All trees supports basic methods:
-
Add values and keys as nodes to the tree:
treeExample.add(key: "abc", value: 1.0)
-
Change node's value:
treeExample.changeVal(key: "abc", value: 37.7)
-
Remove node from the tree:
treeExample.remove(key: "Choose wisely.")
-
Find node by key:
treeExample.findByKey(key: "Anything you can compare!")
-
Iterate in tree:
for (node in treeExample) { ...
-
...and much more!
With binary trees, Tree Lib provides a node type for each of them. You can read node's key and value(with key() and value() methods), compare them between each other(although they must share same type), convert them to pair(toPair()) or string(toString()).
Distributed under the MIT License. See LICENSE.txt
for more information.
This library was created by:
- Magomedov Islam (tg @JapEmpLove) - BST
- Damir Yunusov (tg @TopographicOcean) - RB
- Sofya Grishkova (tg @tea_jack) - AVL
Links to Wikipages about binary trees:
Here are provided applications, advantages and disadvantages of Binary Search Tree
Good Habr article about AVL-Trees