Rename poll to removeFirstOrNull

This is more consistent with the Kotlin standard library.

Signed-off-by: Graham <gpe@openrs2.org>
pull/132/head
Graham 3 years ago
parent 7d04774d60
commit 65194fae43
  1. 2
      deob-bytecode/src/main/kotlin/org/openrs2/deob/bytecode/analysis/DataFlowAnalyzer.kt
  2. 2
      deob-bytecode/src/main/kotlin/org/openrs2/deob/bytecode/transform/ConstantArgTransformer.kt
  3. 2
      deob-bytecode/src/main/kotlin/org/openrs2/deob/bytecode/transform/UnusedMethodTransformer.kt
  4. 2
      game/src/main/kotlin/org/openrs2/game/net/js5/Js5Service.kt
  5. 2
      util/src/main/kotlin/org/openrs2/util/collect/UniqueQueue.kt
  6. 16
      util/src/test/kotlin/org/openrs2/util/collect/UniqueQueueTest.kt

@ -50,7 +50,7 @@ public abstract class DataFlowAnalyzer<T>(owner: String, private val method: Met
workList += graph.vertexSet().filter { vertex -> graph.inDegreeOf(vertex) == 0 }
while (true) {
val node = workList.poll() ?: break
val node = workList.removeFirstOrNull() ?: break
val predecessors = graph.incomingEdgesOf(node).map { edge ->
outSets[graph.getEdgeSource(edge)] ?: initialSet

@ -72,7 +72,7 @@ public class ConstantArgTransformer @Inject constructor(private val profile: Pro
queueEntryPoints(classPath)
while (true) {
val method = pendingMethods.poll() ?: break
val method = pendingMethods.removeFirstOrNull() ?: break
analyzeMethod(classPath, method)
}
}

@ -31,7 +31,7 @@ public class UnusedMethodTransformer @Inject constructor(private val profile: Pr
queueEntryPoints(classPath)
while (true) {
val method = pendingMethods.poll() ?: break
val method = pendingMethods.removeFirstOrNull() ?: break
analyzeMethod(classPath, method)
}
}

@ -36,7 +36,7 @@ public class Js5Service @Inject constructor(
return
}
val next = clients.poll()
val next = clients.removeFirstOrNull()
if (next == null) {
lock.wait()
continue

@ -27,7 +27,7 @@ public class UniqueQueue<T> {
addAll(vs)
}
public fun poll(): T? {
public fun removeFirstOrNull(): T? {
val v = queue.removeFirstOrNull()
if (v != null) {
set.remove(v)

@ -8,15 +8,15 @@ import kotlin.test.assertTrue
class UniqueQueueTest {
@Test
fun testAddPoll() {
fun testAddRemove() {
val queue = UniqueQueue<String>()
assertTrue(queue.add("a"))
assertTrue(queue.add("b"))
assertFalse(queue.add("a"))
assertEquals("a", queue.poll())
assertEquals("b", queue.poll())
assertNull(queue.poll())
assertEquals("a", queue.removeFirstOrNull())
assertEquals("b", queue.removeFirstOrNull())
assertNull(queue.removeFirstOrNull())
}
@Test
@ -24,9 +24,9 @@ class UniqueQueueTest {
val queue = UniqueQueue<String>()
queue.addAll(listOf("a", "b", "a"))
assertEquals("a", queue.poll())
assertEquals("b", queue.poll())
assertNull(queue.poll())
assertEquals("a", queue.removeFirstOrNull())
assertEquals("b", queue.removeFirstOrNull())
assertNull(queue.removeFirstOrNull())
}
@Test
@ -36,6 +36,6 @@ class UniqueQueueTest {
queue.clear()
assertNull(queue.poll())
assertNull(queue.removeFirstOrNull())
}
}

Loading…
Cancel
Save