|
-
July 17th, 2008, 07:53 AM
#1
[RESOLVED] Stange problem in std::map
I'm trying to load a dictionary in memory and everything goes fine. No error, no warning, no memory leak, nothing. Just trying to see how many elements my map has and I dicovered that it is loading less words that the dictionary has. Here is my code.
Code:
UINT CPM2Dlg::LoadVocabolary(void)
{
CStdioFile pFile;
CString temp;
if(pFile.Open("vocabolario.txt",CFile::modeRead | CFile::typeText))
{
while(pFile.ReadString(temp))
{
dataHandler.vocabolary.words.insert(dict_words::value_type(temp,DecodeString(temp)));
}
pFile.Close();
}
return 0;
}
CString & CPM2Dlg::DecodeString(CString & str)
{
int i,length;
CString buffer;
length = str.GetLength();
for(i = 0; i < length; i++)
{
if(str[i] == 'a' || str[i] == 'b' || str[i] == 'c' || str[i] == '*')
{
buffer += "2";
continue;
}
if(str[i] == 'd' || str[i] == 'e' || str[i] == 'f' || str[i] == 'è' || str[i] == 'é')
{
buffer += "3";
continue;
}
if(str[i] == 'g' || str[i] == 'h' || str[i] == 'i' || str[i] == 'ì')
{
buffer += "4";
continue;
}
if(str[i] == 'j' || str[i] == 'k' || str[i] == 'l')
{
buffer += "5";
continue;
}
if(str[i] == 'm' || str[i] == 'n' || str[i] == 'o' || str[i] == 'ò')
{
buffer += "6";
continue;
}
if(str[i] == 'p' || str[i] == 'q' || str[i] == 'r' || str[i] == 's')
{
buffer += "7";
continue;
}
if(str[i] == 't' || str[i] == 'u' || str[i] == 'v' || str[i] == 'ù')
{
buffer += "8";
continue;
}
if(str[i] == 'w' || str[i] == 'x' || str[i] == 'y' || str[i] == 'z')
{
buffer += "9";
continue;
}
}
str = buffer;
return str;
}
the vocabolary has 245227 elements but the map only shows 222791. If I delete a word from the dictionary (delete fisically a line in the txt file) the number decrease (as I expected). Any clue? Have I done something wrong here?
Posting Permissions
- You may not post new threads
- You may not post replies
- You may not post attachments
- You may not edit your posts
-
Forum Rules
|
Click Here to Expand Forum to Full Width
|