?
Solved

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

Posted on 2006-11-16
1
Medium Priority
?
548 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 400 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

On Demand Webinar - Networking for the Cloud Era

This webinar discusses:
-Common barriers companies experience when moving to the cloud
-How SD-WAN changes the way we look at networks
-Best practices customers should employ moving forward with cloud migration
-What happens behind the scenes of SteelConnect’s one-click button

Question has a verified solution.

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

Templates For Beginners Or How To Encourage The Compiler To Work For You Introduction This tutorial is targeted at the reader who is, perhaps, familiar with the basics of C++ but would prefer a little slower introduction to the more ad…
Written by John Humphreys C++ Threading and the POSIX Library This article will cover the basic information that you need to know in order to make use of the POSIX threading library available for C and C++ on UNIX and most Linux systems.   [s…
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 additional member functions of the vector class. Specifically, the capacity and swap member functions will be introduced.
Suggested Courses

800 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