https://kotlinlang.org logo
Title
u

ubu

07/13/2018, 2:50 PM
Hi there. Is there some alternative in
Kotlin
to Guava's
EvictingQueue
? https://google.github.io/guava/releases/15.0/api/docs/com/google/common/collect/EvictingQueue.html
f

fred.deschenes

07/13/2018, 3:00 PM
any reason you don't want to use the one in Guava?
u

ubu

07/13/2018, 3:02 PM
@fred.deschenes, I'm removing Guava from Android Project, I've just this one method left.
f

fred.deschenes

07/13/2018, 3:06 PM
I guess you could make your own, Guava's EvictingQueue is just a wrapper around an ArrayDeque
u

ubu

07/13/2018, 3:22 PM
@fred.deschenes, I guess I should override only
add()
method, something like:
override fun add(element: E): Boolean {

        if (size == buffer) {
            super.removeFirst()
        }

        return super.add(element)
    }
f

fred.deschenes

07/13/2018, 3:24 PM
depends on how you use it, there's also
addAll
and
offer
. I've never used EvictingQueue myself so I'm not really sure what you absolutely need to overload
u

ubu

07/13/2018, 6:23 PM
thanks anyway