From 1808fc6e9628650d9a47466f500f3fc1dff65270 Mon Sep 17 00:00:00 2001 From: kinou-p Date: Tue, 22 Nov 2022 14:21:39 +0100 Subject: [PATCH] crap mandatory aprt --- containers/iterators/enable_if.hpp | 2 +- containers/iterators/equal.hpp | 29 +++++++++++ containers/iterators/is_integral.hpp | 2 +- containers/iterators/make_pair.hpp | 24 +++++++++ containers/iterators/pair.hpp | 75 ++++++++++++++++++++++++++++ containers/vector.hpp | 41 +-------------- 6 files changed, 132 insertions(+), 41 deletions(-) diff --git a/containers/iterators/enable_if.hpp b/containers/iterators/enable_if.hpp index 3d9ebab..9a497e8 100644 --- a/containers/iterators/enable_if.hpp +++ b/containers/iterators/enable_if.hpp @@ -6,7 +6,7 @@ /* 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 */ /* */ /* ************************************************************************** */ diff --git a/containers/iterators/equal.hpp b/containers/iterators/equal.hpp index e69de29..d5d965d 100644 --- a/containers/iterators/equal.hpp +++ b/containers/iterators/equal.hpp @@ -0,0 +1,29 @@ +/* ************************************************************************** */ +/* */ +/* ::: :::::::: */ +/* equal.hpp :+: :+: :+: */ +/* +:+ +:+ +:+ */ +/* By: apommier +#+ +:+ +#+ */ +/* +#+#+#+#+#+ +#+ */ +/* Created: 2022/11/22 14:11:09 by apommier #+# #+# */ +/* Updated: 2022/11/22 14:13:11 by apommier ### ########.fr */ +/* */ +/* ************************************************************************** */ + +#pragma once + +namespace ft +{ + template + bool equal ( InputIterator1 first1, InputIterator1 last1, InputIterator2 first2 ) + { + while (first1!=last1) + { + if (!(*first1 == *first2)) + return false; + ++first1; ++first2; + } + return true; + } + +} \ No newline at end of file diff --git a/containers/iterators/is_integral.hpp b/containers/iterators/is_integral.hpp index 46ef5af..14fe73d 100644 --- a/containers/iterators/is_integral.hpp +++ b/containers/iterators/is_integral.hpp @@ -6,7 +6,7 @@ /* 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 */ /* */ /* ************************************************************************** */ diff --git a/containers/iterators/make_pair.hpp b/containers/iterators/make_pair.hpp index e69de29..904f551 100644 --- a/containers/iterators/make_pair.hpp +++ b/containers/iterators/make_pair.hpp @@ -0,0 +1,24 @@ +/* ************************************************************************** */ +/* */ +/* ::: :::::::: */ +/* make_pair.hpp :+: :+: :+: */ +/* +:+ +:+ +:+ */ +/* By: apommier +#+ +:+ +#+ */ +/* +#+#+#+#+#+ +#+ */ +/* 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 + pair make_pair (T1 x, T2 y) + { + return ( pair(x,y) ); + } +} \ No newline at end of file diff --git a/containers/iterators/pair.hpp b/containers/iterators/pair.hpp index e69de29..3dbf0a4 100644 --- a/containers/iterators/pair.hpp +++ b/containers/iterators/pair.hpp @@ -0,0 +1,75 @@ +/* ************************************************************************** */ +/* */ +/* ::: :::::::: */ +/* pair.hpp :+: :+: :+: */ +/* +:+ +:+ +:+ */ +/* By: apommier +#+ +:+ +#+ */ +/* +#+#+#+#+#+ +#+ */ +/* Created: 2022/11/22 13:39:29 by apommier #+# #+# */ +/* Updated: 2022/11/22 14:11:41 by apommier ### ########.fr */ +/* */ +/* ************************************************************************** */ + +#pragma once + +namespace ft +{ + template + 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 + 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 + bool operator== (const pair& lhs, const pair& rhs) + { + return (lhs.first==rhs.first && lhs.second==rhs.second); + } + + template + bool operator!= (const pair& lhs, const pair& rhs) + { + return (!(lhs==rhs)); + } + + template + bool operator< (const pair& lhs, const pair& rhs) + { + return (lhs.first + bool operator<= (const pair& lhs, const pair& rhs) + { + return (!(rhs + bool operator> (const pair& lhs, const pair& rhs) + { + return (rhs + bool operator>= (const pair& lhs, const pair& rhs) + { + return (!(lhs +#+ +:+ +#+ */ /* +#+#+#+#+#+ +#+ */ /* 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& lhs, const vector& rhs); template friend bool operator>= (const vector& lhs, const vector& rhs); +}; //--------------------------------------------- //---------OPERATOR OVERLOAD FUNCTION---------- //--------------------------------------------- - - // template - // bool operator== (const vector& lhs, const vector& rhs) - // { - - // } - - // template - // bool operator!= (const vector& lhs, const vector& rhs) - // { - - // } - - // template - // bool operator< (const vector& lhs, const vector& rhs) - // { - - // } - - // template - // bool operator<= (const vector& lhs, const vector& rhs) - // { - - // } - - // template - // bool operator> (const vector& lhs, const vector& rhs) - // { - - // } - - // template - // bool operator>= (const vector& lhs, const vector& rhs) - // { - - // } -}; template bool operator== (const vector& lhs, const vector& rhs) { if (lhs._size != rhs._size) return (lhs._size == rhs._size); - int i = 0; while (lhs._size - i && lhs._tab[i] == rhs._tab[i]) i++;