Skip to content

Instantly share code, notes, and snippets.

@chancez
Created August 3, 2012 01:11
Show Gist options
  • Save chancez/3243011 to your computer and use it in GitHub Desktop.
Save chancez/3243011 to your computer and use it in GitHub Desktop.
bool HashTable::retrieve (char const * const name, Player & aPlayer)const
{
//calculate the retrieval position (the index of the array)
int index = calculateIndex(name);
//search for the Player in the chain (linked list)
node * curr = table[index];
char id[100];
char *playerName;
while (curr)
{
playerName = curr->item.getName();
if(strcmp(name, playerName) == 0)
{
//find match and return the Player
aPlayer = curr->item;
return true;
}
else
curr = curr->next;
}
//Player is not in the table
return false;
}
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment