This is library that implements a cache using my fib and btree libraries. You must have both of the libraries installed in order to use this library.
The library uses the B-tree to store data and look it up. It also maintains a fibonacci heap to keep track of the least used elements.
libcache is not a very complex library to use. It takes data as the opaque data type of c_data_t (which is just a void *). A compare function taking two c_data_t's and returning an int is required to keep the btree in order.
typedef void *c_data_t
Opque user data
typedef int (*cmp_fun)(c_data_t, c_data_t)
A function pointer to be called on two datums
struct cache *lc_create(cmp_fun)
Create the cache using cmp_fun to compare all added data
c_data_t lc_insert(struct cache *, c_data_t)
Insert the c_data_t into the cache
c_data_t lc_find(struct cache *, c_data_t)
Return the c_data_t that is equal to the argument in the cache. You pass in a partially filled data that your compare function will compare equal with the datum that you want. The return is the data that matches in the tree, or NULL if the datum can not be found. lc_find will also move the datum return to the bottom of the stack.
c_data_t lc_delmin(struct cache *)
Returns the oldest datum in the cache.
int lc_num(struct cache *)
Returns the total nubmer of datums in the cache.