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.

95 lines
3.3 KiB

  1. //---------------------------------------------------------------------------
  2. //
  3. // Microsoft Windows
  4. // Copyright (C) Microsoft Corporation, 1996 - 1997
  5. //
  6. // File: sdict.hxx
  7. //
  8. // Contents: simple dictionary
  9. //
  10. // History: 28-Feb-97 SophiaC Created.
  11. //
  12. //----------------------------------------------------------------------------
  13. #ifndef __SDICT_HXX__
  14. #define __SDICT_HXX__
  15. #define INITIALDICTSLOTS 5
  16. class SIMPLE_DICT
  17. {
  18. private:
  19. void * * DictSlots;
  20. int cDictSlots;
  21. int cDictSize;
  22. int iNextItem;
  23. void * InitialDictSlots[INITIALDICTSLOTS];
  24. public:
  25. SIMPLE_DICT ( // Constructor.
  26. );
  27. ~SIMPLE_DICT ( // Destructor.
  28. );
  29. int // Return the key in the dictionary for the item just inserted.
  30. Insert ( // Insert an item in the dictionary and return its key.
  31. void *Item // The item to insert.
  32. );
  33. void * // Returns the item if found, and 0 otherwise.
  34. Find ( // Find an item in the dictionary.
  35. int Key // The key of the item.
  36. );
  37. void * // Returns the item being deleted.
  38. Delete ( // Delete an item from the dictionary.
  39. int Key // The key of the item being deleted.
  40. );
  41. int // Returns the number of items in the dictionary.
  42. Size ( // Returns the number of items in the dictionary.
  43. ) {return(cDictSize);}
  44. void
  45. Reset ( // Resets the dictionary, so that when Next is called,
  46. // the first item will be returned.
  47. ) {iNextItem = 0;}
  48. void * // Returns the next item or 0 if at the end.
  49. Next (
  50. );
  51. void *
  52. DeleteItemByBruteForce(
  53. void * Item
  54. );
  55. };
  56. #define NEW_SDICT(TYPE) \
  57. \
  58. class TYPE; \
  59. \
  60. class TYPE##_DICT : public SIMPLE_DICT \
  61. { \
  62. public: \
  63. \
  64. TYPE##_DICT () {} \
  65. ~TYPE##_DICT () {} \
  66. \
  67. TYPE * \
  68. Find (int Key) \
  69. {return((TYPE *) SIMPLE_DICT::Find(Key));} \
  70. \
  71. TYPE * \
  72. Delete (int Key) \
  73. {return((TYPE *) SIMPLE_DICT::Delete(Key));} \
  74. \
  75. TYPE * \
  76. Next () \
  77. {return((TYPE *) SIMPLE_DICT::Next());} \
  78. }
  79. #endif // __SDICT_HXX__