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.

69 lines
1.9 KiB

  1. ////////////////////////////////////////////////////////////////////////////
  2. class FAR CMapUintHwnd : public CPrivAlloc
  3. {
  4. public:
  5. // Construction
  6. CMapUintHwnd(UINT nBlockSize=10)
  7. : m_mkv(sizeof(HWND), sizeof(UINT), nBlockSize) { }
  8. CMapUintHwnd(UINT nBlockSize, UINT nHashTableSize)
  9. : m_mkv(sizeof(HWND), sizeof(UINT), nBlockSize,
  10. &MKVDefaultHashKey, nHashTableSize) { }
  11. // Attributes
  12. // number of elements
  13. int GetCount() const
  14. { return m_mkv.GetCount(); }
  15. BOOL IsEmpty() const
  16. { return GetCount() == 0; }
  17. // Lookup
  18. BOOL Lookup(UINT key, HWND FAR& value) const
  19. { return m_mkv.Lookup((LPVOID)&key, sizeof(UINT), (LPVOID)&value); }
  20. BOOL LookupHKey(HMAPKEY hKey, HWND FAR& value) const
  21. { return m_mkv.LookupHKey(hKey, (LPVOID)&value); }
  22. BOOL LookupAdd(UINT key, HWND FAR& value) const
  23. { return m_mkv.LookupAdd((LPVOID)&key, sizeof(UINT), (LPVOID)&value); }
  24. // Add/Delete
  25. // add a new (key, value) pair
  26. BOOL SetAt(UINT key, HWND value)
  27. { return m_mkv.SetAt((LPVOID)&key, sizeof(UINT), (LPVOID)&value); }
  28. BOOL SetAtHKey(HMAPKEY hKey, HWND value)
  29. { return m_mkv.SetAtHKey(hKey, (LPVOID)&value); }
  30. // removing existing (key, ?) pair
  31. BOOL RemoveKey(UINT key)
  32. { return m_mkv.RemoveKey((LPVOID)&key, sizeof(UINT)); }
  33. BOOL RemoveHKey(HMAPKEY hKey)
  34. { return m_mkv.RemoveHKey(hKey); }
  35. void RemoveAll()
  36. { m_mkv.RemoveAll(); }
  37. // iterating all (key, value) pairs
  38. POSITION GetStartPosition() const
  39. { return m_mkv.GetStartPosition(); }
  40. void GetNextAssoc(POSITION FAR& rNextPosition, UINT FAR& rKey, HWND FAR& rValue) const
  41. { m_mkv.GetNextAssoc(&rNextPosition, (LPVOID)&rKey, NULL, (LPVOID)&rValue); }
  42. HMAPKEY GetHKey(UINT key) const
  43. { return m_mkv.GetHKey((LPVOID)&key, sizeof(UINT)); }
  44. #ifdef _DEBUG
  45. void AssertValid() const
  46. { m_mkv.AssertValid(); }
  47. #endif
  48. private:
  49. CMapKeyToValue m_mkv;
  50. };