Velocity Reviews - Computer Hardware Reviews

Velocity Reviews > Newsgroups > Programming > C++ > Why "associative" in associative container?

Reply
Thread Tools

Why "associative" in associative container?

 
 
desktop
Guest
Posts: n/a
 
      06-25-2007
set, map, multiset and multimap are all associative containers. But what
does the word "associative" have to do with these 4 containers?
 
Reply With Quote
 
 
 
 
Ivan Vecerina
Guest
Posts: n/a
 
      06-25-2007
"desktop" <(E-Mail Removed)> wrote in message
news:f5nu6p$2hv$(E-Mail Removed)-c.dk...
: set, map, multiset and multimap are all associative containers. But
: what does the word "associative" have to do with these 4 containers?

Good question

I think that the name comes from the fact that each element stored
within the container is "associated" with a key, from the element
can be retrieved.

Of course, set and multiset do not explicitly store additional data
along with the key itself - they're therefore a bit of a degenerate
case. Yet you will often seen std::set used with an element type that
stores more data than the key itself, and a custom Comparator.

--
http://ivan.vecerina.com/contact/?subject=NG_POST <- email contact form
Brainbench MVP for C++ <> http://www.brainbench.com

 
Reply With Quote
 
 
 
 
Michael DOUBEZ
Guest
Posts: n/a
 
      06-25-2007
Ivan Vecerina a écrit :
> "desktop" <(E-Mail Removed)> wrote in message
> news:f5nu6p$2hv$(E-Mail Removed)-c.dk...
> : set, map, multiset and multimap are all associative containers. But
> : what does the word "associative" have to do with these 4 containers?
>
> Good question
>
> I think that the name comes from the fact that each element stored
> within the container is "associated" with a key, from the element
> can be retrieved.
>
> Of course, set and multiset do not explicitly store additional data
> along with the key itself - they're therefore a bit of a degenerate
> case. Yet you will often seen std::set used with an element type that
> stores more data than the key itself, and a custom Comparator.


In fact, for set and multiset, the element is the key itself. This is
why values are const in set and multiset. They are called Simple
Associative Containers.

For more information, see:
http://www.sgi.com/tech/stl/AssociativeContainer.html

Michael
 
Reply With Quote
 
Ron Natalie
Guest
Posts: n/a
 
      06-25-2007
desktop wrote:
> set, map, multiset and multimap are all associative containers. But what
> does the word "associative" have to do with these 4 containers?

 
Reply With Quote
 
Ivan Vecerina
Guest
Posts: n/a
 
      06-25-2007
"Michael DOUBEZ" <(E-Mail Removed)> wrote in message
news:467f9654$0$19195$(E-Mail Removed)...
: Ivan Vecerina a écrit :
: > "desktop" <(E-Mail Removed)> wrote in message
: > news:f5nu6p$2hv$(E-Mail Removed)-c.dk...
: > : set, map, multiset and multimap are all associative containers.
But
: > : what does the word "associative" have to do with these 4
containers?
: >
: > Good question
: >
: > I think that the name comes from the fact that each element stored
: > within the container is "associated" with a key, from the element
: > can be retrieved.
: >
: > Of course, set and multiset do not explicitly store additional data
: > along with the key itself - they're therefore a bit of a degenerate
: > case. Yet you will often seen std::set used with an element type
that
: > stores more data than the key itself, and a custom Comparator.
:
: In fact, for set and multiset, the element is the key itself. This is
: why values are const in set and multiset.

They are (now) required to be, athough this was not the case in the
original 1998 C++ standard, but was later debated and settled --
limiting some possible (-/mis/ab)uses of std::set and std::multiset.
For those interested:
http://www.open-std.org/jtc1/sc22/wg...fects.html#103

For instance, the current MSVC2005+SP1 still allows std::set key
modification...
--
http://ivan.vecerina.com/contact/?subject=NG_POST <- email contact form

 
Reply With Quote
 
James Kanze
Guest
Posts: n/a
 
      06-26-2007
On Jun 25, 10:26 am, desktop <(E-Mail Removed)> wrote:
> set, map, multiset and multimap are all associative
> containers. But what does the word "associative" have to do
> with these 4 containers?


They are addressable (indexed) by content, and "associative" is
the standard technical word for that. (Long before the STL,
Perl and AWK referred to their arrays as "associative arrays".)
See e.g.: http://www.nist.gov/dads/HTML/assocarray.html.

--
James Kanze (GABI Software) email:(E-Mail Removed)
Conseils en informatique orientée objet/
Beratung in objektorientierter Datenverarbeitung
9 place Sémard, 78210 St.-Cyr-l'École, France, +33 (0)1 30 23 00 34

 
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
Associative Array Joe Rigley ASP .Net 3 10-14-2009 01:14 PM
Javascript Associative array syntax not valid. Why?!?!?!? Kevin Javascript 8 12-21-2007 05:03 PM
why why why why why Mr. SweatyFinger ASP .Net 4 12-21-2006 01:15 PM
findcontrol("PlaceHolderPrice") why why why why why why why why why why why Mr. SweatyFinger ASP .Net 2 12-02-2006 03:46 PM
How to read associative array from file? nospam Perl 2 06-26-2004 09:46 AM



Advertisments