-
Notifications
You must be signed in to change notification settings - Fork 0
Expand file tree
/
Copy pathalgorithm.hpp
More file actions
52 lines (46 loc) · 1.73 KB
/
Copy pathalgorithm.hpp
File metadata and controls
52 lines (46 loc) · 1.73 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
/* ************************************************************************** */
/* */
/* ::: :::::::: */
/* algorithm.hpp :+: :+: :+: */
/* +:+ +:+ +:+ */
/* By: alienard <alienard@student.42.fr> +#+ +:+ +#+ */
/* +#+#+#+#+#+ +#+ */
/* Created: 2021/04/13 12:10:58 by alienard #+# #+# */
/* Updated: 2021/05/20 20:40:44 by alienard ### ########.fr */
/* */
/* ************************************************************************** */
#pragma once
#include <iostream>
#include <string>
#include <limits>
// https://en.cppreference.com/w/cpp/algorithm
namespace ft {
template< class InputIt1, class InputIt2 >
bool lexicographical_compare( InputIt1 first1, InputIt1 last1, InputIt2 first2, InputIt2 last2 ){
for ( ; (first1 != last1) && (first2 != last2); ++first1, (void) ++first2 ) {
if (*first1 < *first2) return true;
if (*first2 < *first1) return false;
}
return (first1 == last1) && (first2 != last2);
}
template< class T >
struct less {
bool operator()(const T& lhs, const T& rhs ) const {
return lhs < rhs;
}
};
template< class T >
void swap( T& a, T& b ){
T tmp = a;
a = b;
b = tmp;
}
template <class Iterator>
size_t iterator_range_size(Iterator first, Iterator last) {
size_t size = 0 ;
for (; first != last ; first++){
size++;
}
return (size);
}
}