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.

66 lines
1.8 KiB

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