Jelajahi Sumber

added module 08 containers & iterator

bastien 2 minggu lalu
induk
melakukan
2f77c7a15a

+ 50 - 0
Module_08/ex00/Makefile

@@ -0,0 +1,50 @@
+# **************************************************************************** #
+#                                                                              #
+#                                                         :::      ::::::::    #
+#    Makefile                                           :+:      :+:    :+:    #
+#                                                     +:+ +:+         +:+      #
+#    By: bchanot <bchanot@42.fr>                    +#+  +:+       +#+         #
+#                                                 +#+#+#+#+#+   +#+            #
+#    Created: 2016/07/24 00:00:08 by bchanot           #+#    #+#              #
+#    Updated: 2026/01/11 16:26:46 by bchanot          ###   ########.fr        #
+#                                                                              #
+# **************************************************************************** #
+
+NAME = a.out
+MAKE_LIBS = make --no-print-directory
+SRCS_DIR = srcs/
+OBJS_DIR = .objects/
+CC = g++ -Wall -Wextra -Werror -g
+INC = -I./includes
+FILES = main 
+SRCS = $(FILES)
+OBJS = $(addprefix $(OBJS_DIR), $(addsuffix .o, $(SRCS)))
+RED = \033[1;31m
+BLUE = \033[1;34m
+CYAN = \033[0;36m
+GREEN = \033[1;32m
+YELLOW = \033[1;33m
+EOC = \033[0m
+
+all: $(NAME)
+
+$(NAME): $(OBJS)
+	@echo -e "$(GREEN)Objects created.$(EOC)"
+	@$(CC) $(OBJS) $(INC) -o $(NAME)
+	@echo -e "$(GREEN)Compilation complete.$(EOC)"
+
+$(OBJS_DIR)%.o: $(SRCS_DIR)%.cpp
+	@mkdir -p $(dir $@)
+	$(CC) -c $< $(INC) -o $@
+
+clean:
+	@echo -e "$(RED)Deleting objects.$(EOC)"
+	@/bin/rm -rf $(OBJS_DIR)
+
+fclean: clean
+	@echo -e "$(RED)Deleting binary.$(EOC)"
+	@/bin/rm -rf $(NAME)
+
+re: fclean all
+
+.PHONY: all clean fclean re

+ 42 - 0
Module_08/ex00/srcs/main.cpp

@@ -0,0 +1,42 @@
+/* ************************************************************************** */
+/*                                                                            */
+/*                                                        :::      ::::::::   */
+/*   main.cpp                                           :+:      :+:    :+:   */
+/*                                                    +:+ +:+         +:+     */
+/*   By: bchanot <bchanot@42.fr>                    +#+  +:+       +#+        */
+/*                                                +#+#+#+#+#+   +#+           */
+/*   Created: 2026/01/13 17:54:18 by bchanot           #+#    #+#             */
+/*   Updated: 2026/01/13 18:03:54 by bchanot          ###   ########.fr       */
+/*                                                                            */
+/* ************************************************************************** */
+
+#include <iostream>
+#include <vector>
+#include <iterator>
+
+template< typename T >
+std::vector<int>::iterator   easyFind(T & vec, int const & j) {
+    std::vector<int>::iterator it;
+
+    for (it = std::begin(vec); it < std::end(vec); it++) {
+        if (*it == j)
+            return it;
+    }
+    throw std::exception();
+}
+
+
+int main(void)
+{
+    std::vector<int> vec = {0, 23, 456, 67};
+    std::vector<int>::iterator it;
+
+    try {
+        it = easyFind(vec, 22);
+        std::cout << "Found ! it is : " << *it << std::endl;
+
+    } catch (std::exception &e) {
+        std::cout << "Didn't found the given int in the vec" << std::endl;
+    }
+    return 0;
+}

+ 50 - 0
Module_08/ex01-bis/Makefile

@@ -0,0 +1,50 @@
+# **************************************************************************** #
+#                                                                              #
+#                                                         :::      ::::::::    #
+#    Makefile                                           :+:      :+:    :+:    #
+#                                                     +:+ +:+         +:+      #
+#    By: bchanot <bchanot@42.fr>                    +#+  +:+       +#+         #
+#                                                 +#+#+#+#+#+   +#+            #
+#    Created: 2016/07/24 00:00:08 by bchanot           #+#    #+#              #
+#    Updated: 2026/01/13 19:57:03 by bchanot          ###   ########.fr        #
+#                                                                              #
+# **************************************************************************** #
+
+NAME = a.out
+MAKE_LIBS = make --no-print-directory
+SRCS_DIR = srcs/
+OBJS_DIR = .objects/
+CC = g++ -Wall -Wextra -Werror -g
+INC = -I./includes
+FILES = main Span
+SRCS = $(FILES)
+OBJS = $(addprefix $(OBJS_DIR), $(addsuffix .o, $(SRCS)))
+RED = \033[1;31m
+BLUE = \033[1;34m
+CYAN = \033[0;36m
+GREEN = \033[1;32m
+YELLOW = \033[1;33m
+EOC = \033[0m
+
+all: $(NAME)
+
+$(NAME): $(OBJS)
+	@echo -e "$(GREEN)Objects created.$(EOC)"
+	@$(CC) $(OBJS) $(INC) -o $(NAME)
+	@echo -e "$(GREEN)Compilation complete.$(EOC)"
+
+$(OBJS_DIR)%.o: $(SRCS_DIR)%.cpp
+	@mkdir -p $(dir $@)
+	$(CC) -c $< $(INC) -o $@
+
+clean:
+	@echo -e "$(RED)Deleting objects.$(EOC)"
+	@/bin/rm -rf $(OBJS_DIR)
+
+fclean: clean
+	@echo -e "$(RED)Deleting binary.$(EOC)"
+	@/bin/rm -rf $(NAME)
+
+re: fclean all
+
+.PHONY: all clean fclean re

+ 56 - 0
Module_08/ex01-bis/includes/Span.hpp

@@ -0,0 +1,56 @@
+/* ************************************************************************** */
+/*                                                                            */
+/*                                                        :::      ::::::::   */
+/*   Span.hpp                                           :+:      :+:    :+:   */
+/*                                                    +:+ +:+         +:+     */
+/*   By: bchanot <bchanot@42.fr>                    +#+  +:+       +#+        */
+/*                                                +#+#+#+#+#+   +#+           */
+/*   Created: 2026/01/13 18:18:53 by bchanot           #+#    #+#             */
+/*   Updated: 2026/01/14 13:38:57 by bchanot          ###   ########.fr       */
+/*                                                                            */
+/* ************************************************************************** */
+
+#ifndef SPAN_HPP
+# define SPAN_HPP
+
+# include <iostream>
+# include <string>
+#include <vector>
+
+class Span
+{
+	public:
+		Span( unsigned int const & src );
+		Span( Span const & src );
+		~Span();
+
+		Span &			operator=( Span const & rhs );
+
+		class isFullException : public std::exception {
+			public :
+				virtual const char * what() const throw() {
+					return ("The Span container is full");
+				}
+		};
+
+		void 			addNumber(int const & add);
+		unsigned int	shortestSpan(void) const;
+		unsigned int	longestSpan(void) const;
+		void			fullFillSpan(void);
+		void			rangeFillSpan(size_t start, size_t end);
+		void			fillSpan(size_t n);
+
+		unsigned int 	getSize(void) const;
+
+	private:
+		int				*_value;
+		unsigned int	_max;
+		unsigned int	_size;
+
+		Span();
+
+};
+
+std::ostream &			operator<<( std::ostream & o, Span const & i );
+
+#endif /* ************************************************************ SPAN_H */

+ 154 - 0
Module_08/ex01-bis/srcs/Span.cpp

@@ -0,0 +1,154 @@
+/* ************************************************************************** */
+/*                                                                            */
+/*                                                        :::      ::::::::   */
+/*   Span.cpp                                           :+:      :+:    :+:   */
+/*                                                    +:+ +:+         +:+     */
+/*   By: bchanot <bchanot@42.fr>                    +#+  +:+       +#+        */
+/*                                                +#+#+#+#+#+   +#+           */
+/*   Created: 2026/01/13 18:18:53 by bchanot           #+#    #+#             */
+/*   Updated: 2026/01/14 13:32:20 by bchanot          ###   ########.fr       */
+/*                                                                            */
+/* ************************************************************************** */
+
+#include "Span.hpp"
+#include <climits>
+
+/*
+** ------------------------------- CONSTRUCTOR --------------------------------
+*/
+
+Span::Span( unsigned int const & size ) : _value(NULL), _max(size), _size(0)
+{
+	this->_value = new int[size];
+}
+
+Span::Span( const Span & src ) : _value(NULL), _max(src._max), _size(src._size)
+{
+	this->_value = new int[src._max];
+	for (size_t i = 0; i < this->_max; i++) {
+		this->_value[i] = src._value[i];
+	}
+}
+
+
+/*
+** -------------------------------- DESTRUCTOR --------------------------------
+*/
+
+Span::~Span()
+{
+	delete [] this->_value;
+}
+
+
+/*
+** --------------------------------- OVERLOAD ---------------------------------
+*/
+
+Span &				Span::operator=( Span const & rhs )
+{
+	(void)rhs;
+	//if ( this != &rhs )
+	//{
+		//this->_value = rhs.getValue();
+	//}
+	return *this;
+}
+
+std::ostream &			operator<<( std::ostream & o, Span const & i )
+{
+	(void)i;
+	//o << "Value = " << i.getValue();
+	return o;
+}
+
+
+/*
+** --------------------------------- METHODS ----------------------------------
+*/
+
+void 			Span::addNumber(int const & add) {
+	if (this->_size >= this->_max)
+		throw isFullException() ;
+	this->_value[this->_size] = add;
+	this->_size++;
+}
+
+void			Span::fullFillSpan(void) {
+	srand(time(0));
+	size_t	size;
+
+	size = this->_size;
+	for (size_t i = size; i < this->_max; i++) {
+		this->addNumber(rand() % INT_MAX / 1000);
+//		std::cout << this->_value[i] << std::endl;
+	}
+}
+
+void			Span::fillSpan(size_t n) {
+	srand(time(0));
+	size_t	size;
+	size_t	j;
+
+	j = 0;
+	size = this->_size;
+	for (size_t i = size; j < n && i < this->_max; i++, j++) {
+		this->addNumber(rand() % INT_MAX / 1000);
+//		std::cout << this->_value[i] << std::endl;
+	}
+}
+
+void			Span::rangeFillSpan(size_t start, size_t end) {
+	srand(time(0));
+	size_t	size;
+	size_t	j;
+
+	while (start < end) {
+		this->addNumber(start);
+		start++;
+//		std::cout << this->_value[i] << std::endl;
+	}
+}
+
+unsigned int	Span::shortestSpan(void) const {
+	int		*check;
+	int		sub;
+	
+	check = this->_value;
+	sub = INT_MAX;
+
+	for (size_t i = 0; i < this->_size; i++) {
+		for (size_t j = 0; j < this->_size; j++) {
+			int sub_check = this->_value[i] - check[j];
+			if (sub_check > 0 && sub_check < sub) {
+				sub = sub_check;
+			}
+		}
+	}
+	return sub;
+}
+
+unsigned int	Span::longestSpan(void) const {
+	int		max;
+	int		min;
+
+	min = max = this->_value[0];
+	for (size_t i = 1; i < this->_size; i++) {
+		if (this->_value[i] > max) {
+			max = this->_value[i];
+		} else if (this->_value[i] < min) {
+			min = this->_value[i];
+		}
+	}
+	return (max - min);
+}
+
+/*
+** --------------------------------- ACCESSOR ---------------------------------
+*/
+
+unsigned int 	Span::getSize(void) const {
+	return this->_size;
+}
+
+/* ************************************************************************** */

+ 26 - 0
Module_08/ex01-bis/srcs/main.cpp

@@ -0,0 +1,26 @@
+/* ************************************************************************** */
+/*                                                                            */
+/*                                                        :::      ::::::::   */
+/*   main.cpp                                           :+:      :+:    :+:   */
+/*                                                    +:+ +:+         +:+     */
+/*   By: bchanot <bchanot@42.fr>                    +#+  +:+       +#+        */
+/*                                                +#+#+#+#+#+   +#+           */
+/*   Created: 2026/01/13 17:54:18 by bchanot           #+#    #+#             */
+/*   Updated: 2026/01/14 13:14:28 by bchanot          ###   ########.fr       */
+/*                                                                            */
+/* ************************************************************************** */
+
+#include "Span.hpp"
+
+int main(void)
+{
+    Span sp = Span(5);
+sp.addNumber(6);
+sp.addNumber(3);
+sp.addNumber(17);
+sp.addNumber(9);
+sp.addNumber(11);
+    std::cout << sp.shortestSpan() << std::endl;
+    std::cout << sp.longestSpan() << std::endl;
+    return 0;
+}

+ 50 - 0
Module_08/ex01/Makefile

@@ -0,0 +1,50 @@
+# **************************************************************************** #
+#                                                                              #
+#                                                         :::      ::::::::    #
+#    Makefile                                           :+:      :+:    :+:    #
+#                                                     +:+ +:+         +:+      #
+#    By: bchanot <bchanot@42.fr>                    +#+  +:+       +#+         #
+#                                                 +#+#+#+#+#+   +#+            #
+#    Created: 2016/07/24 00:00:08 by bchanot           #+#    #+#              #
+#    Updated: 2026/01/13 19:57:03 by bchanot          ###   ########.fr        #
+#                                                                              #
+# **************************************************************************** #
+
+NAME = a.out
+MAKE_LIBS = make --no-print-directory
+SRCS_DIR = srcs/
+OBJS_DIR = .objects/
+CC = g++ -Wall -Wextra -Werror -g
+INC = -I./includes
+FILES = main Span
+SRCS = $(FILES)
+OBJS = $(addprefix $(OBJS_DIR), $(addsuffix .o, $(SRCS)))
+RED = \033[1;31m
+BLUE = \033[1;34m
+CYAN = \033[0;36m
+GREEN = \033[1;32m
+YELLOW = \033[1;33m
+EOC = \033[0m
+
+all: $(NAME)
+
+$(NAME): $(OBJS)
+	@echo -e "$(GREEN)Objects created.$(EOC)"
+	@$(CC) $(OBJS) $(INC) -o $(NAME)
+	@echo -e "$(GREEN)Compilation complete.$(EOC)"
+
+$(OBJS_DIR)%.o: $(SRCS_DIR)%.cpp
+	@mkdir -p $(dir $@)
+	$(CC) -c $< $(INC) -o $@
+
+clean:
+	@echo -e "$(RED)Deleting objects.$(EOC)"
+	@/bin/rm -rf $(OBJS_DIR)
+
+fclean: clean
+	@echo -e "$(RED)Deleting binary.$(EOC)"
+	@/bin/rm -rf $(NAME)
+
+re: fclean all
+
+.PHONY: all clean fclean re

+ 56 - 0
Module_08/ex01/includes/Span.hpp

@@ -0,0 +1,56 @@
+/* ************************************************************************** */
+/*                                                                            */
+/*                                                        :::      ::::::::   */
+/*   Span.hpp                                           :+:      :+:    :+:   */
+/*                                                    +:+ +:+         +:+     */
+/*   By: bchanot <bchanot@42.fr>                    +#+  +:+       +#+        */
+/*                                                +#+#+#+#+#+   +#+           */
+/*   Created: 2026/01/13 18:18:53 by bchanot           #+#    #+#             */
+/*   Updated: 2026/01/14 16:18:13 by bchanot          ###   ########.fr       */
+/*                                                                            */
+/* ************************************************************************** */
+
+#ifndef SPAN_HPP
+# define SPAN_HPP
+
+# include <iostream>
+# include <string>
+#include <vector>
+#include <iterator>
+
+class Span
+{
+	public:
+		Span( unsigned int const & src );
+		Span( Span const & src );
+		~Span();
+
+		Span &			operator=( Span const & rhs );
+
+		class isFullException : public std::exception {
+			public :
+				virtual const char * what() const throw() {
+					return ("The Span container is full");
+				}
+		};
+
+		void 				addNumber(int const & add);
+		unsigned int		shortestSpan(void) const;
+		unsigned int		longestSpan(void) const;
+		void				fullFillSpan(void);
+		void				rangeFillSpan(size_t start, size_t end);
+		void				fillSpan(size_t n);
+
+		unsigned int 		getSize(void) const;
+
+	private:
+		std::vector<int>	_values;
+		unsigned int		_max;
+
+		Span();
+
+};
+
+std::ostream &			operator<<( std::ostream & o, Span const & i );
+
+#endif /* ************************************************************ SPAN_H */

+ 154 - 0
Module_08/ex01/srcs/Span.cpp

@@ -0,0 +1,154 @@
+/* ************************************************************************** */
+/*                                                                            */
+/*                                                        :::      ::::::::   */
+/*   Span.cpp                                           :+:      :+:    :+:   */
+/*                                                    +:+ +:+         +:+     */
+/*   By: bchanot <bchanot@42.fr>                    +#+  +:+       +#+        */
+/*                                                +#+#+#+#+#+   +#+           */
+/*   Created: 2026/01/13 18:18:53 by bchanot           #+#    #+#             */
+/*   Updated: 2026/01/14 17:08:45 by bchanot          ###   ########.fr       */
+/*                                                                            */
+/* ************************************************************************** */
+
+#include "Span.hpp"
+#include <climits>
+
+/*
+** ------------------------------- CONSTRUCTOR --------------------------------
+*/
+
+Span::Span( unsigned int const & size ) : _values(0), _max(size)
+{
+	this->_values.reserve(size);
+}
+
+Span::Span( const Span & src ) : _values(0), _max(src._max)
+{
+	std::vector<int>::const_iterator it;
+	
+	this->_values.reserve(src._max);
+	for (it = std::begin(src._values); it < std::end(src._values); it++) {
+		this->_values.emplace_back(*it);
+	}
+}
+
+
+/*
+** -------------------------------- DESTRUCTOR --------------------------------
+*/
+
+Span::~Span()
+{
+}
+
+
+/*
+** --------------------------------- OVERLOAD ---------------------------------
+*/
+
+Span &				Span::operator=( Span const & rhs )
+{
+	(void)rhs;
+	//if ( this != &rhs )
+	//{
+		//this->_value = rhs.getValue();
+	//}
+	return *this;
+}
+
+std::ostream &			operator<<( std::ostream & o, Span const & i )
+{
+	(void)i;
+	//o << "Value = " << i.getValue();
+	return o;
+}
+
+
+/*
+** --------------------------------- METHODS ----------------------------------
+*/
+
+void 			Span::addNumber(int const & add) {
+	if (this->_values.size() >= this->_max)
+		throw isFullException() ;
+	this->_values.emplace_back(add);
+}
+
+void			Span::fullFillSpan(void) {
+	srand(time(0));
+
+	for (size_t i = this->_values.size(); i < this->_max; i++) {
+		this->addNumber(rand() % INT_MAX / 1000);
+	}
+}
+
+void			Span::fillSpan(size_t n) {
+	srand(time(0));
+	size_t	j;
+
+	j = 0;
+	for (size_t i = this->_values.size(); j < n && i < this->_max; i++, j++) {
+		this->addNumber(rand() % INT_MAX / 1000);
+	}
+}
+
+void			Span::rangeFillSpan(size_t start, size_t end) {
+	srand(time(0));
+	
+	while (start < end) {
+		try {
+			this->addNumber(start);
+		} catch (std::exception &e) {
+			std::cout << e.what() << std::endl;
+			break ;
+		}
+		start++;
+	}
+}
+
+unsigned int	Span::shortestSpan(void) const {
+	std::vector<int>	const			check = this->_values;
+	std::vector<int>::const_iterator	iti;
+	std::vector<int>::const_iterator	itj;
+	int									sub;	
+
+	sub = INT_MAX;
+
+	for (iti = std::begin(this->_values); iti < std::end(this->_values); iti++) {
+		for (itj = std::begin(check); itj < std::end(check); itj++) {
+			int sub_check = *iti - *itj;
+			if (sub_check > 0 && sub_check < sub) {
+				sub = sub_check;
+			}
+		}
+	}
+	return sub;
+}
+
+unsigned int	Span::longestSpan(void) const {
+	int		max;
+	int		min;
+
+	std::vector<int>::const_iterator	it;
+	it = std::begin(this->_values);
+
+	min = max = *it;
+	for (; it < std::end(this->_values); it++) {
+		if (*it > max) {
+			max = *it;
+		} else if (*it < min) {
+			min = *it;
+		}
+	}
+	return (max - min);
+}
+
+/*
+** --------------------------------- ACCESSOR ---------------------------------
+*/
+
+unsigned int 	Span::getSize(void) const {
+	return this->_values.size();
+}
+
+/* ************************************************************************** */

+ 22 - 0
Module_08/ex01/srcs/main.cpp

@@ -0,0 +1,22 @@
+/* ************************************************************************** */
+/*                                                                            */
+/*                                                        :::      ::::::::   */
+/*   main.cpp                                           :+:      :+:    :+:   */
+/*                                                    +:+ +:+         +:+     */
+/*   By: bchanot <bchanot@42.fr>                    +#+  +:+       +#+        */
+/*                                                +#+#+#+#+#+   +#+           */
+/*   Created: 2026/01/13 17:54:18 by bchanot           #+#    #+#             */
+/*   Updated: 2026/01/14 16:18:52 by bchanot          ###   ########.fr       */
+/*                                                                            */
+/* ************************************************************************** */
+
+#include "Span.hpp"
+
+int main(void)
+{
+    Span sp = Span(500);
+    sp.fullFillSpan();
+    std::cout << sp.shortestSpan() << std::endl;
+    std::cout << sp.longestSpan() << std::endl;
+    return 0;
+}

+ 50 - 0
Module_08/ex02/Makefile

@@ -0,0 +1,50 @@
+# **************************************************************************** #
+#                                                                              #
+#                                                         :::      ::::::::    #
+#    Makefile                                           :+:      :+:    :+:    #
+#                                                     +:+ +:+         +:+      #
+#    By: bchanot <bchanot@42.fr>                    +#+  +:+       +#+         #
+#                                                 +#+#+#+#+#+   +#+            #
+#    Created: 2016/07/24 00:00:08 by bchanot           #+#    #+#              #
+#    Updated: 2026/01/14 18:41:24 by bchanot          ###   ########.fr        #
+#                                                                              #
+# **************************************************************************** #
+
+NAME = a.out
+MAKE_LIBS = make --no-print-directory
+SRCS_DIR = srcs/
+OBJS_DIR = .objects/
+CC = g++ -Wall -Wextra -Werror -g
+INC = -I./includes
+FILES = main
+SRCS = $(FILES)
+OBJS = $(addprefix $(OBJS_DIR), $(addsuffix .o, $(SRCS)))
+RED = \033[1;31m
+BLUE = \033[1;34m
+CYAN = \033[0;36m
+GREEN = \033[1;32m
+YELLOW = \033[1;33m
+EOC = \033[0m
+
+all: $(NAME)
+
+$(NAME): $(OBJS)
+	@echo -e "$(GREEN)Objects created.$(EOC)"
+	@$(CC) $(OBJS) $(INC) -o $(NAME)
+	@echo -e "$(GREEN)Compilation complete.$(EOC)"
+
+$(OBJS_DIR)%.o: $(SRCS_DIR)%.cpp
+	@mkdir -p $(dir $@)
+	$(CC) -c $< $(INC) -o $@
+
+clean:
+	@echo -e "$(RED)Deleting objects.$(EOC)"
+	@/bin/rm -rf $(OBJS_DIR)
+
+fclean: clean
+	@echo -e "$(RED)Deleting binary.$(EOC)"
+	@/bin/rm -rf $(NAME)
+
+re: fclean all
+
+.PHONY: all clean fclean re

+ 53 - 0
Module_08/ex02/includes/MutantStack.hpp

@@ -0,0 +1,53 @@
+/* ************************************************************************** */
+/*                                                                            */
+/*                                                        :::      ::::::::   */
+/*   MutantStack.hpp                                    :+:      :+:    :+:   */
+/*                                                    +:+ +:+         +:+     */
+/*   By: bchanot <bchanot@42.fr>                    +#+  +:+       +#+        */
+/*                                                +#+#+#+#+#+   +#+           */
+/*   Created: 2026/01/14 17:17:11 by bchanot           #+#    #+#             */
+/*   Updated: 2026/01/14 19:17:32 by bchanot          ###   ########.fr       */
+/*                                                                            */
+/* ************************************************************************** */
+
+#ifndef MUTANTSTACK_HPP
+# define MUTANTSTACK_HPP
+
+# include <iostream>
+# include <string>
+#include <deque>
+#include <stack>
+#include <iterator>
+
+template < typename T, typename Container = std::deque<T> >
+class MutantStack : public std::stack<T, Container>
+{
+	public:
+
+		MutantStack() : MutantStack<T, Container>::stack() {};
+		MutantStack( MutantStack const & src ) : MutantStack<T, Container>::stack(src) {};
+		virtual ~MutantStack() {};
+
+		MutantStack<T, Container>	&operator=( MutantStack const & rhs ) {
+			if (this != &rhs)
+				this->MutantStack<T, Container>::stack::operator=(rhs);
+			return *this;
+		}
+
+		typedef typename Container::iterator				iterator;
+		typedef typename Container::reverse_iterator		reverse_iterator;
+		typedef typename Container::const_iterator			const_iterator;
+		typedef typename Container::const_reverse_iterator	const_reverse_iterator;
+
+		iterator begin() { return this->c.begin(); };
+		const_iterator begin() const { return this->c.begin(); };
+		iterator end() { return this->c.end(); };
+		const_iterator end() const { return this->c.end(); };
+		reverse_iterator rbegin() { return this->c.rbegin(); };
+		const_reverse_iterator rbegin() const { return this->c.rbegin(); };
+		reverse_iterator rend() { return this->c.rend(); };
+		const_reverse_iterator rend() const { return this->c.rend(); };
+
+};
+
+#endif /* ***************************************************** MUTANTSTACK_H */

+ 39 - 0
Module_08/ex02/srcs/main.cpp

@@ -0,0 +1,39 @@
+/* ************************************************************************** */
+/*                                                                            */
+/*                                                        :::      ::::::::   */
+/*   main.cpp                                           :+:      :+:    :+:   */
+/*                                                    +:+ +:+         +:+     */
+/*   By: bchanot <bchanot@42.fr>                    +#+  +:+       +#+        */
+/*                                                +#+#+#+#+#+   +#+           */
+/*   Created: 2026/01/13 17:54:18 by bchanot           #+#    #+#             */
+/*   Updated: 2026/01/14 18:35:59 by bchanot          ###   ########.fr       */
+/*                                                                            */
+/* ************************************************************************** */
+
+#include "MutantStack.hpp"
+
+int main()
+{
+    MutantStack<int> mstack;
+    mstack.push(5);
+    mstack.push(17);
+    std::cout << mstack.top() << std::endl;
+    mstack.pop();
+    std::cout << mstack.size() << std::endl;
+    mstack.push(3);
+    mstack.push(5);
+    mstack.push(737);
+//[...]
+    mstack.push(0);
+    MutantStack<int>::iterator it = mstack.begin();
+    MutantStack<int>::iterator ite = mstack.end();
+    ++it;
+    --it;
+    while (it != ite)
+    {
+        std::cout << *it << std::endl;
+        ++it;
+    }
+    std::stack<int> s(mstack);
+    return 0;
+}