Skip to content

Commit

Permalink
really fix, sloppy
Browse files Browse the repository at this point in the history
  • Loading branch information
sanity committed Apr 21, 2017
1 parent 58b25ee commit 748fe30
Show file tree
Hide file tree
Showing 2 changed files with 3 additions and 3 deletions.
2 changes: 1 addition & 1 deletion build.gradle
Original file line number Diff line number Diff line change
@@ -1,5 +1,5 @@
group 'com.github.sanity'
version '0.2.6'
version '0.2.7'

buildscript {
ext.kotlin_version = '1.1.1'
Expand Down
4 changes: 2 additions & 2 deletions src/main/kotlin/com/github/sanity/shoebox/OrderedViewSet.kt
Original file line number Diff line number Diff line change
Expand Up @@ -14,15 +14,15 @@ class OrderedViewSet<T : Any>(val view : View<T>, val viewKey : String, val comp

init {
val ol = ArrayList<KeyValue<T>>()
val kvComparator : Comparator<KeyValue<T>> = Comparator<KeyValue<T>> { o1, o2 -> comparator.thenBy { o1.key.compareTo(o2.key) }.compare(o1.value, o2.value) }
val kvComparator : Comparator<KeyValue<T>> = Comparator<KeyValue<T>> { o1, o2 -> comparator.compare(o1.value, o2.value) }.thenBy(KeyValue<T>::key)
ol.addAll(view.getKeyValues(viewKey))
ol.sortWith(kvComparator)
orderedList = ol
additionHandle = view.onAdd(viewKey) { keyValue ->
val binarySearchResult = orderedList.betterBinarySearch(keyValue, kvComparator)
val insertionPoint: Int = when (binarySearchResult) {
is BinarySearchResult.Exact -> {
throw RuntimeException("Listener called for key/value already in list ($keyValue)")
throw RuntimeException("Listener called for key/value already in list keyValue: $keyValue orderedList[${binarySearchResult.index}] = ${orderedList[binarySearchResult.index]}")
}
is BinarySearchResult.Between -> binarySearchResult.highIndex
}
Expand Down

0 comments on commit 748fe30

Please sign in to comment.