LinuxQuestions.org
Help answer threads with 0 replies.
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, 03: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, 03:59 PM   #2
acid_kewpie
Moderator
 
Registered: Jun 2001
Location: UK
Distribution: Gentoo, RHEL, Fedora, Centos
Posts: 43,417

Rep: Reputation: 1974Reputation: 1974Reputation: 1974Reputation: 1974Reputation: 1974Reputation: 1974Reputation: 1974Reputation: 1974Reputation: 1974Reputation: 1974Reputation: 1974
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 04:10 PM.
 
Old 03-15-2008, 04:42 PM   #3
Tinkster
Moderator
 
Registered: Apr 2002
Location: in a fallen world
Distribution: slackware by choice, others too :} ... android.
Posts: 23,066
Blog Entries: 11

Rep: Reputation: 910Reputation: 910Reputation: 910Reputation: 910Reputation: 910Reputation: 910Reputation: 910Reputation: 910
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, 05:17 PM   #4
acid_kewpie
Moderator
 
Registered: Jun 2001
Location: UK
Distribution: Gentoo, RHEL, Fedora, Centos
Posts: 43,417

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

Rep: Reputation: 1181Reputation: 1181Reputation: 1181Reputation: 1181Reputation: 1181Reputation: 1181Reputation: 1181Reputation: 1181Reputation: 1181
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, 07:02 PM   #6
acid_kewpie
Moderator
 
Registered: Jun 2001
Location: UK
Distribution: Gentoo, RHEL, Fedora, Centos
Posts: 43,417

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

Rep: Reputation: 910Reputation: 910Reputation: 910Reputation: 910Reputation: 910Reputation: 910Reputation: 910Reputation: 910
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, 09:56 PM   #8
Tinkster
Moderator
 
Registered: Apr 2002
Location: in a fallen world
Distribution: slackware by choice, others too :} ... android.
Posts: 23,066
Blog Entries: 11

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


Closed Thread


Thread Tools Search this Thread
Search this Thread:

Advanced Search

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 12:06 PM
what will be the return value? ( STL and c++) ankit4u1 Programming 3 06-15-2006 02:59 PM
STL Map problem krishnacins Programming 4 04-20-2006 01:23 AM
Stl iterator woes Config Programming 4 06-23-2004 06:31 PM
compile error while returning STL iterator as object * rameshmiraje Programming 2 06-20-2004 02:50 PM


All times are GMT -5. The time now is 03:08 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
Facebook: linuxquestions Google+: linuxquestions
Open Source Consulting | Domain Registration