crap mandatory aprt

This commit is contained in:
kinou-p 2022-11-22 14:21:39 +01:00
parent f978d9909a
commit 1808fc6e96
6 changed files with 132 additions and 41 deletions

View File

@ -6,7 +6,7 @@
/* By: apommier <apommier@student.42.fr> +#+ +:+ +#+ */ /* By: apommier <apommier@student.42.fr> +#+ +:+ +#+ */
/* +#+#+#+#+#+ +#+ */ /* +#+#+#+#+#+ +#+ */
/* Created: 2022/11/19 05:59:46 by apommier #+# #+# */ /* Created: 2022/11/19 05:59:46 by apommier #+# #+# */
/* Updated: 2022/11/19 10:55:47 by apommier ### ########.fr */ /* Updated: 2022/11/22 14:09:44 by apommier ### ########.fr */
/* */ /* */
/* ************************************************************************** */ /* ************************************************************************** */

View File

@ -0,0 +1,29 @@
/* ************************************************************************** */
/* */
/* ::: :::::::: */
/* equal.hpp :+: :+: :+: */
/* +:+ +:+ +:+ */
/* By: apommier <apommier@student.42.fr> +#+ +:+ +#+ */
/* +#+#+#+#+#+ +#+ */
/* Created: 2022/11/22 14:11:09 by apommier #+# #+# */
/* Updated: 2022/11/22 14:13:11 by apommier ### ########.fr */
/* */
/* ************************************************************************** */
#pragma once
namespace ft
{
template <class InputIterator1, class InputIterator2>
bool equal ( InputIterator1 first1, InputIterator1 last1, InputIterator2 first2 )
{
while (first1!=last1)
{
if (!(*first1 == *first2))
return false;
++first1; ++first2;
}
return true;
}
}

View File

@ -6,7 +6,7 @@
/* By: apommier <apommier@student.42.fr> +#+ +:+ +#+ */ /* By: apommier <apommier@student.42.fr> +#+ +:+ +#+ */
/* +#+#+#+#+#+ +#+ */ /* +#+#+#+#+#+ +#+ */
/* Created: 2022/11/19 10:55:07 by apommier #+# #+# */ /* Created: 2022/11/19 10:55:07 by apommier #+# #+# */
/* Updated: 2022/11/19 10:55:51 by apommier ### ########.fr */ /* Updated: 2022/11/22 14:07:55 by apommier ### ########.fr */
/* */ /* */
/* ************************************************************************** */ /* ************************************************************************** */

View File

@ -0,0 +1,24 @@
/* ************************************************************************** */
/* */
/* ::: :::::::: */
/* make_pair.hpp :+: :+: :+: */
/* +:+ +:+ +:+ */
/* By: apommier <apommier@student.42.fr> +#+ +:+ +#+ */
/* +#+#+#+#+#+ +#+ */
/* Created: 2022/11/22 12:04:50 by apommier #+# #+# */
/* Updated: 2022/11/22 14:05:43 by apommier ### ########.fr */
/* */
/* ************************************************************************** */
#pragma once
#include "pair.hpp"
namespace ft
{
template <class T1,class T2>
pair<T1,T2> make_pair (T1 x, T2 y)
{
return ( pair<T1,T2>(x,y) );
}
}

View File

@ -0,0 +1,75 @@
/* ************************************************************************** */
/* */
/* ::: :::::::: */
/* pair.hpp :+: :+: :+: */
/* +:+ +:+ +:+ */
/* By: apommier <apommier@student.42.fr> +#+ +:+ +#+ */
/* +#+#+#+#+#+ +#+ */
/* Created: 2022/11/22 13:39:29 by apommier #+# #+# */
/* Updated: 2022/11/22 14:11:41 by apommier ### ########.fr */
/* */
/* ************************************************************************** */
#pragma once
namespace ft
{
template<class _T1, class _T2>
struct pair{
typedef _T1 first_type;
typedef _T2 second_type;
_T1 _first;
_T2 _second;
pair(): _first(), _second() {}
pair( const T1& x, const T2& y ); : _first(x), _second(y) {}
template<class _U1, class _U2>
pair(const pair<_U1, _U2>& p): _first(p._first), _second(p._second) { }
pair& operator=(pair& other)
{
_first = other.first;
_second = other.second;
return (*this);
}
};
template <class T1, class T2>
bool operator== (const pair<T1,T2>& lhs, const pair<T1,T2>& rhs)
{
return (lhs.first==rhs.first && lhs.second==rhs.second);
}
template <class T1, class T2>
bool operator!= (const pair<T1,T2>& lhs, const pair<T1,T2>& rhs)
{
return (!(lhs==rhs));
}
template <class T1, class T2>
bool operator< (const pair<T1,T2>& lhs, const pair<T1,T2>& rhs)
{
return (lhs.first<rhs.first || (!(rhs.first<lhs.first) && lhs.second<rhs.second));
}
template <class T1, class T2>
bool operator<= (const pair<T1,T2>& lhs, const pair<T1,T2>& rhs)
{
return (!(rhs<lhs));
}
template <class T1, class T2>
bool operator> (const pair<T1,T2>& lhs, const pair<T1,T2>& rhs)
{
return (rhs<lhs);
}
template <class T1, class T2>
bool operator>= (const pair<T1,T2>& lhs, const pair<T1,T2>& rhs)
{
return (!(lhs<rhs));
}
}

View File

@ -6,7 +6,7 @@
/* By: apommier <apommier@student.42.fr> +#+ +:+ +#+ */ /* By: apommier <apommier@student.42.fr> +#+ +:+ +#+ */
/* +#+#+#+#+#+ +#+ */ /* +#+#+#+#+#+ +#+ */
/* Created: 2022/10/12 19:46:32 by apommier #+# #+# */ /* Created: 2022/10/12 19:46:32 by apommier #+# #+# */
/* Updated: 2022/11/22 11:24:31 by apommier ### ########.fr */ /* Updated: 2022/11/22 14:20:29 by apommier ### ########.fr */
/* */ /* */
/* ************************************************************************** */ /* ************************************************************************** */
@ -481,54 +481,17 @@ class vector
friend bool operator> (const vector<Temp,Alloc>& lhs, const vector<Temp,Alloc>& rhs); friend bool operator> (const vector<Temp,Alloc>& lhs, const vector<Temp,Alloc>& rhs);
template <class Temp, class Alloc> template <class Temp, class Alloc>
friend bool operator>= (const vector<Temp,Alloc>& lhs, const vector<Temp,Alloc>& rhs); friend bool operator>= (const vector<Temp,Alloc>& lhs, const vector<Temp,Alloc>& rhs);
};
//--------------------------------------------- //---------------------------------------------
//---------OPERATOR OVERLOAD FUNCTION---------- //---------OPERATOR OVERLOAD FUNCTION----------
//--------------------------------------------- //---------------------------------------------
// template <class T, class Alloc>
// bool operator== (const vector<T,Alloc>& lhs, const vector<T,Alloc>& rhs)
// {
// }
// template <class T, class Alloc>
// bool operator!= (const vector<T,Alloc>& lhs, const vector<T,Alloc>& rhs)
// {
// }
// template <class T, class Alloc>
// bool operator< (const vector<T,Alloc>& lhs, const vector<T,Alloc>& rhs)
// {
// }
// template <class T, class Alloc>
// bool operator<= (const vector<T,Alloc>& lhs, const vector<T,Alloc>& rhs)
// {
// }
// template <class T, class Alloc>
// bool operator> (const vector<T,Alloc>& lhs, const vector<T,Alloc>& rhs)
// {
// }
// template <class T, class Alloc>
// bool operator>= (const vector<T,Alloc>& lhs, const vector<T,Alloc>& rhs)
// {
// }
};
template <class T, class Alloc> template <class T, class Alloc>
bool operator== (const vector<T,Alloc>& lhs, const vector<T,Alloc>& rhs) bool operator== (const vector<T,Alloc>& lhs, const vector<T,Alloc>& rhs)
{ {
if (lhs._size != rhs._size) if (lhs._size != rhs._size)
return (lhs._size == rhs._size); return (lhs._size == rhs._size);
int i = 0; int i = 0;
while (lhs._size - i && lhs._tab[i] == rhs._tab[i]) while (lhs._size - i && lhs._tab[i] == rhs._tab[i])
i++; i++;