Hi, is there a First In First Out collection in Ko...
# getting-started
a
Hi, is there a First In First Out collection in Kotlin which we can set a limited size ?
g
Have you looked into buffered `Channel`s? Not exactly a collection but it could be better. Otherwise you could try something like this but with an array implementation
a
Queue is a good option (since there is no requirement for thread blocking in your question): https://docs.oracle.com/javase/tutorial/collections/implementations/queue.html
a
I found out about
ArrayDeque
in the documentation, maybe it's what I need ? It's for storing little data classes with 100 maximum items to keep RAM consuption small
👍 1
s
ArrayDeque is definitely what I’d use instead of the older Queue or LinkedList classes to implement this, but I don’t think there are any stdlib data structures with a capacity-based eviction policy built in