This is the mail archive of the
libstdc++@sourceware.cygnus.com
mailing list for the libstdc++ project.
Re: Is this a bug or lack of understanding?
- To: Stephen Webb <stephen at bregmasoft dot com>
- Subject: Re: Is this a bug or lack of understanding?
- From: Chris Picton <Chris dot Picton at usko dot com>
- Date: Tue, 18 Apr 2000 15:04:37 +0200
- Cc: libstdc++ at sourceware dot cygnus dot com
- References: <38FC57B5.626F1DA4@usko.com> <00041809120800.26612@piggy>
Stephen Webb wrote:
> On Tue, 18 Apr 2000, Chris Picton wrote:
> > Hi
> >
> > I have the following program:
> >...
> >
> > If i run it as it stands, it prints out all the elements in the map
> > in alphabetical order of the keys
> >
> > If I change the commented return line in the sort function object, to
> > sort by length of the key, it doesnt print all the entries in the map.
> >
> > Could someone explain why, or is it a bug?
>
> Not a bug.
>
> Your first version of the program maps strips to ints. The second maps the length of the strings to ints. A map<>
> will hold only one instance per value, so I would expect only one entry per length of string in the second version of
> the program.
In both of them, I declare map<string, int, s>
Dowsnt that mean I am mapping strings to ints in both cases. Shouldnt the sorting function be only to decide in what
order to store the objects.
>
>
> Stephen M. Webb
> Principle Consultant, Bregmasoft
--
Chris Picton
Usko Communications Systems Developer
Chris.Picton@usko.com