-
Notifications
You must be signed in to change notification settings - Fork 0
/
Main.cpp
118 lines (102 loc) · 3.63 KB
/
Main.cpp
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
102
103
104
105
106
107
108
109
110
111
112
113
114
115
116
117
118
#include <iostream>
#include <list>
#include <vector>
#include <map>
#include <stack>
#include <queue>
#include <set>
#include <unordered_map>
#include "Student.h"
int main()
{
// List of int's
std::list<int> ListofInts;
ListofInts.push_back(500);
ListofInts.push_back(400);
ListofInts.push_back(300);
ListofInts.push_back(200);
ListofInts.push_back(100);
// List of string's
std::list<std::string> ListofStrings;
ListofStrings.push_back("Hello");
ListofStrings.push_back("ABC");
ListofStrings.push_back("DEF");
ListofStrings.push_back("GHI");
ListofStrings.push_back("JKL");
// Vector of student's
std::vector<Student> vectorOfStudents;
vectorOfStudents.push_back(Student());
vectorOfStudents.push_back(Student());
vectorOfStudents.push_back(Student());
vectorOfStudents.push_back(Student());
// Stack of student pointer's
std::stack<Student*> stackOfStudents;
Student* aStudent = new Student;
// For loop to add student pointer's
for (int i = 0; i < 9; i++)
{
aStudent = new Student;
stackOfStudents.push(aStudent);
}
// While loop to delete student pointer's
while (!stackOfStudents.empty())
{
Student* studentPtr = stackOfStudents.top();
stackOfStudents.pop();
delete studentPtr;
}
// Set of int's
std::set<int> setOfInts;
setOfInts.insert(19);
setOfInts.insert(28);
setOfInts.insert(37);
setOfInts.insert(46);
setOfInts.insert(55);
// Set of Char's
std::set<int> setOfChars;
setOfChars.insert('a');
setOfChars.insert('a');
setOfChars.insert('b');
setOfChars.insert('c');
setOfChars.insert('d');
// Map of movie title's to the year of release
std::map<std::string, int> movieMap;
movieMap["Gone with the Wind"] = 1940;
movieMap["Pulp Fiction"] = 1994;
movieMap["Top Gun"] = 1986;
movieMap["Halloween"] = 1978;
movieMap["The Matrix"] = 1999;
// Unordered map of movie title's to the year of release
std::unordered_map<std::string, int> movieUnorderedMap;
movieUnorderedMap["Gone with the Wind"] = 1940;
movieUnorderedMap["Pulp Fiction"] = 1994;
movieUnorderedMap["Top Gun"] = 1986;
movieUnorderedMap["Halloween"] = 1978;
movieUnorderedMap["The Matrix"] = 1999;
// Unordered map of Student pointer's to int's (posibly student ID numbers)
std::unordered_map<Student*, int> studentPointersToInts;
studentPointersToInts[new Student("Joe", 2.0, 50000, 6.4)] = 157393;
studentPointersToInts[new Student("Michelle", 3.0, 10000, 5.0)] = 240396;
studentPointersToInts[new Student("Steve", 1.0, 70000, 6.0)] = 336278;
studentPointersToInts[new Student("Cindy", 2.5, 500, 5.5)] = 409124;
// Priority queue of student's
std::priority_queue<Student, std::vector<Student>, Student::CompareStudentGPA> priorityqueueOfStudentGPA;
priorityqueueOfStudentGPA.push(Student("Joe", 2.0, 50000, 6.4));
priorityqueueOfStudentGPA.push(Student("Michelle", 3.0, 10000, 5.0));
priorityqueueOfStudentGPA.push(Student("Steve", 1.0, 70000, 6.0));
priorityqueueOfStudentGPA.push(Student("Cindy", 2.5, 500, 5.5));
Student checkStudent_1 = priorityqueueOfStudentGPA.top();
// Priority queue of student pointer's
std::priority_queue<Student*, std::vector<Student*>, Student::CompareStudentDebt> priorityQueueOfStudentDebt;
priorityQueueOfStudentDebt.push(new Student("Joe", 2.0, 50000, 6.4));
priorityQueueOfStudentDebt.push(new Student("Michelle", 3.0, 10000, 5.0));
priorityQueueOfStudentDebt.push(new Student("Steve", 1.0, 70000, 6.0));
priorityQueueOfStudentDebt.push(new Student("Cindy", 2.5, 500, 5.5));
Student* checkStudent_2 = priorityQueueOfStudentDebt.top();
while (!priorityQueueOfStudentDebt.empty())
{
Student* PqStudentPtr = priorityQueueOfStudentDebt.top();
priorityQueueOfStudentDebt.pop();
delete PqStudentPtr;
}
}