-
Notifications
You must be signed in to change notification settings - Fork 0
Expand file tree
/
Copy pathmain.cpp
More file actions
77 lines (62 loc) · 1.89 KB
/
Copy pathmain.cpp
File metadata and controls
77 lines (62 loc) · 1.89 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
/**
* @file main.cpp
* @author Sam Emison and Cole Belew
* @date 2024-12-06
* @brief Main
*
* Main.cpp, calls functions and holds the stress test
*/
#include <iostream>
#include "deque.h"
using namespace std;
/**
* Stress test
*
* @pre
* @return void
* @post
*
*/
void stressTest() {
Deque d;
int NUM_OPERATIONS;
cin >> NUM_OPERATIONS;
cout << endl;
cout << "Starting stress test..." << endl;
// --- Push elements to the back ---
cout << "\n--- Pushing Elements to the Back ---" << endl;
for (int i = 0; i < NUM_OPERATIONS; ++i) {
d.push_back(i);
cout << "Pushed " << i << " to the back." << endl;
}
// --- Accessing elements ---
cout << "\n--- Accessing Elements (first 5 and last 5) ---" << endl;
for (int i = 0; i < 5; ++i) {
cout << "Accessing index " << i << ": " << d[i] << endl;
}
for (int i = NUM_OPERATIONS - 5; i < NUM_OPERATIONS; ++i) {
cout << "Accessing index " << i << ": " << d[i] << endl;
}
// --- Pop elements from the front ---
cout << "\n--- Popping Elements from the Front ---" << endl;
for (int i = 0; i < NUM_OPERATIONS / 2; ++i) {
cout << "Popped " << d.front() << " from the front." << endl;
d.pop_front();
}
// --- Pop elements from the back ---
cout << "\n--- Popping Elements from the Back ---" << endl;
for (int i = 0; i < NUM_OPERATIONS / 2; ++i) {
cout << "Popped " << d.back() << " from the back." << endl;
d.pop_back();
}
// --- Stress Test Summary ---
cout << "\n--- Stress Test Summary ---" << endl;
cout << "Total elements remaining: " << d.size() << endl;
cout << "Deque is " << (d.empty() ? "empty" : "not empty") << "." << endl;
cout << "Stress test completed." << endl;
}
int main() {
cout << "Please enter a number for the stress test...";
stressTest();
return 0;
}