java - FIFO buffer with a limited capacity that overrides oldest elements -


this question has answer here:

i'm trying create fifo (first in first out) data structure in java, have limited capacity , remove oldest elements when there not enough space new ones. example:

fifo<integer> fifo = new fifo<integer>(100); // 100 elements maximum (int = 0; < 500; i++) {   fifo.write(i); } assert fifo.read() == 400; // elements 0..399 lost 

am re-inventing wheel? can recommend library (or maybe it's part of jdk) same? thread safety not important.

apache's common.collections has circularfifobuffer should meet requirements.


Comments

Popular posts from this blog

Why does Ruby on Rails generate add a blank line to the end of a file? -

node.js - Bad Request - node js ajax post -

uitableview - Create and use custom prototype table cells in xamarin ios using storyboard -