Skip to content
Open
Show file tree
Hide file tree
Changes from all commits
Commits
Show all changes
91 commits
Select commit Hold shift + click to select a range
0de1819
Setting up GitHub Classroom Feedback
github-classroom[bot] Mar 20, 2023
3cbfea0
first commit, add .gitignore, README.md, init Gradle
RoketFlame Mar 23, 2023
c008b4a
feat: add Deployment paragraph in README.md, add basic structure for …
RoketFlame Mar 23, 2023
117df44
feat: add CONTRIBUTING.md
RoketFlame Mar 24, 2023
f7a83f8
fix: fix generics in interface Tree
RoketFlame Mar 24, 2023
d5751e5
fix: fix interface Node
RoketFlame Mar 24, 2023
f17f3b8
fix: add .idea files (trash)
RoketFlame Mar 24, 2023
fe3d134
feat: change generics in Tree, now it has more clear structure
RoketFlame Mar 24, 2023
6898fb5
fix: change interface Tree, root in ABSTree is protected
RoketFlame Mar 25, 2023
1ca3445
fix: fix compareTo for Node and BSNode
RoketFlame Mar 25, 2023
c7ee8b5
feat: add early BSTree
RoketFlame Mar 25, 2023
86a611e
fix: delete .idea
RoketFlame Mar 25, 2023
3749a5f
fix: add .idea to .gitignore
RoketFlame Mar 25, 2023
caa7bb2
feat: add fun get for BSTree
RoketFlame Mar 25, 2023
064af09
feat: add filed parent for interface Node
RoketFlame Mar 25, 2023
c5c003b
fix: fix version of gradle
RoketFlame Mar 25, 2023
0a84450
feat: add funs simpleDelete, getMinimal and getMaximal
RoketFlame Mar 26, 2023
b13cc6d
fix: change contains function to be compatible with simpleContains
RoketFlame Mar 26, 2023
3a81f3d
feat: add copyright header for source files
RoketFlame Mar 27, 2023
79de548
feat: add workflows for github, it has to check project build on crea…
RoketFlame Mar 27, 2023
e6f0ee6
fix: change platform for build and tests
RoketFlame Mar 27, 2023
542a092
struct: change struct project for gradle building
RoketFlame Mar 27, 2023
a299c66
feat: init correct build project
RoketFlame Mar 27, 2023
740e220
feat: add build directory
RoketFlame Mar 27, 2023
c0f3561
feat: init correct gradle project
RoketFlame Mar 27, 2023
c135272
fix: refactor fun get, now it uses simpleContains from ABSTree
RoketFlame Mar 27, 2023
b4e7919
fix: fix funs getMinimal nad getMaximal
RoketFlame Mar 29, 2023
5a945fd
fix: huge refactoring of methods, now it are more simple and clear
RoketFlame Mar 29, 2023
ab537d2
fix: minor changes in the use of ABSTree functions
RoketFlame Mar 29, 2023
c5f45a3
feat: add conversion KeyValue to string
RoketFlame Mar 29, 2023
ac10c0b
feat: add functions rotateLeft and rotateRight
RoketFlame Mar 29, 2023
4a5e5dc
fix: simple fix avoid null exception
RoketFlame Mar 29, 2023
651e56e
fix: minor class BSTree initialization fix
RoketFlame Mar 29, 2023
d41ad0d
struct: split all files into files for each class/interface
RoketFlame Apr 2, 2023
32aaf55
struct: add modules for trees and nodes
RoketFlame Apr 2, 2023
5ebeade
refactor: sort funs in BSTree, rename fun "rebalance" to "balance"
RoketFlame Apr 4, 2023
373a15f
feat(AVLNode): add AVLNode with methods "compareTo", "equals", "getKe…
Lesh79 Mar 28, 2023
97fc2ee
feat(AVLTree): add AVLTree implementing methods "balaceFactor", "upda…
Lesh79 Mar 28, 2023
669e0df
feat(AVLTree): add AVLTree implementing methods "balaceFactor", "upda…
Lesh79 Apr 4, 2023
ce39186
feat: add early RBTree and RBNode
Apr 5, 2023
77e56b0
Realized all types of trees (#10)
RoketFlame Apr 9, 2023
d1d875f
Merge remote-tracking branch 'origin/main' into dev-wokuparalyzed
Apr 9, 2023
a455232
feat: add early BSTreeTest
Apr 11, 2023
0480a42
fix: small fix BSTreeTest. Add list of random integers for test binar…
Apr 12, 2023
5fb1fda
feat: row commit, change struct of balance and refactor code
RoketFlame Apr 5, 2023
42ba4a5
fix: fix adding already existing value
RoketFlame Apr 7, 2023
2e29d1c
fix: hu-u-uge refactor, change access modifier most of the methods
RoketFlame Apr 9, 2023
9650516
struct: move abstract class MyNode into Nodes folder
RoketFlame Apr 9, 2023
47b17c8
fix: change private access modifier on internal
Lesh79 Apr 12, 2023
7de5e53
feat: add early AVLTreeTest
Lesh79 Apr 12, 2023
fab3467
fix: one of the invariants
Lesh79 Apr 12, 2023
a62958f
feat: add tests for all types of trees with InvariantTest
RoketFlame Apr 16, 2023
45fd11a
feat: add tests for function "contains"
RoketFlame Apr 17, 2023
b209b00
fix: simple fix classes of nodes (data class now, add hashCode())
RoketFlame Apr 17, 2023
3080f2f
fix: add information about value in tests when test failed
RoketFlame Apr 17, 2023
a85c0ae
fix: fix dependencies
RoketFlame Apr 17, 2023
7310c8a
struct: restructure code (preparation for adding storage database)
RoketFlame Apr 18, 2023
9d5ed2a
feat: add way to save trees to neo4j database
RoketFlame Apr 19, 2023
1323217
fix:
RoketFlame Apr 19, 2023
754cf9c
refactor: standardize the names of functions and fields in classes
RoketFlame Apr 19, 2023
0c36518
feat:
RoketFlame Apr 19, 2023
a5afc9e
fix: fix github-actions.yml, set versions in settings.gradle.kts
RoketFlame Apr 19, 2023
4094933
fix: fix settings.gradle.kts
RoketFlame Apr 19, 2023
efcb5dd
struct: move classes of trees in root
RoketFlame Apr 23, 2023
020f46d
test: add test for deleting
RoketFlame Apr 23, 2023
72742c9
test: add test for using KeyValue as data in node
RoketFlame Apr 23, 2023
acdd6ad
feat: add dependencies for jetbrains.compose
RoketFlame Apr 23, 2023
83a6aeb
feat: add way to store trees with .json file
RoketFlame Apr 23, 2023
bca7503
feat: add a way to store trees in SQL database
RoketFlame Apr 24, 2023
8d216c7
feat: add field typeOfTree in JsonRepository
RoketFlame Apr 24, 2023
4f019e6
fix: fix AVLNode
RoketFlame Apr 24, 2023
86ff2c0
feat: implement getNames for Neo4jRepo
RoketFlame Apr 26, 2023
297ad58
feat: implement very early visualizer for trees
RoketFlame Apr 27, 2023
05f8fa6
feat: update version of gradle, add building project on macOS and ubu…
RoketFlame Apr 28, 2023
445c8fa
feat: update properties for gradle, prepare for restructure of project
RoketFlame Apr 28, 2023
1c3d41a
struct: huge refactor, now project include lib (with trees and reposi…
RoketFlame Apr 28, 2023
934d808
feat: add comments to code to `repository` part
RoketFlame Apr 29, 2023
2b6eb36
feat: add comments to code to `trees` package
RoketFlame Apr 29, 2023
17c8217
fix: update CI script
RoketFlame Apr 29, 2023
ead2d74
hotfix: update README
RoketFlame Apr 29, 2023
f25ab8a
feat: simplify work with JsonRepository, update dependencies
RoketFlame May 1, 2023
868ae7a
feat: first version of App, so dirty code (sorry)
RoketFlame May 1, 2023
32e3c97
feat: first version of App, so dirty code (sorry)
RoketFlame May 1, 2023
2cb077d
feat: simplify some cast expressions
RoketFlame May 2, 2023
9672f88
feat: add some checks for correct opening tree
RoketFlame May 2, 2023
97f923f
feat: add a button to return to the home screen
RoketFlame May 2, 2023
c99838f
fix: fix name of text fields
RoketFlame May 2, 2023
f276c79
feat: update CONTRIBUTING.md, DOCS.md, LICENSE and README.md
RoketFlame May 2, 2023
8d4c82d
feat: update README.md, add tips for using viewer
RoketFlame May 2, 2023
cf27697
fix: fix bug with empty key field
RoketFlame May 2, 2023
0b7e482
fix: Change licence of stolen files
RoketFlame May 3, 2023
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

30 changes: 30 additions & 0 deletions .github/mergeable.yml
Original file line number Diff line number Diff line change
@@ -0,0 +1,30 @@
version: 2
mergeable:
- when: pull_request.*, pull_request_review.*
filter:
# ignore 'Feedback' PR
- do: payload
pull_request:
title:
must_exclude:
regex: ^Feedback$
regex_flag: none
validate:
- do: description
no_empty:
enabled: true
message: "Description matter and should not be empty. Provide detail with **what** was changed, **why** it was changed, and **how** it was changed."
- do: approvals
min:
count: 1
required:
assignees: true

- when: pull_request.opened
name: "Remind about contributing guidelines"
validate: [ ]
pass:
- do: comment
payload:
body: >
Thanks for creating a pull request! Please, check that your pull request meets the [CONTRIBUTING](./CONTRIBUTING.md) requirements.
30 changes: 30 additions & 0 deletions .github/workflows/github-actions.yml
Original file line number Diff line number Diff line change
@@ -0,0 +1,30 @@
name: Build CI

on:
pull_request:
branches:
- main
- release

permissions:
contents: read

jobs:
build:
runs-on: ${{ matrix.os }}

strategy:
matrix:
os: [ macos-latest, ubuntu-latest, windows-latest ]

steps:
- uses: actions/checkout@v3
- name: Set up JDK 17
uses: actions/setup-java@v3
with:
java-version: '17'
distribution: zulu
- name: Build & test with Gradle
uses: gradle/gradle-build-action@v2
with:
arguments: build
51 changes: 51 additions & 0 deletions .gitignore
Original file line number Diff line number Diff line change
@@ -0,0 +1,51 @@
.gradle
build/
!gradle/wrapper/gradle-wrapper.jar
!**/src/main/**/build/
!**/src/test/**/build/
### IntelliJ IDEA ###
.idea/modules.xml
.idea/jarRepositories.xml
.idea/compiler.xml
.idea/libraries/
*.iws
*.iml
*.ipr
out/
!**/src/main/**/out/
!**/src/test/**/out/

### Eclipse ###
.apt_generated
.classpath
.factorypath
.project
.settings
.springBeans
.sts4-cache
bin/
!**/src/main/**/bin/
!**/src/test/**/bin/

### NetBeans ###
/nbproject/private/
/nbbuild/
/dist/
/nbdist/
/.nb-gradle/

### VS Code ###
.vscode/

### Mac OS ###
.DS_Store
/.idea/.name
/.idea/gradle.xml
/.idea/kotlinc.xml
/.idea/misc.xml
/.idea/vcs.xml
/.idea/

# Ignore Gradle build output directory
build
/app/build
39 changes: 39 additions & 0 deletions CONTRIBUTING.md
Original file line number Diff line number Diff line change
@@ -0,0 +1,39 @@
# Making edits

## Basic Tips

Choose a reason for hiding this comment

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

Не говорите что НЕ нужно делать, лучше предоставьте примерный пайплайн человеку, который хочет контрибьютить. Можно сказать, что вы используете Github Flow, поэтому все изменения принимаются через ПР'ы, расскажите о возможных требованиях к названию ветки из мастера. Если новый код требует тестов, нужно ли добавить тесты, если изменилось API, нужно ли обновить документацию? Попросите человека проверить, что его код удовлетворяет принятому в проекте codestyle и приложите ссылку, если таковой имеется.

1. Don't use merge, only rebase (to keep a linear commit history)
2. Do not change other people's branches unless absolutely necessary
3. Recheck your commit history before creating a pull request
4. **Check you're on the right branch**, never commit directly in main

## Rules for adding commits

Commits are added according to conventional commits. Those
`<type>(<scope>): <body>`.

The `<type>` field must take one of these values:

* `feat` to add new functionality
* `fix` to fix a bug in the program
* `refactor` for code refactoring, such as renaming a variable
* `test` to add tests, refactor them
* `struct` for changes related to a change in the structure of the project (BUT NOT CODE), for example, changing
folder locations
* `ci` for various ci/cd tasks

The `<body>` field contains the gist of the changes in the present imperative in English without the dot in
at the end, the first word is a verb with a small letter.
Examples:

* Good: "feat: Add module for future BST implementations"
* Bad: "Added module for future BST implementations."

Choose a reason for hiding this comment

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

Вся остальная документация на английском, почему здесь не так?

## Rules for pull requests

**Forbidden** to merge your pull request into the branch yourself.

If you click on the green button, then **make sure** that it says `REBASE AND MERGE`

The review takes place in the form of comments to pull requests, discussions in the team chat and personal
communication.
111 changes: 111 additions & 0 deletions DOCS.md
Original file line number Diff line number Diff line change
@@ -0,0 +1,111 @@
## Getting started

To build the library run

```bash
./gradlew build
```

## Using Trees

Any `Comparable` data can be stored in trees.
We also provide access to the `KeyValue` class, which allows you to store a key-value pair in the nodes of the tree.

```kotlin
import lib.trees.AVLTree
import lib.trees.RBTree
import lib.trees.BSTree
import lib.trees.KeyValue

val alvTree = AVLTree<Int>() // instantiate empty AVL tree
val bsTree = BSTree<String>() // instantiate empty simple tree
val rbTree = RBTree<KeyValue<Int, String>>() // instantiate empty red-black tree with key-value
```

Each tree supports 3 basic operations: `add`, `contain`, `delete` and `get` (if you need to get value by key using
KeyValue)

```kotlin
avlTree.add(42)
bsTree.add("42")
rbTree.add(KeyValue(42, "42"))
bsTree.contain("42") // returns true
avlTree.contain(1) // returns false
rbTree.get(KeyValue(42, null))?.getValue() // returns "42"
```

Trees' nodes can be read-only accessed by `root` property.

```kotlin
avlTree.add(10)
avlTree.add(5)
avlTree.add(20)
avlTree.add(30)
avlTree.add(42)
// avlTree after balancing:
// 10
// ┌─────────┴─────────┐
// 5 30
// ┌──┴──┐
// 20 42

avlTree.root?.data // 10
avlTree.root?.left?.data // 5
avlTree.root?.right?.data // 30
avlTree.root?.right?.right?.data // 42
avlTree.root?.right?.left?.data // 20
```

## Storing Trees

`teemEight` provides `JsonRepository`, `SqlRepository` and `Neo4jRepository` to save & load trees.

Each instance of repository is used to store exactly 1 tree type. To store different tree types several repositories can
be instantiated.
Repository must be provided with `Serialization` which describes how to serialize & deserialize any particular
type of tree.

`bstrees` is shipped with `AVLStrategy`, `RBStrategy` and `SimpleStrategy` to serialize & deserialize AVL trees,
Red-black trees and Simple BSTs respectively. As these strategies don't know anything about the data type stored in
trees' nodes, user must provide `serializeData` and `deserializeData` functions to them.

Different tree types can be stored in the same database (directory) by creating several repositories and passing them
same databases (directory paths).

### Using Neo4j

Before using this, you must have [Docker](https://www.docker.com/) (also see [docs](https://docs.docker.com/))

#### Before started

1. Run docker container with `docker-compose.yml`
2. Open http://localhost:7474
3. Create new user (default password: neo4j)
4. Change the password
5. You got this

#### Example

```kotlin
val username = "neo4j"
val password = "" // insert password to database here
val conf = Configuration.Builder()
.uri("bolt://localhost")
.credentials(username, password)
.build()

fun serializeInt(data: Int) = SerializableValue(data.toString())

fun deserializeInt(data: SerializableValue) = data.value.toInt()

val avlRepo = Neo4jRepo(AVLStrategy(::serializeInt, ::deserializeInt), conf)


val tree = AVLTree<Int>()
val randomizer = Random(42)
val lst = List(15) { randomizer.nextInt(1000) }
lst.forEach { tree.add(it) }
avlRepo.save("test", tree)
val testTree = avlRepo.loadByName("test")
println(testTree.preOrder()) // output pre-order traversal of tree
```

Choose a reason for hiding this comment

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

В доках обязательно нужно добавить раздел с приложением.

Loading