medfall

Unnamed repository; edit this file 'description' to name the repository.
Log | Files | Refs

commit a2495447972c166eb1a794304cb0c133446993a0
parent b1477a74ab3d998d84ea5bd265579955ef3a7a83
Author: Michael Savage <mikejsavage@gmail.com>
Date:   Sat Dec 24 16:24:11 +0200

Template HashTable on the value type

Diffstat:
hashtable.h | 8++++----
1 file changed, 4 insertions(+), 4 deletions(-)
diff --git a/hashtable.h b/hashtable.h @@ -3,7 +3,7 @@ #include "intrinsics.h" -template< size_t N > +template< typename T, size_t N > class HashTable { // https://fgiesen.wordpress.com/2015/02/22/triangular-numbers-mod-2n/ STATIC_ASSERT( is_power_of_2( N ) ); @@ -13,7 +13,7 @@ public: clear(); } - bool add( u64 key, u64 value ) { + bool add( u64 key, const T & value ) { size_t idx = find( key ); if( get_state( idx ) == OCCUPIED ) { return false; @@ -33,7 +33,7 @@ public: return false; } - bool get( u64 key, u64 * value ) { + bool get( u64 key, T * value ) { size_t idx = find( key ); if( get_state( idx ) == OCCUPIED ) { if( value != NULL ) { @@ -104,7 +104,7 @@ private: */ u8 states[ slots_required( N, 4 ) ]; u64 keys[ N ]; - u64 values[ N ]; + T values[ N ]; }; #endif // _HASHTABLE_H_