version 1.19, 2001/05/03 13:41:07 |
version 1.20, 2001/05/23 12:34:45 |
|
|
|
#ifndef _LST_H_ |
|
#define _LST_H_ |
|
|
/* $OpenPackages$ */ |
/* $OpenPackages$ */ |
/* $OpenBSD$ */ |
/* $OpenBSD$ */ |
/* $NetBSD: lst.h,v 1.7 1996/11/06 17:59:12 christos Exp $ */ |
/* $NetBSD: lst.h,v 1.7 1996/11/06 17:59:12 christos Exp $ */ |
|
|
* lst.h -- |
* lst.h -- |
* Header for using the list library |
* Header for using the list library |
*/ |
*/ |
#ifndef _LST_H_ |
|
#define _LST_H_ |
|
|
|
#include "sprite.h" |
|
#include <sys/param.h> |
#include <sys/param.h> |
#ifdef __STDC__ |
#ifdef __STDC__ |
#include <stdlib.h> |
#include <stdlib.h> |
|
|
/* These data structures are PRIVATE !!! |
/* These data structures are PRIVATE !!! |
* Here for efficiency, so that some functions can be recoded as inlines, |
* Here for efficiency, so that some functions can be recoded as inlines, |
* and so that lst headers don't need dynamic allocation most of the time. */ |
* and so that lst headers don't need dynamic allocation most of the time. */ |
typedef struct ListNode_ { |
struct ListNode_ { |
struct ListNode_ *prevPtr; /* previous element in list */ |
struct ListNode_ *prevPtr; /* previous element in list */ |
struct ListNode_ *nextPtr; /* next in list */ |
struct ListNode_ *nextPtr; /* next in list */ |
void *datum; /* datum associated with this element */ |
void *datum; /* datum associated with this element */ |
} *LstNode; |
}; |
|
|
typedef struct { |
#ifndef LIST_TYPE |
LstNode firstPtr; /* first node in list */ |
#include "lst_t.h" |
LstNode lastPtr; /* last node in list */ |
#endif |
} LIST; |
|
|
|
typedef LIST *Lst; |
|
|
|
typedef void (*SimpleProc)(void *); |
typedef void (*SimpleProc)(void *); |
typedef int (*FindProc)(void *, void *); |
typedef int (*FindProc)(void *, void *); |
typedef int (*FindProcConst)(void *, const void *); |
typedef int (*FindProcConst)(void *, const void *); |
|
|
extern void Lst_ForEachFrom(LstNode, ForEachProc, void *); |
extern void Lst_ForEachFrom(LstNode, ForEachProc, void *); |
extern void Lst_Every(Lst, SimpleProc); |
extern void Lst_Every(Lst, SimpleProc); |
|
|
extern ReturnStatus Lst_AddNew(Lst, void *); |
extern bool Lst_AddNew(Lst, void *); |
/* |
/* |
* for using the list as a queue |
* for using the list as a queue |
*/ |
*/ |
|
|
#define Lst_EnQueue Lst_AtEnd |
#define Lst_EnQueue Lst_AtEnd |
#define Lst_QueueNew Lst_AddNew |
#define Lst_QueueNew Lst_AddNew |
|
|
|
/* |
|
* for using the list as a stack |
|
*/ |
|
#define Lst_Push Lst_AtFront |
|
#define Lst_Pop Lst_DeQueue |
|
|
/* Remove an element from head of queue */ |
/* Remove an element from head of queue */ |
extern void * Lst_DeQueue(Lst); |
extern void * Lst_DeQueue(Lst); |
|
|
|
|
#define Lst_Rev(ln) ((ln)->prevPtr) |
#define Lst_Rev(ln) ((ln)->prevPtr) |
|
|
|
|
|
/* Inlines are preferable to macros here because of the type checking. */ |
#ifdef HAS_INLINES |
#ifdef HAS_INLINES |
static INLINE LstNode |
static INLINE LstNode |
Lst_FindConst(Lst l, FindProcConst cProc, const void *d) |
Lst_FindConst(Lst l, FindProcConst cProc, const void *d) |