Source code of Windows XP (NT5)
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.

110 lines
2.5 KiB

  1. //+-------------------------------------------------------------------------
  2. //
  3. // Microsoft Windows
  4. //
  5. // Copyright (C) Microsoft Corporation, 1990 - 1999
  6. //
  7. // File: sdict2.hxx
  8. //
  9. //--------------------------------------------------------------------------
  10. /* --------------------------------------------------------------------
  11. File : sdict2.hxx
  12. Title : Simple dictionary.
  13. Description :
  14. History :
  15. -------------------------------------------------------------------- */
  16. #ifndef __SDICT2_HXX__
  17. #define __SDICT2_HXX__
  18. #define INITIALDICT2SLOTS 4
  19. class SIMPLE_DICT2
  20. {
  21. protected:
  22. void * * DictKeys;
  23. void * * DictItems;
  24. int cDictSlots;
  25. void * InitialDictKeys[INITIALDICT2SLOTS];
  26. void * InitialDictItems[INITIALDICT2SLOTS];
  27. public:
  28. SIMPLE_DICT2 ( // Constructor.
  29. );
  30. ~SIMPLE_DICT2 ( // Destructor.
  31. );
  32. int // Indicates success (0), or an error (-1).
  33. Insert ( // Insert the item into the dictionary so that a find operation
  34. // using the key will return it.
  35. void * Key,
  36. void * Item
  37. );
  38. void * // Returns the item deleted from the dictionary, or 0.
  39. Delete ( // Delete the item named by Key from the dictionary.
  40. void * Key
  41. );
  42. void * // Returns the item named by key, or 0.
  43. Find (
  44. void * Key
  45. );
  46. void // updates the item named by key.
  47. Update (
  48. void * Key,
  49. void *Item
  50. );
  51. void
  52. Reset (DictionaryCursor &cursor // Resets the dictionary, so that when Next is called,
  53. // the first item will be returned.
  54. ) {cursor = 0;}
  55. void * // Returns the next item or 0 if at the end.
  56. Next (DictionaryCursor &cursor, BOOL fRemove);
  57. };
  58. #define NEW_SDICT2(TYPE, KTYPE) NEW_NAMED_SDICT2(TYPE, TYPE, KTYPE)
  59. #define NEW_NAMED_SDICT2(CLASS, TYPE, KTYPE)\
  60. \
  61. class CLASS##_DICT2 : public SIMPLE_DICT2\
  62. {\
  63. public:\
  64. \
  65. CLASS##_DICT2 () {}\
  66. ~CLASS##_DICT2 () {}\
  67. \
  68. TYPE *\
  69. Find (KTYPE Key)\
  70. {return((TYPE *) SIMPLE_DICT2::Find((void *)Key));}\
  71. \
  72. TYPE *\
  73. Delete (KTYPE Key)\
  74. {return((TYPE *) SIMPLE_DICT2::Delete((void *)Key));}\
  75. \
  76. int\
  77. Insert (KTYPE Key, TYPE * Item)\
  78. {return(SIMPLE_DICT2::Insert((void *)Key, (void *)Item));}\
  79. \
  80. void\
  81. Update (KTYPE Key, TYPE * Item)\
  82. {SIMPLE_DICT2::Update((void *)Key, (void *)Item);}\
  83. \
  84. TYPE *\
  85. Next (DictionaryCursor &cursor, BOOL fRemove = 0)\
  86. {return ((TYPE *) SIMPLE_DICT2::Next(cursor, fRemove));}\
  87. }
  88. #endif // __SDICT2_HXX__