Created
June 1, 2011 01:05
-
-
Save sprite2005/1001588 to your computer and use it in GitHub Desktop.
This file contains hidden or 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
void CSpriteTrie::addWord(const char *string) | |
{ | |
CSpriteTrieNode* pNode = &m_root; | |
for (unsigned int i = 0; i < strlen(string); i++) { | |
char current = string[i]; | |
CSpriteTrieNode* pPreviousNode = pNode; | |
map<char, CSpriteTrieNode*>::iterator iter = pNode->m_nodeMap.find(current); | |
if (iter != pNode->m_nodeMap.end()) { | |
pNode = iter->second; | |
} else { | |
CSpriteTrieNode* pNewNode = new CSpriteTrieNode; | |
pNewNode->m_bIsWord = true; | |
g_NodeCount2++; | |
pPreviousNode->m_nodeMap.insert(pair<char, CSpriteTrieNode*>(current, pNewNode)); | |
pNode = pNewNode; | |
} | |
//NSLog(@"Adding char: %c", string[i]); | |
} | |
// NSLog(@"Finished adding word"); | |
pNode->m_bIsWord = true; | |
} |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment