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.

69 lines
2.0 KiB

  1. ////////////////////////////////////////////////////////////////////////////
  2. class FAR CMapLongPtr : public CPrivAlloc
  3. {
  4. public:
  5. // Construction
  6. CMapLongPtr(DWORD memctx, UINT nBlockSize=10)
  7. : m_mkv(memctx, sizeof(void FAR*), sizeof(LONG), nBlockSize) { }
  8. CMapLongPtr(DWORD memctx, UINT nBlockSize, UINT nHashTableSize)
  9. : m_mkv(memctx, sizeof(void FAR*), sizeof(LONG), 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(LONG key, void FAR* FAR& value) const
  19. { return m_mkv.Lookup((LPVOID)&key, sizeof(LONG), (LPVOID)&value); }
  20. BOOL LookupHKey(HMAPKEY hKey, void FAR* FAR& value) const
  21. { return m_mkv.LookupHKey(hKey, (LPVOID)&value); }
  22. BOOL LookupAdd(LONG key, void FAR* FAR& value) const
  23. { return m_mkv.LookupAdd((LPVOID)&key, sizeof(LONG), (LPVOID)&value); }
  24. // Add/Delete
  25. // add a new (key, value) pair
  26. BOOL SetAt(LONG key, void FAR* value)
  27. { return m_mkv.SetAt((LPVOID)&key, sizeof(LONG), (LPVOID)&value); }
  28. BOOL SetAtHKey(HMAPKEY hKey, void FAR* value)
  29. { return m_mkv.SetAtHKey(hKey, (LPVOID)&value); }
  30. // removing existing (key, ?) pair
  31. BOOL RemoveKey(LONG key)
  32. { return m_mkv.RemoveKey((LPVOID)&key, sizeof(LONG)); }
  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, LONG FAR& rKey, void FAR* FAR& rValue) const
  41. { m_mkv.GetNextAssoc(&rNextPosition, (LPVOID)&rKey, NULL, (LPVOID)&rValue); }
  42. HMAPKEY GetHKey(LONG key) const
  43. { return m_mkv.GetHKey((LPVOID)&key, sizeof(LONG)); }
  44. #ifdef _DEBUG
  45. void AssertValid() const
  46. { m_mkv.AssertValid(); }
  47. #endif
  48. private:
  49. CMapKeyToValue m_mkv;
  50. };