-
Notifications
You must be signed in to change notification settings - Fork 0
Expand file tree
/
Copy pathsets.cpp
More file actions
101 lines (67 loc) · 1.78 KB
/
sets.cpp
File metadata and controls
101 lines (67 loc) · 1.78 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
75
76
77
78
79
80
81
82
83
84
85
86
87
88
89
90
91
92
93
94
95
96
97
98
99
100
101
//
// Created by jskag on 7/1/2022.
//
//Set Data Type (9.1)
//What's a Set?
//1. a container that holds objects
//2. no duplicates
//3. the container controls the order of the objects
//What operations are supported by a Set?
//What's the abstract interface for a Set?
//size();
//add(item);
//remove(item);
//find(item);
//Maps in the C++ Library
#include <set>
//std::set
#include <iostream>
#include <fstream>
#include <sstream>
#include <string>
#include <list>
#include <vector>
using namespace std;
int main() {
//What happens if you add 2 to a set that already contains 2?
//What order is commonly used for the items in a Set?
//Classwork
//You may work with a partner.
//What does the program print?
//Set S1;
//S1.add(4);
//S1.add(2);
//S1.add(8);
//S1.add(4);
//S1.add(1);
//S1.add(8);
//print(S1);
//Set S2;
//for ( item : S1 )
//S2.add( item );
//print(S2);
//S1.remove(2);
//S1.remove(4);
//print(S1);
//for ( item : S1 )
//S2.remove( item );
//print(S2);
//Sets in the C++ Library
//#include <set>
//std::set
//What are some of the operations supported by std::set?
//size_t size() const;
//pair<iterator,bool> insert ( const ItemType& item );
//size_t erase ( const ItemType& item ); // returns number of items erased
//iterator find ( const ItemType& item ) const;
//size_t count ( const ItemType& item ) const;
//DEMO (change list to set)
//Why Set?
//A List holds a collection of objects and
//allows you to control each object's location.
//A Set holds a collection of objects but
//does not allow you to control object location.
//Why is a Set useful?
//DEMO (time for find on list vs set)
return 0;
}