-
Notifications
You must be signed in to change notification settings - Fork 0
/
Copy pathtest-removeat-array-list-01.cpp
39 lines (38 loc) · 1.14 KB
/
test-removeat-array-list-01.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
#include <iostream>
#include <chrono>
#include "array_list.hpp"
int main() {
unsigned int n;
std::cin >> n;
array_list l1;
for (unsigned int i = 0; i < n; ++i) {
int x;
std::cin >> x;
l1.push_back(x);
}
auto beg = std::chrono::high_resolution_clock::now();
unsigned int m;
std::cin >> m;
unsigned int removed = 0, not_removed = 0;
for (int i = 0; i < m; ++i) {
int x;
std::cin >> x;
if (l1.remove_at(x))
removed++;
else
not_removed++;
}
auto end = std::chrono::high_resolution_clock::now();
auto elapsed = end - beg;
std::cerr << "[DEBUG] Tried to remove " << m << " element(s)\n";
std::cerr << "[DEBUG] removed " << removed << " element(s)\n";
std::cerr << "[DEBUG] not removed " << not_removed << " element(s)\n";
if (not (l1.size() == n - removed) or (not_removed + removed != m)) {
std::cerr << "[ERROR] check remove_at method!\n";
exit(1);
}
std::cerr << "[INFO] " << "Elapsed time for "
<< removed << " remove_at success : "
<< elapsed.count() << std::endl;
return 0;
}