Leaked source code of windows server 2003
You can not select more than 25 topics Topics must start with a letter or number, can include dashes ('-') and can be up to 35 characters long.

74 lines
2.0 KiB

  1. /* (C) 1997 Microsoft Corp.
  2. *
  3. * file : SList.h
  4. * authors : Christos Tsollis, Erik Mavrinac
  5. *
  6. * description: Interface definition to a dynamically-resizing list/queue
  7. * data type. The "key" values in the list are unsigned ints of whatever the
  8. * default word size is, so the elements of the array will be word-aligned.
  9. * These elements can be cast into whatever form is needed. Associated is
  10. * a void * for data asssociated with the "key".
  11. */
  12. #ifndef __SLIST_H
  13. #define __SLIST_H
  14. /*
  15. * Types
  16. */
  17. typedef struct
  18. {
  19. unsigned Key;
  20. void *Value;
  21. } _SListNode;
  22. typedef struct {
  23. unsigned NEntries; // current # of entries in the list
  24. unsigned MaxEntries; // max # of entries that the array can hold
  25. unsigned HeadOffset; // Offset of the 1st entry in the circular array
  26. unsigned CurrOffset; // Iterator value
  27. _SListNode *Entries; // Circular array of entries
  28. } SList, *PSList;
  29. /*
  30. * API prototypes.
  31. */
  32. BOOLEAN SListAppend(PSList, unsigned, void *);
  33. void SListDestroy(PSList);
  34. BOOLEAN SListGetByKey(PSList, unsigned, void **);
  35. void SListInit(PSList, unsigned);
  36. BOOLEAN SListIterate(PSList, unsigned *, void **);
  37. BOOLEAN SListPrepend(PSList, unsigned, void *);
  38. void SListRemove(PSList, unsigned, void **);
  39. void SListRemoveFirst(PSList, unsigned *, void **);
  40. void SListRemoveLast(PSList, unsigned *, void **);
  41. /*
  42. * API functions implemented as macros.
  43. */
  44. // void SListResetIteration(PSList); // Resets iteration counter.
  45. #define SListResetIteration(pSL) (pSL)->CurrOffset = 0xFFFFFFFF
  46. // unsigned SListGetEntries(PSList); // Ret. # entries in list.
  47. #define SListGetEntries(pSL) ((pSL)->NEntries)
  48. // void SListClear(PSList);
  49. #define SListClear(pSL) { \
  50. (pSL)->NEntries = (pSL)->HeadOffset = 0; \
  51. (pSL)->CurrOffset = 0xFFFFFFFF; \
  52. }
  53. // BOOLEAN SListIsEmpty(PSList);
  54. #define SListIsEmpty(pSL) ((pSL)->NEntries == 0)
  55. #endif // !defined(__SLIST_H)