Velocity Reviews - Computer Hardware Reviews

Velocity Reviews > Newsgroups > Programming > C++ > Re: Is set's iterator a const_iterator?

Reply
Thread Tools

Re: Is set's iterator a const_iterator?

 
 
Jonathan Lee
Guest
Posts: n/a
 
      05-19-2010
On May 19, 3:31*pm, Andy Champ <(E-Mail Removed)> wrote:
> Have I understood this correctly?
>
> Andy


Yup. I had the exact same problem recently. By
[lib.associative.reqmts] point 5: Keys in an associative
container are immutable.

And in a set, the value is also the key.

--Jonathan
 
Reply With Quote
 
 
 
 
Juha Nieminen
Guest
Posts: n/a
 
      05-20-2010
Jonathan Lee <(E-Mail Removed)> wrote:
> Yup. I had the exact same problem recently. By
> [lib.associative.reqmts] point 5: Keys in an associative
> container are immutable.
>
> And in a set, the value is also the key.


That's why we have std::map: It's like a set, but with a mutable part on
each "key". It's what you should use when you want to change a part of the
key which isn't used to determine its ordering.
 
Reply With Quote
 
 
 
 
Jonathan Lee
Guest
Posts: n/a
 
      05-21-2010
On May 21, 3:12*pm, Andy Champ <(E-Mail Removed)> wrote:
> Jonathan Lee wrote:
> Leigh Johnston wrote:
>
> As I went back through the posts to forward them to my work account (no
> NNTP) it occurred to me - Are you guys related
>
> Andy


The near name reversal is indicative of the fact that one of us is
from a parallel universe and has a goatee.

You don't get to know which one.

--Jonathan
 
Reply With Quote
 
Brian
Guest
Posts: n/a
 
      05-22-2010
On May 20, 5:00*am, Juha Nieminen <(E-Mail Removed)> wrote:
> Jonathan Lee <(E-Mail Removed)> wrote:
> > Yup. I had the exact same problem recently. By
> > [lib.associative.reqmts] point 5: Keys in an associative
> > container are immutable.

>
> > And in a set, the value is also the key.

>
> * That's why we have std::map: It's like a set, but with a mutable part on
> each "key". It's what you should use when you want to change a part of the
> key which isn't used to determine its ordering.


I would say that's why we have boost::multi_index_container and
boost::intrusive containers. std::map it seems to me speaks
with a forked tongue, pair<key, value>. Although it takes a
little more effort, using an alternative to map avoids the
useless "first" and "second" terminology required by maps.
You can get by with maps in small programs, but how things
are named is more important in larger programs. I think
that some projects start out using maps and although they
would benefit from switching to an alternative, they lack
the resources to go back and rework things.


Brian Wood
http://webEbenezer.net
(651) 251-9384
 
Reply With Quote
 
 
 
Reply

Thread Tools

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 On
HTML code is Off
Trackbacks are On
Pingbacks are On
Refbacks are Off


Similar Threads
Thread Thread Starter Forum Replies Last Post
List iterator assignment fails, assert iterator not dereferencable David Bilsby C++ 5 10-09-2007 02:05 PM
What makes an iterator an iterator? Steven D'Aprano Python 28 04-20-2007 03:34 AM
Difference between Java iterator and iterator in Gang of Four Hendrik Maryns Java 18 12-22-2005 05:14 AM
How to convert from std::list<T*>::iterator to std::list<const T*>::iterator? PengYu.UT@gmail.com C++ 6 10-30-2005 03:31 AM
Iterator doubts, Decision on Iterator usage greg C++ 6 07-17-2003 01:26 PM



Advertisments