forked from hitmen047/Source-PlusPlus
-
Notifications
You must be signed in to change notification settings - Fork 0
/
Copy pathutlpair.h
52 lines (41 loc) · 1.3 KB
/
utlpair.h
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
//========= Copyright, Valve Corporation, All rights reserved. ================//
//
// std::pair style container; exists to work easily in our CUtlMap/CUtlHashMap classes
//
//=============================================================================//
#ifndef UTLPAIR_H
#define UTLPAIR_H
#ifdef _WIN32
#pragma once
#endif
// std::pair style container; exists to work easily in our CUtlMap/CUtlHashMap classes
template<typename T1, typename T2>
class CUtlPair
{
public:
CUtlPair() {}
CUtlPair( T1 t1, T2 t2 ) : first( t1 ), second( t2 ) {}
bool operator<( const CUtlPair<T1,T2> &rhs ) const {
if ( first != rhs.first )
return first < rhs.first;
return second < rhs.second;
}
bool operator==( const CUtlPair<T1,T2> &rhs ) const {
return first == rhs.first && second == rhs.second;
}
T1 first;
T2 second;
};
// utility to make a CUtlPair without having to specify template parameters
template<typename T1, typename T2>
inline CUtlPair<T1,T2> MakeUtlPair( T1 t1, T2 t2 )
{
return CUtlPair<T1,T2>(t1, t2);
}
//// HashItem() overload that works automatically with our hash containers
//template<typename T1, typename T2>
//inline uint32 HashItem( const CUtlPair<T1,T2> &item )
//{
// return HashItem( (uint64)HashItem( item.first ) + ((uint64)HashItem( item.second ) << 32) );
//}
#endif // UTLPAIR_H