diff --git a/build.gradle.kts b/build.gradle.kts index 334f030..7381e5d 100644 --- a/build.gradle.kts +++ b/build.gradle.kts @@ -22,7 +22,7 @@ dependencies { testImplementation(Config.Libs.junit) testImplementation(Config.Libs.kluent) testImplementation(Config.Libs.mockk) - testImplementation (Config.Libs.jetbrainJunit) + testImplementation(Config.Libs.jetbrainJunit) // testImplementation(Config.Libs.spekDsl) testRuntimeOnly(Config.Libs.junitEngine) diff --git a/src/main/kotlin/it/norangeb/algorithms/datastructures/dictionary/ImmutableBST.kt b/src/main/kotlin/it/norangeb/algorithms/datastructures/dictionary/ImmutableBST.kt index 7abbb70..8794e84 100644 --- a/src/main/kotlin/it/norangeb/algorithms/datastructures/dictionary/ImmutableBST.kt +++ b/src/main/kotlin/it/norangeb/algorithms/datastructures/dictionary/ImmutableBST.kt @@ -25,7 +25,11 @@ package it.norangeb.algorithms.datastructures.dictionary -import arrow.core.* +import arrow.core.getOrElse +import arrow.core.None +import arrow.core.Option +import arrow.core.Some +import arrow.core.toOption class ImmutableBST, V> : OrderedDictionary { private var root: Option> = None @@ -47,7 +51,8 @@ class ImmutableBST, V> : OrderedDictionary { private fun set( node: Option>, - key: K, value: V + key: K, + value: V ): Option> = node.fold( { Node(key, value) }, { diff --git a/src/test/kotlin/it/norangeb/algorithms/datastructures/bag/LinkedListBagTest.kt b/src/test/kotlin/it/norangeb/algorithms/datastructures/bag/LinkedListBagTest.kt index aa193ff..bc3787a 100644 --- a/src/test/kotlin/it/norangeb/algorithms/datastructures/bag/LinkedListBagTest.kt +++ b/src/test/kotlin/it/norangeb/algorithms/datastructures/bag/LinkedListBagTest.kt @@ -30,7 +30,7 @@ import org.junit.jupiter.api.BeforeEach import org.junit.jupiter.api.Test class LinkedListBagTest { - private lateinit var bag :LinkedListBag + private lateinit var bag: LinkedListBag @BeforeEach fun init() { diff --git a/src/test/kotlin/it/norangeb/algorithms/datastructures/bag/ResizingArrayBagTest.kt b/src/test/kotlin/it/norangeb/algorithms/datastructures/bag/ResizingArrayBagTest.kt index c94f3c2..8feca71 100644 --- a/src/test/kotlin/it/norangeb/algorithms/datastructures/bag/ResizingArrayBagTest.kt +++ b/src/test/kotlin/it/norangeb/algorithms/datastructures/bag/ResizingArrayBagTest.kt @@ -30,7 +30,7 @@ import org.junit.jupiter.api.BeforeEach import org.junit.jupiter.api.Test class ResizingArrayBagTest { - private lateinit var bag :ResizingArrayBag + private lateinit var bag: ResizingArrayBag @BeforeEach fun makeBag() { diff --git a/src/test/kotlin/it/norangeb/algorithms/datastructures/dictionary/ImmutableBSTTest.kt b/src/test/kotlin/it/norangeb/algorithms/datastructures/dictionary/ImmutableBSTTest.kt index b999f12..8706e27 100644 --- a/src/test/kotlin/it/norangeb/algorithms/datastructures/dictionary/ImmutableBSTTest.kt +++ b/src/test/kotlin/it/norangeb/algorithms/datastructures/dictionary/ImmutableBSTTest.kt @@ -32,7 +32,6 @@ import org.amshove.kluent.`should be` import org.amshove.kluent.shouldEqual import org.junit.jupiter.api.Test - class ImmutableBSTTest { @Test @@ -42,8 +41,8 @@ class ImmutableBSTTest { orderedMap.isEmpty() `should be` true orderedMap.size() `should be equal to` 0 orderedMap.contains("UNO") `should be` false - orderedMap.max() shouldEqual None - orderedMap.min() shouldEqual None + orderedMap.max() shouldEqual None + orderedMap.min() shouldEqual None orderedMap["QUATTRO"] = 4 orderedMap["UNO"] = 0 @@ -84,25 +83,25 @@ class ImmutableBSTTest { orderedMap.size() `should be equal to` 9 - //delete node with no child + // delete node with no child orderedMap.delete(1) orderedMap.size() `should be equal to` 8 - orderedMap.min() shouldEqual Some(2) + orderedMap.min() shouldEqual Some(2) - //delete node with only right child + // delete node with only right child orderedMap.delete(2) orderedMap.size() `should be equal to` 7 - orderedMap.min() shouldEqual Some(3) + orderedMap.min() shouldEqual Some(3) - //delete node with two child + // delete node with two child orderedMap.delete(10) orderedMap.size() `should be equal to` 6 orderedMap.delete(13) - //delete node with only left child + // delete node with only left child orderedMap.delete(11) orderedMap.size() `should be equal to` 4 diff --git a/src/test/kotlin/it/norangeb/algorithms/datastructures/queue/LinkedListQueueTest.kt b/src/test/kotlin/it/norangeb/algorithms/datastructures/queue/LinkedListQueueTest.kt index 43ca44d..834484d 100644 --- a/src/test/kotlin/it/norangeb/algorithms/datastructures/queue/LinkedListQueueTest.kt +++ b/src/test/kotlin/it/norangeb/algorithms/datastructures/queue/LinkedListQueueTest.kt @@ -33,7 +33,7 @@ import org.junit.jupiter.api.BeforeEach import org.junit.jupiter.api.Test class LinkedListQueueTest { - private lateinit var queue : LinkedListQueue + private lateinit var queue: LinkedListQueue @BeforeEach fun makeQueue() { diff --git a/src/test/kotlin/it/norangeb/algorithms/datastructures/queue/ResizingArrayQueueTest.kt b/src/test/kotlin/it/norangeb/algorithms/datastructures/queue/ResizingArrayQueueTest.kt index 2bea52f..9ec6bd3 100644 --- a/src/test/kotlin/it/norangeb/algorithms/datastructures/queue/ResizingArrayQueueTest.kt +++ b/src/test/kotlin/it/norangeb/algorithms/datastructures/queue/ResizingArrayQueueTest.kt @@ -33,7 +33,7 @@ import org.junit.jupiter.api.BeforeEach import org.junit.jupiter.api.Test class ResizingArrayQueueTest { - private lateinit var queue : ResizingArrayQueue + private lateinit var queue: ResizingArrayQueue @BeforeEach fun makeQueue() { diff --git a/src/test/kotlin/it/norangeb/algorithms/datastructures/stack/LinkedListStackTest.kt b/src/test/kotlin/it/norangeb/algorithms/datastructures/stack/LinkedListStackTest.kt index 9635af4..6414f8a 100644 --- a/src/test/kotlin/it/norangeb/algorithms/datastructures/stack/LinkedListStackTest.kt +++ b/src/test/kotlin/it/norangeb/algorithms/datastructures/stack/LinkedListStackTest.kt @@ -32,7 +32,7 @@ import org.junit.jupiter.api.BeforeEach import org.junit.jupiter.api.Test class LinkedListStackTest { - private lateinit var stack : LinkedListStack + private lateinit var stack: LinkedListStack @BeforeEach fun init() { diff --git a/src/test/kotlin/it/norangeb/algorithms/datastructures/unionfind/QuickFindTest.kt b/src/test/kotlin/it/norangeb/algorithms/datastructures/unionfind/QuickFindTest.kt index 986a886..2cd0f1c 100644 --- a/src/test/kotlin/it/norangeb/algorithms/datastructures/unionfind/QuickFindTest.kt +++ b/src/test/kotlin/it/norangeb/algorithms/datastructures/unionfind/QuickFindTest.kt @@ -30,7 +30,7 @@ import org.junit.jupiter.api.BeforeEach import org.junit.jupiter.api.Test class QuickFindTest { - private lateinit var unionFind : QuickFind + private lateinit var unionFind: QuickFind @BeforeEach fun init() { diff --git a/src/test/kotlin/it/norangeb/algorithms/datastructures/unionfind/QuickUnionCompressionPathTest.kt b/src/test/kotlin/it/norangeb/algorithms/datastructures/unionfind/QuickUnionCompressionPathTest.kt index 885e31c..7fa840a 100644 --- a/src/test/kotlin/it/norangeb/algorithms/datastructures/unionfind/QuickUnionCompressionPathTest.kt +++ b/src/test/kotlin/it/norangeb/algorithms/datastructures/unionfind/QuickUnionCompressionPathTest.kt @@ -30,7 +30,7 @@ import org.junit.jupiter.api.BeforeEach import org.junit.jupiter.api.Test class QuickUnionCompressionPathTest { - private lateinit var unionFind : QuickUnion + private lateinit var unionFind: QuickUnion @BeforeEach fun init() { diff --git a/src/test/kotlin/it/norangeb/algorithms/datastructures/unionfind/QuickUnionTest.kt b/src/test/kotlin/it/norangeb/algorithms/datastructures/unionfind/QuickUnionTest.kt index 1d500b3..8f30fe9 100644 --- a/src/test/kotlin/it/norangeb/algorithms/datastructures/unionfind/QuickUnionTest.kt +++ b/src/test/kotlin/it/norangeb/algorithms/datastructures/unionfind/QuickUnionTest.kt @@ -30,7 +30,7 @@ import org.junit.jupiter.api.BeforeEach import org.junit.jupiter.api.Test class QuickUnionTest { - private lateinit var unionFind : QuickUnion + private lateinit var unionFind: QuickUnion @BeforeEach fun init() { diff --git a/src/test/kotlin/it/norangeb/algorithms/datastructures/unionfind/QuickUnionWithSizeTest.kt b/src/test/kotlin/it/norangeb/algorithms/datastructures/unionfind/QuickUnionWithSizeTest.kt index f388811..1065ef4 100644 --- a/src/test/kotlin/it/norangeb/algorithms/datastructures/unionfind/QuickUnionWithSizeTest.kt +++ b/src/test/kotlin/it/norangeb/algorithms/datastructures/unionfind/QuickUnionWithSizeTest.kt @@ -30,7 +30,7 @@ import org.junit.jupiter.api.BeforeEach import org.junit.jupiter.api.Test class QuickUnionWithSizeTest { - private lateinit var unionFind : QuickUnionWithSize + private lateinit var unionFind: QuickUnionWithSize @BeforeEach fun init() {