Created
August 3, 2012 01:11
-
-
Save chancez/3243016 to your computer and use it in GitHub Desktop.
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
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 *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