Enter your Sign on user name and password.

Forgot password?
Sign In | Subscribe
Start learning today, and be successful in your academic & professional career. Start Today!
Loading video...
This is a quick preview of the lesson. For full access, please Log In or Sign up.
For more information, please see full course syllabus of Intermediate C++
  • Discussion

  • Study Guides

  • Download Lecture Slides

  • Table of Contents

  • Related Services

Start Learning Now

Our free lessons will get you started (Adobe Flash® required).
Get immediate access to our entire library.

Sign up for Educator.com

Membership Overview

  • Unlimited access to our entire library of courses.
  • Search and jump to exactly what you want to learn.
  • *Ask questions and get answers from the community and our teachers!
  • Practice questions with step-by-step solutions.
  • Download lesson files for programming and software training practice.
  • Track your course viewing progress.
  • Download lecture slides for taking notes.
  • Learn at your own pace... anytime, anywhere!

Containers, Set, Map

  • Create a program to load a “vector” with strings that represent unique user ID’s for system login.
    • Loop until the user flags the program to stop looping
    • In each loop, request a new user ID
    • If that user ID is unique, add it to the vector. Otherwise, complain and ask the user to enter it again
    • Test for uniqueness using a “set”
  • One very useful tool is a “properties file.” This file consists of an almost unlimited series of “variable=value” pairs, so that the program can modify its behavior based on its current environment.
    • We have a program that needs access to a database. The access parameters will be different on different machines, so it is not feasible to “hard-code” that into the program. In order for the program to log in to the database, it needs the following information:
      network name of the database host
      port number for network communication
      user login name
      user password
      database name
    • Create a “properties file” that will look like:
      HOSTNAME={name of host}
      PORT={port of host}
      USER={user login}
      PASSWORD={login password}
      DATABASE={name of database}
    • Write a program that reads this file into a “map”. You want to be able to read this data, in any order, and then use it to call the appropriate functions to connect to a database. We won’t worry about actually using any particular database, so just print out the information. E.g.,
      cout << "The user name is: ";
      cout << properties["USER"] << endl;
    • Be sure to validate the information to make sure all of it is there! The program will not be able to login if any of that information is missing.

Containers, Set, Map

Lecture Slides are screen-captured images of important points in the lecture. Students can download and print out these lecture slide images to do practice problems as well as take notes while watching the lecture.

  • Intro 0:00
  • Lesson Overview 0:11
  • Tree Structures for Sets/Maps 2:01
    • What's the Value?
  • Pair Template Class 4:45
    • Allows a Function to Return 'Two' Values Instead of the Normal One
    • Example for an Integer Set
    • Example for Map with a String Key, Double Value
  • Set, Multiset 8:03
    • What's a Set
    • Elements are the Key
    • Custom Class for Ordering
  • Get Data In to Set 10:28
    • Constructors
    • Insert (Value)
    • Insert (Position, Value)
    • Insert (First, Last)
  • Get Data Out of Set 13:28
    • Erase
    • Find
    • Lower_Bound
    • Upper_Bound
    • Iterators Positioned Such That a For-Loop Can 'Start at Zero'
  • Set Examples 16:32
  • Map, Multimap 19:15
  • Get Data In to Map 20:45
    • Constructors
    • Insert a Key Value Pair
    • Insert Position
    • Insert (First, Last)
  • Get Data Out of Map 22:37
    • Operator
    • Erase
    • Find, Lower & Upper Bound
  • Map Examples 25:37
  • Comparison Class 29:34
    • Example
  • What About Duplicates? 33:29
    • Define a Pair to Receive a Container Iterator and a Boolean
    • Example
  • Useful Maps 35:10