V
vertigo
Hello
I have std::map object and i want to have randomly sorted objects in it.
I tried to:
std::map<int,RandomCompare> myobject;
and:
struct RandomCompare{
bool operator(int i1, int i2){
/* what shuold i put here ??? */
}
}
I see that i can only return true or false, but shouldn't it return int to
indicate 3 possibilities: equal, greater, smaller ?
When i put there: return rand()%2; after adding several object's i have
only some of them (because of true which symbols equality ??).
How can i solve my problem ?
I want to have all objects but while they are added always in the same
order i want to read them (using iterator) in randomly order.
Thanx
Michal
I have std::map object and i want to have randomly sorted objects in it.
I tried to:
std::map<int,RandomCompare> myobject;
and:
struct RandomCompare{
bool operator(int i1, int i2){
/* what shuold i put here ??? */
}
}
I see that i can only return true or false, but shouldn't it return int to
indicate 3 possibilities: equal, greater, smaller ?
When i put there: return rand()%2; after adding several object's i have
only some of them (because of true which symbols equality ??).
How can i solve my problem ?
I want to have all objects but while they are added always in the same
order i want to read them (using iterator) in randomly order.
Thanx
Michal