Skip to content

spbu-coding-2023/trees-3

Repository files navigation

NamelessKitty.kt - library that appreciate your data ✨

NamelessKitty.kt is library that help you work with your data by simple interface, using binary search trees under the hood.

⚡️Quick start

import tree.RBTree

fun main() {
    val rbt = RBTree<Int, String>()
    
    rbt.set(1, "Hello world")
    
    println(rbt.search(1))
}

Yes, that is really simple.
We Love KISS.

✨ Features

  • Null-safety code - We didn't use anything that could break your code
  • 18 public methods - Thanks to Dima
  • Simple interface - Our library is easy to use and we proud of it
  • Easy to expand - We provide simple abstact class that allow you create new type of trees and use it for your tasks
  • Generic types - Use whatever you want types. We handle with it.

👀 Examples

📖 Add array of data

import tree.RBTree

fun main() {
    val data = arrayOf(122 to "Homka", 21 to "Dima", 25 to "Nastya")
    val dataKeys = data.map { it.first }.toTypedArray()
    
    val rbt = RBTree<Int, String>(data)
    rbt.set(data)
    rbt.remove(dataKeys)
}

📖 Print all data in ascending order

import tree.RBTree

fun main() {
    val data = arrayOf(122 to "Homka", 21 to "Dima", 25 to "Nastya")

    val rbt = RBTree(data)

    rbt.inOrderTraversal {
        println("key: ${it.first}, value: ${it.second}")
    }
}

📖 Put only first incoming data

import tree.RBTree

fun main() {
    val data = arrayOf(1 to "Homka", 2 to "Dima", 3 to "Nastya", 1 to "Homka")

    val rbt = RBTree(data)

    data.forEach {
        val previousValue = rbt.setIfEmpty(it.first, it.second)
        
        if (previousValue != null) {
            println("Data with key: ${it.first} already exists and contain: ${previousValue}")
        }
    }
}

🐤 Docs

docs.md

🐹 Gitbub stars

We love stars (ok, just me). I would be very pleased if you put a star on our project.
image

Contacts

About

trees-3 created by GitHub Classroom

Resources

License

Stars

Watchers

Forks

Releases

No releases published

Packages

No packages published

Contributors 4

  •  
  •  
  •  
  •  

Languages