Etienne Neveu Etienne Neveu - 9 months ago 65
Java Question

Is there a Guava equivalent to Apache Commons CircularFifoBuffer?

I need a data structure that can efficiently buffer a specific number of elements, in FIFO order.

As mentioned in this question, Apache Commons has a CircularFifoBuffer, but it is sadly not generified. Some forks exist, but I'm not sure of their maintenance status.

Since Guava is the go-to library for my collection needs, I'm wondering: is there a good alternative in Guava? If not, should I implement it in my project, based on Apache Commons' CircularFifoBuffer?

Answer Source

Starting Guava 15.0 - you can use EvictingQueue