LinuxQuestions.org

LinuxQuestions.org (/questions/)
-   Linux - Newbie (https://www.linuxquestions.org/questions/linux-newbie-8/)
-   -   c++, linux, Do STL map iterator always return in same order when iterate from begin( (https://www.linuxquestions.org/questions/linux-newbie-8/c-linux-do-stl-map-iterator-always-return-in-same-order-when-iterate-from-begin-628277/)

linux_linux 03-15-2008 02:27 PM

c++, linux, Do STL map iterator always return in same order when iterate from begin(
 
I have a map<string, int>. When iterate from map.begin() to map.end(), is STL gurantee the iteration always give my the key in same order?

Example:
map<string, int> ABC;
ABC.insert( map<string, int>::value_type("A123", 0));
ABC.insert( map<string, int>::value_type("34DC", 1));
ABC.insert( map<string, int>::value_type("XY34Z", 2));
map<string,int>::iterator itr = ABC.begin();
while (itr != ABC.end()){
//example order is "34DC" -> "XY34Z" -> "A123"
itr++;
}

No mater how many time i repeat the iteration of ABC from begin() to end(), is STL gurantee always give me the same order? or it will be random order?

thanks

acid_kewpie 03-15-2008 02:59 PM

what are you doing? 14 new threads in 11 minutes? posting is utterly irrelevant forums? can you assure me that you are a genuine user with genuine questions??

not a networking question. moved to Linux - Newbie

Tinkster 03-15-2008 03:42 PM

Chris ... I think this is a bot. If you google for any of "his"
new thread titles they give us hits to expert-sexchange, the
infamous pay-forum. I'm very much inclined to ban the thing and
delete all its threads.



Cheers,
Tink

acid_kewpie 03-15-2008 04:17 PM

i did that with a couple, but nothing turned up at all... certainly seems likely.

johnsfine 03-15-2008 05:45 PM

Quote:

Originally Posted by acid_kewpie (Post 3089724)
14 new threads in 11 minutes? posting is utterly irrelevant forums? can you assure me that you are a genuine user with genuine questions??

Thanks. If you hadn't pointed that out, I would be wasting time typing answers to some of those.

He did a good job of generating and titling posts to pull responses. Until you look at them as a group, each looks like a reasonable request.

acid_kewpie 03-15-2008 06:02 PM

I'm totally baffled to the obvious question of "WHY???" though...

Tinkster 03-15-2008 06:53 PM

MY guess is that (since it turns the sexpert pages up for me) is that he
hopes that people trying to help will use the same terms in google, and
will hit their homepage. Only sensible explanation; and then, to be able
to see a SOLUTION you have to sign-up (and pay) most of the time.



Cheers,
Tink

Tinkster 03-15-2008 08:56 PM

Sick of bot posting problems from a different forum verbatim on LQ
in irrelevant boards. Banning the thing and closing the threads.


All times are GMT -5. The time now is 03:09 PM.