Jump to content
  • Advertisement
Sign in to follow this  
3dcgmodeling

set

This topic is 4076 days old which is more than the 365 day threshold we allow for new replies. Please post a new topic.

If you intended to correct an error in the post then please contact us.

Recommended Posts

Advertisement
The key is the value.

In a map, you have the pair and the data-structure is sorted only on the key.
In a set, you have a value and the data-structure is sorted only on that value.


map:
[1,"one"] [2,"two"] [3,"three"]

set:
[1] [2] [3]


Both of these sort on 1,2, and 3. The map just has extra data attached to each node.

Share this post


Link to post
Share on other sites
I assume you are talking about the C++ std::set? Indeed, it only has a 'key' because the key is the value. If you want an associative container, use std::map


jfl.


[Edit: Aw shucks, too slow on dem 'Submit Reply']

Share this post


Link to post
Share on other sites
A nice description about std::set can be found here.
Copy+pasted from the link:
Quote:

Set is a Sorted Associative Container that stores objects of type Key. Set is a Simple Associative Container, meaning that its value type, as well as its key type, is Key. It is also a Unique Associative Container, meaning that no two elements are the same.

Share this post


Link to post
Share on other sites
Sign in to follow this  

  • Advertisement
×

Important Information

By using GameDev.net, you agree to our community Guidelines, Terms of Use, and Privacy Policy.

Participate in the game development conversation and more when you create an account on GameDev.net!

Sign me up!