summaryrefslogtreecommitdiff
path: root/public/tier1/utlpair.h
diff options
context:
space:
mode:
authorFluorescentCIAAfricanAmerican <[email protected]>2020-04-22 12:56:21 -0400
committerFluorescentCIAAfricanAmerican <[email protected]>2020-04-22 12:56:21 -0400
commit3bf9df6b2785fa6d951086978a3e66f49427166a (patch)
tree2c0f1f0c63c4832882bc93814ebd2c2b1c6224e5 /public/tier1/utlpair.h
downloadarchived-source-engine-2018-hl2-src-master.tar.xz
archived-source-engine-2018-hl2-src-master.zip
Diffstat (limited to 'public/tier1/utlpair.h')
-rw-r--r--public/tier1/utlpair.h52
1 files changed, 52 insertions, 0 deletions
diff --git a/public/tier1/utlpair.h b/public/tier1/utlpair.h
new file mode 100644
index 0000000..d306f32
--- /dev/null
+++ b/public/tier1/utlpair.h
@@ -0,0 +1,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