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.

88 lines
2.4 KiB

  1. ///////////////////////////////////////////////////////////////////////////////
  2. //
  3. // Copyright (c) 1999, Microsoft Corp. All rights reserved.
  4. //
  5. // FILE
  6. //
  7. // attridx.h
  8. //
  9. // SYNOPSIS
  10. //
  11. // Declares the class AttributeIndex
  12. //
  13. // MODIFICATION HISTORY
  14. //
  15. // 02/04/2000 Original version.
  16. //
  17. ///////////////////////////////////////////////////////////////////////////////
  18. #ifndef ATTRIDX_H
  19. #define ATTRIDX_H
  20. #if _MSC_VER >= 1000
  21. #pragma once
  22. #endif
  23. struct AttributeDefinition;
  24. class AttributeIndex
  25. {
  26. public:
  27. AttributeIndex() throw ()
  28. : table(NULL), mask(0), hashFn(NULL), equalFn(NULL)
  29. { }
  30. ~AttributeIndex() throw ()
  31. { delete[] table; }
  32. // Used for hashing AttributeDefinitions.
  33. typedef ULONG (WINAPI *HashFn)(
  34. const AttributeDefinition& def
  35. ) throw ();
  36. // Used for testing equality of AttributeDefinitions.
  37. typedef BOOL (WINAPI *EqualFn)(
  38. const AttributeDefinition& def1,
  39. const AttributeDefinition& def2
  40. ) throw ();
  41. // Used for determining which definitions should be indexed.
  42. typedef BOOL (WINAPI *FilterFn)(
  43. const AttributeDefinition& def
  44. ) throw ();
  45. // Create a new index. Any existing index is destroyed.
  46. void create(
  47. const AttributeDefinition* begin,
  48. const AttributeDefinition* end,
  49. HashFn hash,
  50. EqualFn equal,
  51. FilterFn filterFn = NULL
  52. );
  53. // Find an AttributeDefinition according to the key.
  54. const AttributeDefinition* find(
  55. const AttributeDefinition& key
  56. ) const throw ();
  57. private:
  58. // Node in a bucket.
  59. struct Node
  60. {
  61. const Node* next;
  62. const AttributeDefinition* def;
  63. };
  64. // Bucket in a hash table.
  65. typedef Node* Bucket;
  66. Bucket* table; // The hash table.
  67. ULONG mask; // Mask used for reducing hash values.
  68. HashFn hashFn; // Function used for hashing definitions.
  69. EqualFn equalFn; // Function used for comparing definitions to key.
  70. // Not implemented.
  71. AttributeIndex(const AttributeIndex&) throw ();
  72. AttributeIndex& operator=(const AttributeIndex&) throw ();
  73. };
  74. #endif // ATTRIDX_H