From the course: C++ Standard Template Library

Unlock the full course today

Join today to access over 22,600 courses taught by industry experts or purchase this course individually.

Sets and maps usage example

Sets and maps usage example - C++ Tutorial

From the course: C++ Standard Template Library

Start my 1-month free trial

Sets and maps usage example

- [Narrator] Let's solve a basic problem. Supposed we want to keep track of landmark pins on a map, as the content, a name will do. A string. Coordinates are expressed as latitude and longitude pairs. And these are the coordinates used in GPS. We'll use a pair of integers for this. And we will use positive integers. So for example, if we have a coordinate of 34 degrees, 24 minutes, North, and 90 degrees West, then that would translate to 34 and 270. Don't worry about this conversion. For now, let's just think of this pair, as a pair of integers, positive integers. Here are some important details about this problem: First, we expect to have as many pins as needed, but they will all be typed in by a human. By this I mean, that we may have many pins but not infinite; Not even thousands. Next, there are infinite coordinates. That means that it's more appropriate to represent them with floating point numbers rather than integers. A two-dimensional vector indexed by these coordinates is…

Contents