Hi there. Is there some alternative in `Kotlin` to...
# announcements
u
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
any reason you don't want to use the one in Guava?
u
@fred.deschenes, I'm removing Guava from Android Project, I've just this one method left.
f
I guess you could make your own, Guava's EvictingQueue is just a wrapper around an ArrayDeque
u
@fred.deschenes, I guess I should override only
add()
method, something like:
Copy code
override fun add(element: E): Boolean {

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

        return super.add(element)
    }
f
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
thanks anyway