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