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.

70 lines
1.8 KiB

  1. /*
  2. * hash.h
  3. *
  4. * Purpose:
  5. * implementation of a string hash table
  6. *
  7. * Owner:
  8. * EricAn
  9. *
  10. * History:
  11. * Mar 97: Created.
  12. *
  13. * Copyright (C) Microsoft Corp. 1997
  14. */
  15. #ifndef __HASH_H
  16. #define __HASH_H
  17. typedef struct tagHASHENTRY *PHASHENTRY;
  18. typedef struct tagHASHENTRY {
  19. LPSTR pszKey;
  20. LPVOID pv;
  21. PHASHENTRY pheNext;
  22. } HASHENTRY;
  23. class CHash :
  24. public IHashTable,
  25. public CPrivateUnknown
  26. {
  27. public:
  28. // ---------------------------------------------------------------------------
  29. // IUnknown members
  30. // ---------------------------------------------------------------------------
  31. virtual STDMETHODIMP QueryInterface(REFIID riid, LPVOID * ppvObj) {
  32. return CPrivateUnknown::QueryInterface(riid, ppvObj); };
  33. virtual STDMETHODIMP_(ULONG) AddRef(void) {
  34. return CPrivateUnknown::AddRef();};
  35. virtual STDMETHODIMP_(ULONG) Release(void) {
  36. return CPrivateUnknown::Release(); };
  37. // IHashTable
  38. HRESULT STDMETHODCALLTYPE Init(DWORD dwSize, BOOL fDupeKeys);
  39. HRESULT STDMETHODCALLTYPE Insert(LPSTR psz, LPVOID pv, DWORD dwFlags);
  40. HRESULT STDMETHODCALLTYPE Replace(LPSTR psz, LPVOID pv);
  41. HRESULT STDMETHODCALLTYPE Find(LPSTR psz, BOOL fRemove, LPVOID *ppv);
  42. HRESULT STDMETHODCALLTYPE Reset();
  43. HRESULT STDMETHODCALLTYPE Next(ULONG cFetch, LPVOID **prgpv, ULONG *pcFetched);
  44. CHash(IUnknown *pUnkOuter=NULL);
  45. virtual ~CHash();
  46. protected:
  47. inline DWORD Hash(LPSTR psz);
  48. DWORD m_cBins,
  49. m_iListBinEnum;
  50. PHASHENTRY m_rgBins,
  51. m_pLastEntryEnum;
  52. BOOL m_fDupe;
  53. virtual HRESULT PrivateQueryInterface(REFIID riid, LPVOID * ppvObj);
  54. #ifdef DEBUG
  55. void Stats();
  56. #endif
  57. };
  58. #endif // __HASH_H