Counter Strike : Global Offensive Source Code
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.

52 lines
1.3 KiB

  1. //========= Copyright, Valve Corporation, All rights reserved. ================//
  2. //
  3. // std::pair style container; exists to work easily in our CUtlMap/CUtlHashMap classes
  4. //
  5. //=============================================================================//
  6. #ifndef UTLPAIR_H
  7. #define UTLPAIR_H
  8. #ifdef _WIN32
  9. #pragma once
  10. #endif
  11. // std::pair style container; exists to work easily in our CUtlMap/CUtlHashMap classes
  12. template<typename T1, typename T2>
  13. class CUtlPair
  14. {
  15. public:
  16. CUtlPair() {}
  17. CUtlPair( T1 t1, T2 t2 ) : first( t1 ), second( t2 ) {}
  18. bool operator<( const CUtlPair<T1,T2> &rhs ) const {
  19. if ( first != rhs.first )
  20. return first < rhs.first;
  21. return second < rhs.second;
  22. }
  23. bool operator==( const CUtlPair<T1,T2> &rhs ) const {
  24. return first == rhs.first && second == rhs.second;
  25. }
  26. T1 first;
  27. T2 second;
  28. };
  29. // utility to make a CUtlPair without having to specify template parameters
  30. template<typename T1, typename T2>
  31. inline CUtlPair<T1,T2> MakeUtlPair( T1 t1, T2 t2 )
  32. {
  33. return CUtlPair<T1,T2>(t1, t2);
  34. }
  35. //// HashItem() overload that works automatically with our hash containers
  36. //template<typename T1, typename T2>
  37. //inline uint32 HashItem( const CUtlPair<T1,T2> &item )
  38. //{
  39. // return HashItem( (uint64)HashItem( item.first ) + ((uint64)HashItem( item.second ) << 32) );
  40. //}
  41. #endif // UTLPAIR_H