!7
// by default, elements are put to front when added
// (not when accessed)
sclass MRUCache extends LinkedHashMap {
int maxSize = 10;
*() {}
*(int *maxSize) {}
protected bool removeEldestEntry(Map.Entry eldest) {
ret size() > maxSize;
}
}
p {
MRUCache cache = new(10);
for (S word : words2(loadSnippet(#1008407)))
cache.put(word, toInt(cache.get(word))+1);
pnl(cache);
}