Derev'ja is a small kotlin library which provides simple yet powerful interface for working with different binary search trees. This projects implements many trees and adds tools to easily store and manipulate data inside bst.
Download from Releases or build your own from source with
./gradlew build
Create instance from available tree class and define types for keys and values
val tree1 = RegularTree<Int, String>()
val tree2 = AVLTree<Double, Int>()
val tree3 = RedBlackTree<Int, Int>()
tree.put(23, "Apple")
or
tree[23] = "Apple"
// returns "Apple"
tree.remove(23)
// returns "Apple"
tree[23]
By specifying traversal type and callback function tree can be traversed in almost any way you like
// traverses keys inorder
val preOrderKeys = tree.traversed.preOrder { it.key }
// traverses values in level order
val levelOrderValues = tree.traversed.levelOrder { it.value }
Methods of kotlin MutableMap interface are all available to use
For detailed documentation and all methods, check out our Wiki
Follow the steps to add your changes to the project:
- Create a fork of this repository
- Clone repository
- Create new branch named feature/
- Add your changes in that branch
- Push your branch to repository
- Open a pull request to this project