-
Notifications
You must be signed in to change notification settings - Fork 80
/
Demo.cpp
46 lines (39 loc) · 1.57 KB
/
Demo.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
#include <iostream>
#include "sources/MagicalContainer.hpp"
using namespace ariel;
int main() {
// Create a MagicalContainer and add some elements
MagicalContainer container;
container.addElement(17);
container.addElement(2);
container.addElement(25);
container.addElement(9);
container.addElement(3);
// Print container size
std::cout << "Size of container: " << container.size() << std::endl;
// Use AscendingIterator to display elements in ascending order
std::cout << "Elements in ascending order:\n";
MagicalContainer::AscendingIterator ascIter(container);
for (auto it = ascIter.begin(); it != ascIter.end(); ++it) {
std::cout << *it << ' '; // 2 3 9 17 25
}
std::cout << std::endl;
// Use DescendingIterator to display elements in descending order
std::cout << "Elements in cross order:\n";
MagicalContainer::SideCrossIterator crossIter(container);
for (auto it = crossIter.begin(); it != crossIter.end(); ++it) {
std::cout << *it << ' '; // 2 25 3 17 9
}
std::cout << std::endl;
// Use PrimeIterator to display prime numbers only
std::cout << "Prime numbers:\n";
MagicalContainer::PrimeIterator primeIter(container);
for (auto it = primeIter.begin(); it != primeIter.end(); ++it) {
std::cout << *it << ' '; // 2 3 17
}
std::cout << std::endl;
// Remove an element from the container and display the size
container.removeElement(9);
std::cout << "Size of container after removing an element: " << container.size() << std::endl;
return 0;
}