class CategorizedCircularBuffer {

    public void add(K key, T value) {
        // add to main list
        mainList.addFirst(new Pair<T, K>(key, value));
        while (mainList.size() > maxSize) {
            removeLastEntry();
        }

        LinkedList<T> typedList = typedLists.get(key);
        if (typedList == null) {
            typedList = new LinkedList<T>();
            typedLists.put(key, typedList);
        }
        typedList.addFirst(value);
    }

    public  CategorizedCircularBuffer(int maxCount);

}