472,805 Members | 911 Online
Bytes | Software Development & Data Engineering Community
Post Job

Home Posts Topics Members FAQ

Join Bytes to post your question to a community of 472,805 software developers and data experts.

Why "associative" in associative container?

set, map, multiset and multimap are all associative containers. But what
does the word "associative" have to do with these 4 containers?
Jun 25 '07 #1
5 1804
"desktop" <ff*@sss.comwrote in message
news:f5**********@news.net.uni-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

Jun 25 '07 #2
Ivan Vecerina a écrit :
"desktop" <ff*@sss.comwrote in message
news:f5**********@news.net.uni-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
Jun 25 '07 #3
desktop wrote:
set, map, multiset and multimap are all associative containers. But what
does the word "associative" have to do with these 4 containers?
Jun 25 '07 #4
"Michael DOUBEZ" <mi************@free.frwrote in message
news:46***********************@news.free.fr...
: Ivan Vecerina a écrit :
: "desktop" <ff*@sss.comwrote in message
: news:f5**********@news.net.uni-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

Jun 25 '07 #5
On Jun 25, 10:26 am, desktop <f...@sss.comwrote:
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:ja*********@gmail.com
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

Jun 26 '07 #6

This thread has been closed and replies have been disabled. Please start a new discussion.

Similar topics

10
by: Audun Røe | last post by:
Hi, I have a list of codes which I want translated into something "understandable". Is there a mechanism such as hashtables that could handle this? (eg. PHP: array('F' => 'Foo', 'C' => 'Cat')) ...
1
by: Dave | last post by:
Hello all, Why is the term "associative" containter used to describe std::set<>, std::map<>, std::multiset<> and std::multimap<>? I always had the impression that it is related to the fact that...
27
by: Abdullah Kauchali | last post by:
Hi folks, Can one rely on the order of keys inserted into an associative Javascript array? For example: var o = new Object(); o = "Adam"; o = "Eve";
2
isladogs
by: isladogs | last post by:
The next Access Europe meeting will be on Wednesday 2 August 2023 starting at 18:00 UK time (6PM UTC+1) and finishing at about 19:15 (7.15PM) The start time is equivalent to 19:00 (7PM) in Central...
0
by: erikbower65 | last post by:
Using CodiumAI's pr-agent is simple and powerful. Follow these steps: 1. Install CodiumAI CLI: Ensure Node.js is installed, then run 'npm install -g codiumai' in the terminal. 2. Connect to...
0
by: erikbower65 | last post by:
Here's a concise step-by-step guide for manually installing IntelliJ IDEA: 1. Download: Visit the official JetBrains website and download the IntelliJ IDEA Community or Ultimate edition based on...
0
by: kcodez | last post by:
As a H5 game development enthusiast, I recently wrote a very interesting little game - Toy Claw ((http://claw.kjeek.com/))。Here I will summarize and share the development experience here, and hope it...
2
isladogs
by: isladogs | last post by:
The next Access Europe meeting will be on Wednesday 6 Sept 2023 starting at 18:00 UK time (6PM UTC+1) and finishing at about 19:15 (7.15PM) The start time is equivalent to 19:00 (7PM) in Central...
0
by: Taofi | last post by:
I try to insert a new record but the error message says the number of query names and destination fields are not the same This are my field names ID, Budgeted, Actual, Status and Differences ...
14
DJRhino1175
by: DJRhino1175 | last post by:
When I run this code I get an error, its Run-time error# 424 Object required...This is my first attempt at doing something like this. I test the entire code and it worked until I added this - If...
5
by: DJRhino | last post by:
Private Sub CboDrawingID_BeforeUpdate(Cancel As Integer) If = 310029923 Or 310030138 Or 310030152 Or 310030346 Or 310030348 Or _ 310030356 Or 310030359 Or 310030362 Or...
0
by: Mushico | last post by:
How to calculate date of retirement from date of birth

By using Bytes.com and it's services, you agree to our Privacy Policy and Terms of Use.

To disable or enable advertisements and analytics tracking please visit the manage ads & tracking page.