473,396 Members | 1,997 Online
Bytes | Software Development & Data Engineering Community
Post Job

Home Posts Topics Members FAQ

Join Bytes to post your question to a community of 473,396 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 1846
"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";
0
by: Charles Arthur | last post by:
How do i turn on java script on a villaon, callus and itel keypad mobile phone
0
by: ryjfgjl | last post by:
In our work, we often receive Excel tables with data in the same format. If we want to analyze these data, it can be difficult to analyze them because the data is spread across multiple Excel files...
0
by: emmanuelkatto | last post by:
Hi All, I am Emmanuel katto from Uganda. I want to ask what challenges you've faced while migrating a website to cloud. Please let me know. Thanks! Emmanuel
0
BarryA
by: BarryA | last post by:
What are the essential steps and strategies outlined in the Data Structures and Algorithms (DSA) roadmap for aspiring data scientists? How can individuals effectively utilize this roadmap to progress...
1
by: nemocccc | last post by:
hello, everyone, I want to develop a software for my android phone for daily needs, any suggestions?
1
by: Sonnysonu | last post by:
This is the data of csv file 1 2 3 1 2 3 1 2 3 1 2 3 2 3 2 3 3 the lengths should be different i have to store the data by column-wise with in the specific length. suppose the i have to...
0
Oralloy
by: Oralloy | last post by:
Hello folks, I am unable to find appropriate documentation on the type promotion of bit-fields when using the generalised comparison operator "<=>". The problem is that using the GNU compilers,...
0
by: Hystou | last post by:
Overview: Windows 11 and 10 have less user interface control over operating system update behaviour than previous versions of Windows. In Windows 11 and 10, there is no way to turn off the Windows...
0
tracyyun
by: tracyyun | last post by:
Dear forum friends, With the development of smart home technology, a variety of wireless communication protocols have appeared on the market, such as Zigbee, Z-Wave, Wi-Fi, Bluetooth, etc. Each...

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.