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:
Adrien Destugues
2015-01-09 18:09:11 +01:00
parent d4aabe75c3
commit 955d5259d0
+4 -4
View File
@@ -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;
}