HashTableKey_Pointer.cpp
Go to the documentation of this file.00001 //*** HashTableKey_Pointer.cpp *** 00002 00003 #include "HashTableKey_Pointer.h" 00004 00005 HashTableKey_Pointer::HashTableKey_Pointer(): 00006 hash_(0), 00007 pointer_(0) 00008 { 00009 00010 } 00011 00012 00013 //*** Constructor *** 00014 00015 HashTableKey_Pointer::HashTableKey_Pointer(const void* pointer) 00016 { 00017 // No need for any complex calculations for this key type. Just use the number as is. 00018 hash_=(unsigned int)(((long long)pointer)>>2); 00019 pointer_=pointer; 00020 } 00021 00022 00023 //*** GetType *** 00024 00025 StringId HashTableKey_Pointer::GetType() const 00026 { 00027 static StringId type("HashTableKey_Pointer"); 00028 return type; 00029 } 00030 00031 00032 //*** GetHash *** 00033 00034 unsigned int HashTableKey_Pointer::GetHash() const 00035 { 00036 return hash_; 00037 } 00038 00039 00040 //*** GetInt *** 00041 00042 unsigned int HashTableKey_Pointer::GetInt() const 00043 { 00044 return hash_; 00045 } 00046 00047 00048 //*** Compare *** 00049 00050 bool HashTableKey_Pointer::Compare(const HashTableKey* key) const 00051 { 00052 // Make sure key is of the correct type 00053 if (key->GetType()!=GetType()) 00054 { 00055 return false; 00056 } 00057 00058 return pointer_==(static_cast<const HashTableKey_Pointer*>(key))->pointer_; 00059 }
Reproduction/republishing of any material on this site without permission is strictly prohibited.
