/* > H.lru - LRU data type header file */

#ifndef __LRU_h
/*#define testing 1*/
#define __LRU_h

struct LRU
{
 void *head; /* pointer to head of LRU */
 void *tail; /* pointer to tail of LRU */
 int obj_size; /* size of one element */
 int size; /* number of elements in list */
};
typedef struct LRU *LRU;

#ifndef testing
#define LRU_size(d) ((d)->size)
#endif

#define MOST_RECENT 1
#define LEAST_RECENT 0

/* Private fields - don't look at these :-) */
struct link
{
 struct link *next;
 char data[1];
};

typedef struct link *link;

#define STATUS_CONTINUE 1
#define STATUS_QUIT 0

/* Return values from functions */

#define OK 1
#define ERR 0


#if defined(__STDC__) || defined(__cplusplus)
# define _P(s) s
#else
# define _P(s) ()
#endif


/* lru.c */
LRU LRU_new _P((int obj_len));
void LRU_free _P((LRU *d));
void LRU_clear _P((LRU *d));
int LRU_copy _P((LRU d1, const LRU d2));
int LRU_equal _P((const LRU d1, const LRU d2));
int LRU_empty _P((const LRU d));
int LRU_size _P((const LRU d));
int LRU_iterate _P((const LRU d, int (*process )(void *)));
int LRU_add _P((LRU d, int pos, const void *object));
int LRU_pop _P((LRU d, int pos));
int LRU_pop_most_recent _P((LRU d));
int LRU_pop_least_recent _P((LRU d));
void *LRU_most_recent _P((const LRU d));
void *LRU_least_recent _P((const LRU d));
int LRU_used _P((LRU d, const void *object));
int LRU_remove _P((LRU d, const void *object));
int print _P((void *ptr));
void LRU_dump _P((LRU d));

#undef _P

#endif
