1 msgSortir, se distraire, se cultiver autour du Leman
1 msgWhich gcc tar file to be used for SGI Altix 350?
1 msgcan I force linking to older libstdc++?
1 msggcc linker error
6 msgSymbols which were not used, still in binary
5 msgmmx/sse builtins
2 msgdiscard a weak symbol in object file
5 msgerror occured when cross compiling gcc
6 msgGcc 3.4.6 Build error
5 msgAddress of label which is defined within an asm...
3 msgTemplate parameters problem
2 msg-mcpu=v9 -mvis error on Solaris 8/SPARC with gc...
4 msgcurrent subversion (rev 115032) compiling issues
3 msgquestion about gcc assembly
3 msgQn regarding building an application of smalles...

STL, hash_map is sorted !!
\ Mohammad Shojatalab (26 Jun 2006)
. \ Noel Yap (26 Jun 2006)
. . \ Mohammad Shojatalab (26 Jun 2006)
. \ Brian Budge (26 Jun 2006)

3 msgProblem with private copy constructor
2 msgc-parser.y
12 msg'Free as in Freedom'
3 msgHow can I remove articles posted under my name?
Subject:STL, hash_map is sorted !!
Group:Gcc-help
From:Mohammad Shojatalab
Date:26 Jun 2006


Hi There,

I am trying to make use of hash_map from STL, and I was assuming that
hash_map doesn't sort the (key, value) pairs and keep the
pairs in the order I inserted them into the hash_map.

This is the simple program:

#include <ext/hash_map>

using namespace std;
using namespace __gnu_cxx;

typedef vector<int> cvCodes;
typedef hash_multimap<int, std::string> cvValues;

int main()
{
cvCodes items;
cvValues itemsvalues;
cvValues::iterator pos;

itemsvalues.insert(make_pair(3,"Z"));
itemsvalues.insert(make_pair(1,"C"));
itemsvalues.insert(make_pair(2,"A"));

for (pos = itemsvalues.begin(); pos != itemsvalues.end(); pos++)
cout << pos->first << " " << pos->second << endl;

return 0;
}

I was expecting to see the following output:

3 Z
1 C
2 A

but instead I get this one:

1 C
2 A
3 Z

I need to use a container which keeps the order of thing as I insert them.

Im using gcc version 4.0.2 20051125 (Red Hat 4.0.2-8)
on Linux 2.6.14-1.1653_FC4smp

I appreciate any help.

Thanks
Mohammad




© 2004-2008 readlist.com