Signed-off-by: Graham <gpe@openrs2.org>
@ -13,6 +13,20 @@ public class UniqueQueue<T> {
return false
}
public operator fun plusAssign(v: T) {
add(v)
public fun addAll(vs: Iterable<T>) {
for (v in vs) {
public operator fun plusAssign(vs: Iterable<T>) {
addAll(vs)
public fun poll(): T? {
val v = queue.removeFirstOrNull()
if (v != null) {
@ -22,4 +36,9 @@ public class UniqueQueue<T> {
return null
public fun clear() {
queue.clear()
set.clear()
@ -18,4 +18,24 @@ class UniqueQueueTest {
assertEquals("b", queue.poll())
assertNull(queue.poll())
@Test
fun testAddAll() {
val queue = UniqueQueue<String>()
queue.addAll(listOf("a", "b", "a"))
assertEquals("a", queue.poll())
fun testClear() {
assertTrue(queue.add("a"))