-
Notifications
You must be signed in to change notification settings - Fork 0
Expand file tree
/
Copy pathmaps.cpp
More file actions
74 lines (47 loc) · 1.32 KB
/
maps.cpp
File metadata and controls
74 lines (47 loc) · 1.32 KB
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
73
74
//
// Created by jskag on 7/1/2022.
//
//Map Data Type (9.2)
//What's a Map?
//1. a data structure that associates keys with values
//2. a set of key-value pairs
//3. keys are unique, values can be repeated
//What are some examples of Maps?
//phone book (name -> number)
//dictionary (word -> definition)
//What operations are supported by a Map?
//What's the abstract interface for a Map?
//size();
//add(key, value);
//remove(key);
//getValue(key);
//Maps in the C++ Library
#include <map>
//std::map
#include <iostream>
#include <fstream>
#include <sstream>
#include <string>
#include <list>
#include <vector>
#include <set>
using namespace std;
int main() {
//What are some of the operations supported by std::map?
//size_t size() const;
//size_t count ( const KeyType& key ) const;
//size_t erase ( const KeyType& key ); // returns number of items erased
//ValueType& operator[] ( const KeyType& key ); // key is added
// if not already in map
//How do you add a new mapping?
//map["bob"] = 16;
//How do you remove a mapping?
//map.erase("bob");
//How do you iterate over a map?
//iterator points to a pair object
//pair->first is the key
//pair->second is the value
//DEMO (demo6, iterate over a map)
//DEMO (demo8, word frequency counter)
return 0;
}