A commit to save my soul as I'm going to fuck up things a bit...

This commit is contained in:
Song Minjae
2017-04-30 21:26:20 +09:00
parent 9a819ffec3
commit 4a6effff96
7 changed files with 508 additions and 182 deletions

View File

@@ -834,9 +834,9 @@ class StateInGame : BasicGameState() {
}
}
private fun ArrayList<out Actor>.binarySearch(actor: Actor) = this.binarySearch(actor.referenceID)
private fun ArrayList<*>.binarySearch(actor: Actor) = this.binarySearch(actor.referenceID)
private fun ArrayList<out Actor>.binarySearch(ID: Int): Int {
private fun ArrayList<*>.binarySearch(ID: Int): Int {
// code from collections/Collections.kt
var low = 0
var high = this.size - 1
@@ -844,11 +844,11 @@ class StateInGame : BasicGameState() {
while (low <= high) {
val mid = (low + high).ushr(1) // safe from overflows
val midVal = get(mid)
val midVal = get(mid)!!
if (ID > midVal.referenceID)
if (ID > midVal.hashCode())
low = mid + 1
else if (ID < midVal.referenceID)
else if (ID < midVal.hashCode())
high = mid - 1
else
return mid // key found