java - FIFO buffer with a limited capacity that overrides oldest elements -
this question has answer here:
- java - ring buffer 8 answers
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
Post a Comment