📄 osplist.h
字号:
/**########################################################################*########################################################################*########################################################################* * COPYRIGHT (c) 1998, 1999 by TransNexus, LLC * * This software contains proprietary and confidential information * of TransNexus, LLC. Except as may be set forth in the license * agreement under which this software is supplied, use, disclosure, * or reproduction is prohibited without the prior, express, written* consent of TransNexus, LLC. * *******#########################################################################*#########################################################################*#########################################################################*//* * osplist.h - Structures and prototypes for linked lists. */#ifndef osplist_h#define osplist_h#include "osp.h"/* * This module provides simple, linked list utility functions * used through the OSP library. This file defines the two * structures used to manipulate lists. The ListLink structure * contains the information needed to maintain the linked * list. IT MUST BE THE FIRST FIELD OF ANY STRUCTURE THAT * IS TO MAINTAINED IN A LIST. The second structure is the * List structure, which holds the pointers to the elements * that make up the list. Note that, a la Knuth, the List * structure actually points to the last item on the list, * which is then circularly linked to the first item. This * approach minimizes the time needed to find either the * front (2 memory references) or back (1 memory reference) * of the list. */typedef struct OSPSListLink{ struct OSPSListLink *ospmLinkNext;}OSPTLISTLINK;typedef OSPTLISTLINK *OSPTLIST;/**//*-----------------------------------------------------------------------*//* macros that emulate functions *//*-----------------------------------------------------------------------*/#ifndef OSPC_DEBUG/* * Note: all macros are also implemented as functions in osplist.c. For * implementation details, see the comments in that file. To replace a * macro with a true function, simply comment out the macro definition * below. */#define OSPPListLinkNew(ospvLink) ((ospvLink)->ospmLinkNext = OSPC_OSNULL)#define OSPPListLinkDelete(ospvLink) ((ospvLink)->ospmLinkNext = OSPC_OSNULL)#define OSPPListLinkIsolated(ospvLink) ((ospvLink)->ospmLinkNext == OSPC_OSNULL)#define OSPPListNew(ospvList) (*(ospvList) = OSPC_OSNULL)#define OSPPListDelete(ospvList) (*(ospvList) = OSPC_OSNULL)#define OSPPListEmpty(ospvList) (*ospvList == OSPC_OSNULL)#define OSPPListLast(ospvList) (*(ospvList))#define OSPPListFirst(ospvList) (OSPPListEmpty(ospvList) ? \ (OSPTLISTLINK *) OSPC_OSNULL : ((OSPTLISTLINK *)(*(ospvList)))->ospmLinkNext)#define OSPPListNext(ospvList,ospvItem) \ ( (OSPPListLast(ospvList)==((void *)(ospvItem))) ? OSPC_OSNULL : \ ((void *)((OSPTLISTLINK *)(ospvItem))->ospmLinkNext) )#define OSPPListMove(ospvDst,ospvSrc) \ { *(ospvDst) = *(ospvSrc); OSPPListNew(ospvSrc); }#endif/**//*-----------------------------------------------------------------------*//* true macros *//*-----------------------------------------------------------------------*/#define OSPPListItemInList(List,InItem,ItemFld,ItemSize,PtrType,Found) { \ PtrType *item = OSPC_OSNULL; \ int result = 0; \ for (item = (PtrType *)OSPPListFirst(List); item != OSPC_OSNULL; \ item = (PtrType *)OSPPListNext(List, item)) \ { \ result = OSPM_MEMCMP(InItem->ItemFld, item->ItemFld, ItemSize); \ if (result == 0) \ { \ Found = OSPC_TRUE; \ break; \ } \ } \}/**//*-----------------------------------------------------------------------*//* function prototypes *//*-----------------------------------------------------------------------*/#ifdef __cplusplusextern "C" {#endif void OSPPListAppend (OSPTLIST *, void *); void *OSPPListRemove (OSPTLIST *); void *OSPPListRemoveSpecificItem (OSPTLIST *, void *); unsigned OSPPListCount(OSPTLIST *); void *OSPPListNextToLast(OSPTLIST *);#ifdef OSPC_DEBUG void OSPPListLinkNew (OSPTLISTLINK *); void OSPPListLinkDelete (OSPTLISTLINK *); unsigned OSPPListLinkIsolated (OSPTLISTLINK *); void OSPPListNew (OSPTLIST *); void OSPPListDelete (OSPTLIST *); unsigned OSPPListEmpty (OSPTLIST *); void *OSPPListLast (OSPTLIST *); void *OSPPListFirst (OSPTLIST *); void *OSPPListNext (OSPTLIST *, void *); void OSPPListMove (OSPTLIST *, OSPTLIST *);#endif /* OSPC_DEBUG */#ifdef __cplusplus}#endif#endif /* osplist_h */
⌨️ 快捷键说明
复制代码
Ctrl + C
搜索代码
Ctrl + F
全屏模式
F11
切换主题
Ctrl + Shift + D
显示快捷键
?
增大字号
Ctrl + =
减小字号
Ctrl + -