Rewrite sample HashTable description to use the typedefs
This makes the code more readable (as KeyType and ValueType are clearer than int and Foo) and easier to copypaste and edit.
This commit is contained in:
@@ -34,22 +34,22 @@
|
||||
typedef int KeyType;
|
||||
typedef Foo ValueType;
|
||||
|
||||
size_t HashKey(int key) const
|
||||
size_t HashKey(KeyType key) const
|
||||
{
|
||||
return key >> 1;
|
||||
}
|
||||
|
||||
size_t Hash(Foo* value) const
|
||||
size_t Hash(ValueType* value) const
|
||||
{
|
||||
return HashKey(value->bar);
|
||||
}
|
||||
|
||||
bool Compare(int key, Foo* value) const
|
||||
bool Compare(KeyType key, ValueType* value) const
|
||||
{
|
||||
return value->bar == key;
|
||||
}
|
||||
|
||||
Foo*& GetLink(Foo* value) const
|
||||
ValueType*& GetLink(ValueType* value) const
|
||||
{
|
||||
return value->fNext;
|
||||
}
|
||||
|
||||
Reference in New Issue
Block a user