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
2.0 KiB

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