Skip to content

spbu-coding-2023/trees-1

Folders and files

NameName
Last commit message
Last commit date

Latest commit

 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 

Repository files navigation

🌳 Derev'ja 🌳

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.

Installation

Download from Releases or build your own from source with

  ./gradlew build

Usage Examples

Create

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>()

Insert

tree.put(23, "Apple")

or

tree[23] = "Apple"

Remove

// returns "Apple"
tree.remove(23)

Search

// returns "Apple"
tree[23] 

Traverse

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 } 

Other

Methods of kotlin MutableMap interface are all available to use

Documentation

For detailed documentation and all methods, check out our Wiki

Contributing

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

Authors

License

MIT