Map losing elements!?
Hello group,
I've been trying around with a simple std::map<mytype, unsigned> for an
hour now and can't find the bug. It is my belief that I am missing
something incredibly obvious... please help me see it.
Scenario: I created the map and inserted some elements. Afterwards I try
to iterate over them:
std::map<mytype, unsigned int> values;
/* insert some values, say 5 */
/* this will then report 5 */
std::cerr << "cnt = " << values.size() << std::endl;
for (std::map<mytype, unsigned int>::iterator j = values.begin(); j !=
values.end(); j++) {
std::cerr << j->second << " -> ";
j->first.Dump();
std::cerr << std::endl;
}
However in the "for" loop, always only 2 items show up. I figured
something was wrong with my operator< - essentialy "mytype" is just a
container around a LENGTH byte unsigned char[] array:
bool operator<(const mytype &Other) const {
for (unsigned int i = 0; i < LENGTH; i++) {
if (Other.Data[i] < Data[i]) return true;
}
return false;
}
Can anyone explain this behaviour?
Thanks in advance,
Johannes
--
"Meine Gegenklage gegen dich lautet dann auf bewusste Verlogenheit,
verl?sterung von Gott, Bibel und mir und bewusster Blasphemie."
-- Prophet und Vision?r Hans Joss aka HJP in de.sci.physik
<48d8bf1d$0$7510$5402220f@news.sunrise.ch>