Solved

Please explain std::pair, std::map and std::set statements

Posted on 2006-11-16
1
538 Views
Last Modified: 2008-02-01
Would someone please explain these item by item. Thanks. 100 points each! (I'll increase points as required)


typedef std::pair<CString, NameType> NameEntry;
   std::map<NameEntry, CString> m_oNameMap;
   std::set<CString> m_oUsedNameSet;
0
Comment
Question by:Christopher Schene
[X]
Welcome to Experts Exchange

Add your voice to the tech community where 5M+ people just like you are talking about what matters.

  • Help others & share knowledge
  • Earn cash & points
  • Learn & ask questions
1 Comment
 
LVL 86

Accepted Solution

by:
jkr earned 100 total points
ID: 17957594
pair<T1,T2> is a heterogeneous pair: it holds one object of type T1 and one of type T2. (http://www.sgi.com/tech/stl/pair.html)

map<Key, Datais a Sorted Associative Container that associates objects of type Key with objects of type Data. Map is a Pair Associative Container, meaning that its value type is pair<const Key, Data>. (http://www.sgi.com/tech/stl/Map.html)

set<Key, Compare> 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 (http://www.sgi.com/tech/stl/set.html)

In your code, 'NameEntry' is defined to be a 'std::pair<CString, NameType>', then a map is created that maps such a 'NameEntry' to a string (a MFC CString to be more precise). Finally, there is a set of CStrings, which means a (sorted) collection of CStrings where each entry is unique.
0

Featured Post

Industry Leaders: We Want Your Opinion!

We value your feedback.

Take our survey and automatically be enter to win anyone of the following:
Yeti Cooler, Amazon eGift Card, and Movie eGift Card!

Question has a verified solution.

If you are experiencing a similar issue, please ask a related question

What is C++ STL?: STL stands for Standard Template Library and is a part of standard C++ libraries. It contains many useful data structures (containers) and algorithms, which can spare you a lot of the time. Today we will look at the STL Vector. …
Basic understanding on "OO- Object Orientation" is needed for designing a logical solution to solve a problem. Basic OOAD is a prerequisite for a coder to ensure that they follow the basic design of OO. This would help developers to understand the b…
The goal of the tutorial is to teach the user how to use functions in C++. The video will cover how to define functions, how to call functions and how to create functions prototypes. Microsoft Visual C++ 2010 Express will be used as a text editor an…
The viewer will learn how to user default arguments when defining functions. This method of defining functions will be contrasted with the non-default-argument of defining functions.

719 members asked questions and received personalized solutions in the past 7 days.

Join the community of 500,000 technology professionals and ask your questions.

Join & Ask a Question