Skip to content
Open
Show file tree
Hide file tree
Changes from all commits
Commits
Show all changes
145 commits
Select commit Hold shift + click to select a range
df239d1
Setting up GitHub Classroom Feedback
github-classroom[bot] Mar 14, 2024
780db61
struct: gradle init
homka122 Mar 21, 2024
24c34c5
struct: update .gitignore
homka122 Mar 21, 2024
6b4f63f
struct: get initial structure of files
homka122 Mar 21, 2024
d455921
struct: add license
homka122 Mar 21, 2024
523f8ba
feat: created an abstract node class
Demon32123 Mar 23, 2024
4a3b059
feat: created an abstract search tree class
Demon32123 Mar 23, 2024
95addd4
fix: сorrected methods insertNode, removeNode, createNode
Demon32123 Mar 23, 2024
b397449
feat: created a binary search tree node class
Demon32123 Mar 23, 2024
8ceb961
feat: created a AVL-Tree node class
Demon32123 Mar 23, 2024
a2d7ba2
fix: the order of the AVL-Tree node class attributes has been changed
Demon32123 Mar 24, 2024
d712b38
fix: classes AVL, BST and RBT nodes have been corrected
Demon32123 Mar 24, 2024
a18c27d
feat: сreated a binary search tree class
Demon32123 Mar 24, 2024
cfdd4ce
feat: сreated a AVL-Tree class
Demon32123 Mar 24, 2024
7471277
feat: сreated class red black tree node
Demon32123 Mar 24, 2024
d9aefd5
feat: сreated class red black tree
Demon32123 Mar 24, 2024
d077d9b
fix: corrected omissions in serch tree class and formatted code
Demon32123 Mar 24, 2024
5cae855
refactor: move RBTreeColor to seperate file
homka122 Mar 25, 2024
8abb345
refactor: add comments to methods of SearchTree
homka122 Mar 25, 2024
85b70bb
fix: traversal method's argument must be function
homka122 Mar 25, 2024
0b3bccd
refactor(BST): changed comment to method insertNode
far1yg Mar 26, 2024
d2dccc2
feat(BST): add method insertNode
far1yg Mar 27, 2024
5727bfe
feat(BST): add constructors
far1yg Mar 27, 2024
783a863
feat(BST): add method createNode
far1yg Mar 27, 2024
8d9cf1b
feat(AVL-T): implemented method createNode
Demon32123 Mar 28, 2024
59ed960
feat(AVL-T): Implemented insertNode method along with auxiliary methods
Demon32123 Mar 31, 2024
2819604
feat(BST): add private method searchParentNode
far1yg Mar 31, 2024
f6a25f0
refactor(BST): remove ; in method insertNode
far1yg Mar 31, 2024
71f5833
refactor(BST): remove ; in method createNode
far1yg Mar 31, 2024
36db2a2
feat(BST): add private method getMinSubtree
far1yg Mar 31, 2024
d2a8972
feat(BST): add method removeNode
far1yg Mar 31, 2024
3e2314e
refactor(BST): refactor method createNode
far1yg Mar 31, 2024
c5d66c8
refactor(BST): refactor method insertNode
far1yg Mar 31, 2024
6fc787c
feat(BST): add method identifyChild, correct method removeNode
far1yg Mar 31, 2024
bbd3978
Merge pull request #4 from spbu-coding-2023/feature/bstree
far1yg Mar 31, 2024
619020e
feat: add method search
far1yg Mar 31, 2024
439e822
feat: implement searchNode method
homka122 Mar 31, 2024
add2326
feat: implement set with single key method
homka122 Mar 31, 2024
9e39564
fix: spell mistake
homka122 Mar 31, 2024
84f1abe
refactor(AVL-T): balancing has been moved to a separate method rebala…
Demon32123 Mar 31, 2024
41e2366
feat: implement postOrderTraversal
homka122 Mar 31, 2024
396c5a9
Merge pull request #5 from spbu-coding-2023/feature/searchTree/Homka
homka122 Mar 31, 2024
5f42f37
feat(RBT): implement createNode method
homka122 Mar 27, 2024
ddd5d3f
feat(RBT): implement rotation methods
homka122 Mar 27, 2024
8a415a3
feat(RBT): implement insertNode method
homka122 Mar 27, 2024
dd80525
feat(RBT): implement insertFix method
homka122 Mar 27, 2024
3213846
refactor(RBT): refactor insertFix method
homka122 Mar 27, 2024
0b67dce
feat(RBT): implement throwError() method
homka122 Mar 27, 2024
3f58a4d
refactor(RBT): refactor rotation methods
homka122 Mar 27, 2024
b78d2f6
fix(RBT): remove useless method that I did just for fun and forgeted …
homka122 Mar 27, 2024
8a2a2ac
feat(RBT): inherit constructors from SearchTree
homka122 Mar 27, 2024
9e0c75f
fix(RBT): fix bug in insertFix
homka122 Mar 27, 2024
3d8d788
refactor(RBT): refactor RBTree class, remove semicolons
homka122 Mar 27, 2024
b8c74a8
feat(RBT): add rbTransplant method
homka122 Mar 28, 2024
dc8f1f8
feat(RBT): implement removeNode method
homka122 Mar 28, 2024
5a5c4de
refactor(RBT): make minimum and removeNode prettier
homka122 Apr 1, 2024
dd6cf3e
feat(RBT): implement deleteFix method
homka122 Apr 1, 2024
359a1d9
refactor(RBT): delete useless method that throw error
homka122 Apr 1, 2024
d465c67
refactor(RBT): make names of methods prettier
homka122 Apr 1, 2024
3abdc84
refactor(AVL-T): implemented removeNode method along with auxiliary m…
Demon32123 Apr 1, 2024
1711e3c
feat: add method inOrderTraversal
far1yg Apr 1, 2024
2711d2b
feat: add method predecessor
far1yg Apr 1, 2024
9f36f12
feat: add method successor
far1yg Apr 1, 2024
28f266a
feat: add method getMin
far1yg Apr 1, 2024
012efc3
feat: add method getEntities
far1yg Apr 1, 2024
5c94f1a
refactor: add empty line in methods getMin and inOrderTraversal
far1yg Apr 1, 2024
de5a3da
Merge branch 'main' into feature/searchTree/Nastya
homka122 Apr 1, 2024
aeb46ac
Merge pull request #8 from spbu-coding-2023/feature/searchTree/Nastya
homka122 Apr 1, 2024
d7a1184
feat: implements getKeys and getValues methods
homka122 Apr 1, 2024
379679f
refactor(AVL-T): added lines for easier code readability
Demon32123 Apr 1, 2024
c282e91
refactor(AVL-T): used ready-made variables for easy readability of th…
Demon32123 Apr 1, 2024
08fe10b
fix(AVL-T): fixed infinite loop bug in minValueNode
Demon32123 Apr 1, 2024
9eb8a43
Merge pull request #7 from spbu-coding-2023/feature/avltree
homka122 Apr 1, 2024
9dfde18
fix: change return type in method getEntities
far1yg Apr 1, 2024
bc3a9a5
fix: fix getValues and getKeys methods
homka122 Apr 2, 2024
904838f
Merge pull request #6 from spbu-coding-2023/feature/rbtree
homka122 Apr 2, 2024
cfb0356
feat: added set method for arrays
Demon32123 Apr 2, 2024
5af73f9
feat: added setIfEmpty method
Demon32123 Apr 2, 2024
8a08e5f
feat: added setIfEmpty method for arrays
Demon32123 Apr 3, 2024
6d632df
feat: added remove method
Demon32123 Apr 3, 2024
0ce04fa
feat: added remove method for arrays
Demon32123 Apr 3, 2024
fa83af8
feat: added getMax method
Demon32123 Apr 3, 2024
d51ebfa
feat: added clear method
Demon32123 Apr 3, 2024
f68a761
feat: added preOrderTraversal method
Demon32123 Apr 3, 2024
c5019db
refactor: optimized methods set, setIfEmpty, remove
Demon32123 Apr 3, 2024
361dbb5
Merge pull request #9 from spbu-coding-2023/feature/searchTree/Dima
homka122 Apr 3, 2024
0f3e410
test: add some basic tests
homka122 Apr 2, 2024
849c079
test: add jacoco support
homka122 Apr 2, 2024
48d8a53
test(RBT): add constructors tests
homka122 Apr 2, 2024
415270f
test: add test for BSTree
far1yg Apr 3, 2024
e0b74c7
test: add insert test and change remove test for BSTree
far1yg Apr 3, 2024
6ba30e8
test:fix removeNode method in BSTree
far1yg Apr 3, 2024
6c1184a
test(BST): refactor tests of method insertNode
far1yg Apr 3, 2024
224c37a
refactor(RBT): make insertNode more readable and add comments
homka122 Apr 3, 2024
252a2aa
test(RBT): add helper methods for tests
homka122 Apr 4, 2024
336584a
test(RBT): add set tests
homka122 Apr 4, 2024
8a86df2
test(RBT): add universal set test
homka122 Apr 4, 2024
086ae28
test(RBT): add more set tests
homka122 Apr 4, 2024
253038b
test(RBT): add remove tests
homka122 Apr 4, 2024
7c88442
refactor(RBT): make methods prettier, add comments
homka122 Apr 4, 2024
ab6fb80
ci: add tests ci
homka122 Apr 4, 2024
2920dd9
ci: add tests ci
homka122 Apr 4, 2024
bc3d40a
test(BST): refactor tests of method createNode
far1yg Apr 3, 2024
c63ac83
test(BST): add tests of method removeNode
far1yg Apr 4, 2024
613284c
test(BST): fix method removeNode
far1yg Apr 4, 2024
c1d3d17
Create README.md
homka122 Apr 4, 2024
60a1678
Merge pull request #11 from spbu-coding-2023/test
homka122 Apr 4, 2024
802c057
test(RBT): add more random values
homka122 Apr 4, 2024
e8a7c63
Create docs.md
homka122 Apr 4, 2024
ef36bf7
Move docs to another files and fix urls
homka122 Apr 4, 2024
09adfd6
test(BST): fix removeNode method
far1yg Apr 4, 2024
bbf901d
test(BST): add test for remove method
far1yg Apr 4, 2024
4375e88
Merge pull request #12 from spbu-coding-2023/BSTtest
far1yg Apr 4, 2024
f3e3d3c
refactor(BST): make removeNode method prettier
homka122 Apr 4, 2024
4accdb8
test(AVL): add tests for set in AVL-Tree
Demon32123 Apr 4, 2024
07c3b2d
test(STree): add getting test
far1yg Apr 4, 2024
3a96a74
test(STree): add search test
far1yg Apr 4, 2024
dd0fb8e
test(STree): add traversal tests
homka122 Apr 4, 2024
035fa06
test(AVL): add tests for remove in AVL-Tree
Demon32123 Apr 4, 2024
a1f921e
Merge pull request #13 from spbu-coding-2023/STreetest
homka122 Apr 4, 2024
e731a11
Merge pull request #14 from spbu-coding-2023/AVLtest
homka122 Apr 4, 2024
b10fe3e
test(BST): refactor remove tests
far1yg Apr 6, 2024
7d58692
refactor: make method inOrderTraversal more prettier
far1yg Apr 6, 2024
1764f72
refactor: delete empty line in method inOrderTraversal
far1yg Apr 6, 2024
8748774
fix(STree): fix bug in method predecessor
far1yg Apr 6, 2024
e9220f8
test(STree): add cases in successor and predecessor tests
far1yg Apr 6, 2024
2c26904
test(STree): refactor getting tests
far1yg Apr 6, 2024
9f20685
test(STree): add cases in successor and predecessor tests
far1yg Apr 6, 2024
f70e08e
test(STree): add remove tests and refactor search tests
far1yg Apr 6, 2024
2691d72
test(STree): add setting tests, add check in remove and search tests
far1yg Apr 7, 2024
dd776bd
test(STree): add setIfEmpty tests
far1yg Apr 7, 2024
0a9ab71
test(STree): add Constructors tests
far1yg Apr 7, 2024
ccb1090
test(STree): add resently keys tests
far1yg Apr 7, 2024
f234f69
test(STree): group test of methods set
far1yg Apr 7, 2024
6cc7249
test(STree): add case to constructor test
far1yg Apr 7, 2024
74a11c2
test(STree): make setting, remove tests prettier
far1yg Apr 7, 2024
05b6698
Merge pull request #15 from spbu-coding-2023/refactor/Nastya
homka122 Apr 7, 2024
2f431ef
fix(AVL-T): fix remove method in AVLTree
Demon32123 Apr 9, 2024
3e34279
fix(AVL-T): add new tests in remove test
Demon32123 Apr 9, 2024
ec9a09b
Merge pull request #16 from spbu-coding-2023/fix/Dima
homka122 Apr 10, 2024
8ab036c
refactor(STree): change if to when in method searchNode
far1yg Apr 13, 2024
30f48a3
refactor(BST): change if to when in methods insertNode, identifyChild…
far1yg Apr 13, 2024
c6be325
test(STree): make set test in empty tree prettier
far1yg Apr 13, 2024
810d36b
test(BST): use simplier way to create a tree to test
far1yg Apr 13, 2024
3554f69
Merge pull request #17 from spbu-coding-2023/refactor/Nastya
far1yg Apr 13, 2024
File filter

Filter by extension

Filter by extension


Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
9 changes: 9 additions & 0 deletions .gitattributes
Original file line number Diff line number Diff line change
@@ -0,0 +1,9 @@
#
# https://help.github.com/articles/dealing-with-line-endings/
#
# Linux start script should use lf
/gradlew text eol=lf

# These are Windows script files and should use crlf
*.bat text eol=crlf

26 changes: 26 additions & 0 deletions .github/workflows/tests.yml
Original file line number Diff line number Diff line change
@@ -0,0 +1,26 @@
name: Kotlin CI With Gradle

on:
push:
branches: [ "main", "test" ]
pull_request:
branches: [ "main", "test" ]

jobs:
build:

runs-on: ubuntu-latest

steps:
- uses: actions/checkout@v4
- name: Set up JDK 17
uses: actions/setup-java@v4
with:
java-version: '21'
distribution: 'temurin'

- name: Build with Gradle Wrapper
run: ./gradlew build

- name: Launch tests
run: ./gradlew :lib:test

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Покрытие бы посчитать где-нибудь, как-нибудь... (или у вас есть где-то спрятанное и это я слепец -_-)

7 changes: 7 additions & 0 deletions .gitignore
Original file line number Diff line number Diff line change
@@ -0,0 +1,7 @@
# Ignore Gradle project-specific cache directory
.gradle

# Ignore Gradle build output directory
build

.idea
7 changes: 7 additions & 0 deletions LICENSE
Original file line number Diff line number Diff line change
@@ -0,0 +1,7 @@
Copyright 2024 Dmitry Sheiko, Anastasiia Kuzmina, Ilhom Kombaev

Permission is hereby granted, free of charge, to any person obtaining a copy of this software and associated documentation files (the “Software”), to deal in the Software without restriction, including without limitation the rights to use, copy, modify, merge, publish, distribute, sublicense, and/or sell copies of the Software, and to permit persons to whom the Software is furnished to do so, subject to the following conditions:

The above copyright notice and this permission notice shall be included in all copies or substantial portions of the Software.

THE SOFTWARE IS PROVIDED “AS IS”, WITHOUT WARRANTY OF ANY KIND, EXPRESS OR IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY, FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM, OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE SOFTWARE.
91 changes: 91 additions & 0 deletions README.md
Original file line number Diff line number Diff line change
@@ -0,0 +1,91 @@
## 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.

<img src="https://github.com/spbu-coding-2023/trees-3/assets/39369841/2384c62a-a6c7-4fba-a2dc-02ee91b57d79" width="128"/>

## ⚡️Quick start

```kotlin
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**
```kotlin
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**
```kotlin
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**
```kotlin
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](https://github.com/spbu-coding-2023/trees-3/blob/main/docs.md)

## 🐹 Gitbub stars
We love stars (ok, just me). I would be very pleased if you put a star on our project. \
![image](https://github.com/spbu-coding-2023/trees-3/assets/39369841/bb81c1b0-5d69-4b63-9a9a-49b952625ad7)

## Contacts
- [Dmitry Sheiko](https://github.com/Demon32123)
- [Anastasiia Kuzmina](https://github.com/far1yg)
- [Homa Kombaev](https://github.com/homka122)
60 changes: 60 additions & 0 deletions docs.md
Original file line number Diff line number Diff line change
@@ -0,0 +1,60 @@
## 🐤 Docs
- We have three types of tree: BST, AVL, RBT
- Each tree has constructor that accept:
- Nothing (Empty tree)
- Key and Value
- Array of Pairs of Key\Value
- Each tree has these methods:
- `set(key: K, value: V): V?` \
Stores the value for the given key. Return previous value.

- `set(pairs: Array<Pair<K, V>>): MutableList<V?>` \
Stores the values for the given keys. Return previous values.

- `setIfEmpty(key: K, value: V): V?` \
Stores the value for the given key if there is no pair with that key. Return previous value.

- `setIfEmpty(pairs: Array<Pair<K, V>>): MutableList<V?>` \
Stores the values for the given keys if there is no pair with that key. Return previous values.

- `remove(key: K): V?` \
Remove the value for the given key. Return previous value.

- `remove(keys: Array<K>): MutableList<V?>` \
Remove the values for the given keys. Return previous values.

- `search(key: K): V?` \
Return the value for the given key.

- `getKeys(): List<K>` \
Returns a complete list of keys.

- `getValues(): List<V>` \
Returns a complete list of values.

- `getEntities(): List<Pair<K, V>>` \
Returns a complete list of pairs key value.

- `getMin(): Pair<K?, V?>` \
Returns pair with the minimum key.

- `getMax(): Pair<K?, V?>` \
Returns pair with the maximum key.

- `successor(key: K): Pair<K?, V?>` \
Returns the pair with next ascending key.

- `predecessor(key: K): Pair<K?, V?>` \
Returns the pair with previous ascending key

- `clear()` \
Remove all keys in a tree.

- `preOrderTraversal(action: (Pair<K, V>) -> (Unit))` \
Apply [action] on all pairs by preorder tree traversal.

- `inOrderTraversal(action: (Pair<K, V>) -> (Unit))` \
Apply [action] on all pairs by inorder tree traversal.

- `postOrderTraversal(action: (Pair<K, V>) -> (Unit))` \
Apply [action] on all pairs by postorder tree traversal.
15 changes: 15 additions & 0 deletions gradle/libs.versions.toml
Original file line number Diff line number Diff line change
@@ -0,0 +1,15 @@
# This file was generated by the Gradle 'init' task.
# https://docs.gradle.org/current/userguide/platforms.html#sub::toml-dependencies-format

[versions]
commons-math3 = "3.6.1"
guava = "32.1.3-jre"
junit-jupiter-engine = "5.10.0"

[libraries]
commons-math3 = { module = "org.apache.commons:commons-math3", version.ref = "commons-math3" }
guava = { module = "com.google.guava:guava", version.ref = "guava" }
junit-jupiter-engine = { module = "org.junit.jupiter:junit-jupiter-engine", version.ref = "junit-jupiter-engine" }

[plugins]
jvm = { id = "org.jetbrains.kotlin.jvm", version = "1.9.20" }
Binary file added gradle/wrapper/gradle-wrapper.jar
Binary file not shown.
7 changes: 7 additions & 0 deletions gradle/wrapper/gradle-wrapper.properties
Original file line number Diff line number Diff line change
@@ -0,0 +1,7 @@
distributionBase=GRADLE_USER_HOME
distributionPath=wrapper/dists
distributionUrl=https\://services.gradle.org/distributions/gradle-8.6-bin.zip
networkTimeout=10000
validateDistributionUrl=true
zipStoreBase=GRADLE_USER_HOME
zipStorePath=wrapper/dists
Loading