LinuxQuestions.org
Welcome to the most active Linux Forum on the web.
Home Forums Tutorials Articles Register
Go Back   LinuxQuestions.org > Forums > Linux Forums > Linux - Newbie
User Name
Password
Linux - Newbie This Linux forum is for members that are new to Linux.
Just starting out and have a question? If it is not in the man pages or the how-to's this is the place!

Notices


Closed Thread
  Search this Thread
Old 03-15-2008, 02:27 PM   #1
linux_linux
Member
 
Registered: Mar 2008
Posts: 52

Rep: Reputation: 15
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
 
Old 03-15-2008, 02:59 PM   #2
acid_kewpie
Moderator
 
Registered: Jun 2001
Location: UK
Distribution: Gentoo, RHEL, Fedora, Centos
Posts: 43,417

Rep: Reputation: 1985Reputation: 1985Reputation: 1985Reputation: 1985Reputation: 1985Reputation: 1985Reputation: 1985Reputation: 1985Reputation: 1985Reputation: 1985Reputation: 1985
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

Last edited by acid_kewpie; 03-15-2008 at 03:10 PM.
 
Old 03-15-2008, 03:42 PM   #3
Tinkster
Moderator
 
Registered: Apr 2002
Location: earth
Distribution: slackware by choice, others too :} ... android.
Posts: 23,067
Blog Entries: 11

Rep: Reputation: 928Reputation: 928Reputation: 928Reputation: 928Reputation: 928Reputation: 928Reputation: 928Reputation: 928
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
 
Old 03-15-2008, 04:17 PM   #4
acid_kewpie
Moderator
 
Registered: Jun 2001
Location: UK
Distribution: Gentoo, RHEL, Fedora, Centos
Posts: 43,417

Rep: Reputation: 1985Reputation: 1985Reputation: 1985Reputation: 1985Reputation: 1985Reputation: 1985Reputation: 1985Reputation: 1985Reputation: 1985Reputation: 1985Reputation: 1985
i did that with a couple, but nothing turned up at all... certainly seems likely.
 
Old 03-15-2008, 05:45 PM   #5
johnsfine
LQ Guru
 
Registered: Dec 2007
Distribution: Centos
Posts: 5,286

Rep: Reputation: 1197Reputation: 1197Reputation: 1197Reputation: 1197Reputation: 1197Reputation: 1197Reputation: 1197Reputation: 1197Reputation: 1197
Quote:
Originally Posted by acid_kewpie View Post
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.
 
Old 03-15-2008, 06:02 PM   #6
acid_kewpie
Moderator
 
Registered: Jun 2001
Location: UK
Distribution: Gentoo, RHEL, Fedora, Centos
Posts: 43,417

Rep: Reputation: 1985Reputation: 1985Reputation: 1985Reputation: 1985Reputation: 1985Reputation: 1985Reputation: 1985Reputation: 1985Reputation: 1985Reputation: 1985Reputation: 1985
I'm totally baffled to the obvious question of "WHY???" though...
 
Old 03-15-2008, 06:53 PM   #7
Tinkster
Moderator
 
Registered: Apr 2002
Location: earth
Distribution: slackware by choice, others too :} ... android.
Posts: 23,067
Blog Entries: 11

Rep: Reputation: 928Reputation: 928Reputation: 928Reputation: 928Reputation: 928Reputation: 928Reputation: 928Reputation: 928
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
 
Old 03-15-2008, 08:56 PM   #8
Tinkster
Moderator
 
Registered: Apr 2002
Location: earth
Distribution: slackware by choice, others too :} ... android.
Posts: 23,067
Blog Entries: 11

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


Closed Thread



Posting Rules
You may not post new threads
You may not post replies
You may not post attachments
You may not edit your posts

BB code is On
Smilies are On
[IMG] code is Off
HTML code is Off



Similar Threads
Thread Thread Starter Forum Replies Last Post
stl map reverse iterator r.stiltskin Programming 0 03-05-2007 11:06 AM
what will be the return value? ( STL and c++) ankit4u1 Programming 3 06-15-2006 01:59 PM
STL Map problem krishnacins Programming 4 04-20-2006 12:23 AM
Stl iterator woes Config Programming 4 06-23-2004 05:31 PM
compile error while returning STL iterator as object * rameshmiraje Programming 2 06-20-2004 01:50 PM

LinuxQuestions.org > Forums > Linux Forums > Linux - Newbie

All times are GMT -5. The time now is 10:23 AM.

Main Menu
Advertisement
My LQ
Write for LQ
LinuxQuestions.org is looking for people interested in writing Editorials, Articles, Reviews, and more. If you'd like to contribute content, let us know.
Main Menu
Syndicate
RSS1  Latest Threads
RSS1  LQ News
Twitter: @linuxquestions
Open Source Consulting | Domain Registration