5 * A simple most-recently-used cache, backed by a doubly-linked list.
9 * // Create a list. Zero-initialization is required.
10 * static struct mru cache;
11 * mru_append(&cache, item);
14 * // Iterate in MRU order.
15 * struct mru_entry *p;
16 * for (p = cache.head; p; p = p->next) {
17 * if (matches(p->item))
21 * // Mark an item as used, moving it to the front of the list.
22 * mru_mark(&cache, p);
24 * // Reset the list to empty, cleaning up all resources.
27 * Note that you SHOULD NOT call mru_mark() and then continue traversing the
28 * list; it reorders the marked item to the front of the list, and therefore
29 * you will begin traversing the whole list again.
34 struct mru_entry *prev, *next;
38 struct mru_entry *head, *tail;
41 void mru_append(struct mru *mru, void *item);
42 void mru_mark(struct mru *mru, struct mru_entry *entry);
43 void mru_clear(struct mru *mru);