From 466716917d17f9c7acdc8eed9832558882f8b8fe Mon Sep 17 00:00:00 2001 From: Gabriel Tofvesson Date: Mon, 27 Sep 2021 01:11:33 +0200 Subject: [PATCH] Override indexOf implementation for sorted collections --- src/main/kotlin/SortedList.kt | 3 +++ 1 file changed, 3 insertions(+) diff --git a/src/main/kotlin/SortedList.kt b/src/main/kotlin/SortedList.kt index a4c617a..9ff0439 100644 --- a/src/main/kotlin/SortedList.kt +++ b/src/main/kotlin/SortedList.kt @@ -46,6 +46,9 @@ open class SortedList constructor( open fun contains(element: E, searchForward: Boolean) = search(element, searchForward) >= 0 override fun contains(element: E) = contains(element, true) + override fun indexOf(element: E) = search(element, true) + override fun lastIndexOf(element: E) = search(element, false) + override fun containsAll(elements: Collection) = containsAll(elements, true) open fun containsAll(elements: Collection, searchForward: Boolean): Boolean { for (element in elements)