[Last Call] Learn about multicloud storage options and how to improve your company's cloud strategy. Register Now

x
?
Solved

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

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

Tech or Treat! - Giveaway

Submit an article about your scariest tech experience—and the solution—and you’ll be automatically entered to win one of 4 fantastic tech gadgets.

Question has a verified solution.

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

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…
  Included as part of the C++ Standard Template Library (STL) is a collection of generic containers. Each of these containers serves a different purpose and has different pros and cons. It is often difficult to decide which container to use and …
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 goal of the video will be to teach the user the concept of local variables and scope. An example of a locally defined variable will be given as well as an explanation of what scope is in C++. The local variable and concept of scope will be relat…

650 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