-
Notifications
You must be signed in to change notification settings - Fork 0
Expand file tree
/
Copy pathmain.cpp
More file actions
65 lines (57 loc) · 1.83 KB
/
main.cpp
File metadata and controls
65 lines (57 loc) · 1.83 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
/* ************************************************************************** */
/* */
/* ::: :::::::: */
/* main.cpp :+: :+: :+: */
/* +:+ +:+ +:+ */
/* By: zelhajou <zelhajou@student.42.fr> +#+ +:+ +#+ */
/* +#+#+#+#+#+ +#+ */
/* Created: 2025/01/07 15:25:45 by zelhajou #+# #+# */
/* Updated: 2025/02/18 20:39:10 by zelhajou ### ########.fr */
/* */
/* ************************************************************************** */
#include "easyfind.hpp"
#include <iostream>
#include <vector>
#include <list>
template <typename T>
void printContainer(T &container)
{
for (typename T::iterator it = container.begin(); it != container.end(); it++)
{
std::cout << *it << " ";
}
std::cout << std::endl;
}
int main()
{
std::vector<int> vec;
std::list<int> lst;
for (int i = 1; i <= 10; i++)
{
vec.push_back(i * 10);
lst.push_back(i * 5);
}
printContainer(vec);
printContainer(lst);
try
{
std::vector<int>::iterator it = easyfind(vec, 10);
std::cout << "Found: " << *it << std::endl;
std::list<int>::iterator it2 = easyfind(lst, 50);
std::cout << "Found: " << *it2 << std::endl;
}
catch(const std::exception& e)
{
std::cerr << e.what() << '\n';
}
try
{
std::vector<int>::iterator it = easyfind(vec, 500);
std::cout << "Found: " << *it << std::endl;
}
catch(const std::exception& e)
{
std::cerr << e.what() << '\n';
}
return 0;
}