Does anybody know if there is existing Java data structure where elements are automatically removed from it based on the delay for each element? In other words, each element has its own ttl.
For example:
public class DataStructureWithDelay {
void add(Object element, long delay) {}
// After delay expires element will be removed from data structure automatically
}
DataStructureWithDelay dataStructure = new DataStructureWithDelay()
dataStructure.add(element, 10000L)