Open-source multiplayer game server compatible with the RuneScape client
https://www.openrs2.org/
You can not select more than 25 topics
Topics must start with a letter or number, can include dashes ('-') and can be up to 35 characters long.
25 lines
480 B
25 lines
480 B
package org.openrs2.util.collect
|
|
|
|
public class UniqueQueue<T> {
|
|
private val queue = ArrayDeque<T>()
|
|
private val set = mutableSetOf<T>()
|
|
|
|
public fun add(v: T): Boolean {
|
|
if (set.add(v)) {
|
|
queue.addLast(v)
|
|
return true
|
|
}
|
|
|
|
return false
|
|
}
|
|
|
|
public fun poll(): T? {
|
|
val v = queue.removeFirstOrNull()
|
|
if (v != null) {
|
|
set.remove(v)
|
|
return v
|
|
}
|
|
|
|
return null
|
|
}
|
|
}
|
|
|