R
reppisch
Hi Ng,
I have a multiset for keeping elements sorted in a container but key
values may also be equal.
Is there any guaranteed traversal order within the duplicate keys of a
multimap?
When inserting duplicate keys to the multiset i need output order to be
in insert order.
Sample:
std::multimap<int,char,std::greater<int> > m;
m.insert(pair<int,char>(1,'a'));
m.insert(pair<int,char>(2,'B'));
m.insert(pair<int,char>(2,'b'));
m.insert(pair<int,char>(2,'p'));
m.insert(pair<int,char>(3,'c'));
std::multimap<int,char,std::greater<int> >::iterator i = m.begin();
while (i != m.end()) {
cout << i->first << " " << i->second << endl;
++i;
};
- Is it guaranteed that the iteraton will allways print
3 c
2 B
2 b
2 p
1 a
- Can it be made deterministic by providing an insert hint like
m.insert(m.end(),pair<int,char>(2,'b'));
I did'nt find any information about this reading the sgi-specs.
Regards,
Michael
I have a multiset for keeping elements sorted in a container but key
values may also be equal.
Is there any guaranteed traversal order within the duplicate keys of a
multimap?
When inserting duplicate keys to the multiset i need output order to be
in insert order.
Sample:
std::multimap<int,char,std::greater<int> > m;
m.insert(pair<int,char>(1,'a'));
m.insert(pair<int,char>(2,'B'));
m.insert(pair<int,char>(2,'b'));
m.insert(pair<int,char>(2,'p'));
m.insert(pair<int,char>(3,'c'));
std::multimap<int,char,std::greater<int> >::iterator i = m.begin();
while (i != m.end()) {
cout << i->first << " " << i->second << endl;
++i;
};
- Is it guaranteed that the iteraton will allways print
3 c
2 B
2 b
2 p
1 a
- Can it be made deterministic by providing an insert hint like
m.insert(m.end(),pair<int,char>(2,'b'));
I did'nt find any information about this reading the sgi-specs.
Regards,
Michael