separate make pair

This commit is contained in:
hugogogo
2022-07-01 11:56:23 +02:00
parent ae646ee58a
commit 6e230109db
10 changed files with 104 additions and 1119 deletions

23
headers/make_pair.hpp Normal file
View File

@@ -0,0 +1,23 @@
#ifndef MAKE_PAIR_HPP
# define MAKE_PAIR_HPP
# define PR_TPL template < class T1, class T2 >
# define PR pair<T1, T2>
#include "pair.hpp"
namespace ft {
PR_TPL PR
make_pair(T1 x, T2 y) {
return PR(x, y) ;
}
} // namespace ft
# undef PR
# undef PR_TPL
#endif

View File

@@ -12,6 +12,7 @@
# include "lexicographical_compare.hpp"
# include "pair.hpp"
# include "make_pair.hpp"
# include "map_node.hpp"
# include "map_iterator.hpp"
@@ -174,8 +175,6 @@ private:
// BBST
enum {INSERT, ERASE};
node<value_type>* _swap_nodes(node<value_type>* st_old, node<value_type>* st_new);
node<value_type>* _shift_nodes(node<value_type>* st_old, node<value_type>* st_new);
void _balance(node<value_type>* n, bool action);
short _compute_height(node<value_type>* n);
short _balance_factor(node<value_type>* n);

View File

@@ -26,13 +26,16 @@ PR_TPL
* copliens :
************/
PR_TPL PR::
pair() {
}
pair() {}
PR_TPL template< typename U, typename V > PR::
pair(const pair<U,V>& pr) : first(pr.first), second(pr.second) {
pair(const pair<U,V>& pr)
: first(pr.first)
, second(pr.second) {
}
PR_TPL PR::
pair(const first_type& a, const second_type& b) : first(a), second(b) {
pair(const first_type& a, const second_type& b)
: first(a)
, second(b) {
}
@@ -48,8 +51,7 @@ PR_TPL
PR_TPL
bool operator<(const PR& lhs, const PR& rhs) {
return (
lhs.first < rhs.first
return (lhs.first < rhs.first
|| ( !(rhs.first < lhs.first) && (lhs.second < rhs.second) )
);
}
@@ -74,11 +76,6 @@ PR_TPL
return !(lhs < rhs);
}
PR_TPL
PR make_pair(T1 x, T2 y) {
return PR(x, y) ;
}
} // namespace ft