diff --git a/cpp08/ex00/Makefile b/cpp08/ex00/Makefile new file mode 100644 index 0000000..64621ad --- /dev/null +++ b/cpp08/ex00/Makefile @@ -0,0 +1,37 @@ +# **************************************************************************** # +# # +# ::: :::::::: # +# Makefile :+: :+: :+: # +# +:+ +:+ +:+ # +# By: apommier +#+ +:+ +#+ # +# +#+#+#+#+#+ +#+ # +# Created: 2022/08/07 19:53:15 by apommier #+# #+# # +# Updated: 2022/08/07 19:53:28 by apommier ### ########.fr # +# # +# **************************************************************************** # + +NAME = a.out +SRCS = main.cpp + +OBJS = ${SRCS:.cpp=.o} +CC = c++ +CFLAGS = -Wall -Wextra -Werror -std=c++98 +RM = rm -rf + +.cpp.o: + $(CC) ${CFLAGS} -c $< -o $(<:.cpp=.o) + +${NAME}: ${OBJS} + ${CC} ${LIB} ${OBJS} -o ${NAME} + +all: ${NAME} + +clean: + @${RM} ${OBJS} + +fclean: clean + @${RM} ${NAME} + +re: fclean all + +.PHONY: all clean fclean re \ No newline at end of file diff --git a/cpp08/ex00/easyfind.hpp b/cpp08/ex00/easyfind.hpp new file mode 100644 index 0000000..858af78 --- /dev/null +++ b/cpp08/ex00/easyfind.hpp @@ -0,0 +1,23 @@ +/* ************************************************************************** */ +/* */ +/* ::: :::::::: */ +/* easyfind.hpp :+: :+: :+: */ +/* +:+ +:+ +:+ */ +/* By: apommier +#+ +:+ +#+ */ +/* +#+#+#+#+#+ +#+ */ +/* Created: 2022/08/07 19:53:14 by apommier #+# #+# */ +/* Updated: 2022/08/07 20:22:02 by apommier ### ########.fr */ +/* */ +/* ************************************************************************** */ + +#include +#include +#include +#include + +template +typename T::iterator easyfind(T &tab, int toFind) +{ + typename T::iterator result = find(tab.begin(), tab.end(), toFind); + return (result); +} \ No newline at end of file diff --git a/cpp08/ex00/main.cpp b/cpp08/ex00/main.cpp new file mode 100644 index 0000000..e015757 --- /dev/null +++ b/cpp08/ex00/main.cpp @@ -0,0 +1,48 @@ +/* ************************************************************************** */ +/* */ +/* ::: :::::::: */ +/* main.cpp :+: :+: :+: */ +/* +:+ +:+ +:+ */ +/* By: apommier +#+ +:+ +#+ */ +/* +#+#+#+#+#+ +#+ */ +/* Created: 2022/08/07 19:53:12 by apommier #+# #+# */ +/* Updated: 2022/08/07 20:33:43 by apommier ### ########.fr */ +/* */ +/* ************************************************************************** */ + +#include "easyfind.hpp" +#include + +template +void printIterator( T it, T end ) +{ + if (it != end) + std::cout << "Iterator: " << *it << std::endl; + else + std::cout << "Iterator reach end() of container (the value isn't in containers) " << std::endl; +} + +int main() +{ + std::vector container; + std::vector::iterator it; + + std::cout << "====================Vector=====================\n"; + for (int i = 0; i < 43; i++) + container.push_back(i); + it = easyfind(container, 42); + printIterator(it, container.end()); + it = easyfind(container, 43); + printIterator(it, container.end()); + + std::cout << "====================Deque=====================\n"; + std::deque container2; + std::deque::iterator it2; + for (int i = 0; i < 43; i++) + container2.push_back(i); + it2 = easyfind(container2, 42); + printIterator(it2, container2.end()); + it2 = easyfind(container2, 43); + printIterator(it2, container2.end()); + return (0); +} \ No newline at end of file diff --git a/cpp08/ex01/Makefile b/cpp08/ex01/Makefile new file mode 100644 index 0000000..9546f13 --- /dev/null +++ b/cpp08/ex01/Makefile @@ -0,0 +1,37 @@ +# **************************************************************************** # +# # +# ::: :::::::: # +# Makefile :+: :+: :+: # +# +:+ +:+ +:+ # +# By: apommier +#+ +:+ +#+ # +# +#+#+#+#+#+ +#+ # +# Created: 2022/08/07 20:32:52 by apommier #+# #+# # +# Updated: 2022/08/07 20:33:01 by apommier ### ########.fr # +# # +# **************************************************************************** # + +NAME = a.out +SRCS = main.cpp + +OBJS = ${SRCS:.cpp=.o} +CC = c++ +CFLAGS = -Wall -Wextra -Werror -std=c++98 +RM = rm -rf + +.cpp.o: + $(CC) ${CFLAGS} -c $< -o $(<:.cpp=.o) + +${NAME}: ${OBJS} + ${CC} ${LIB} ${OBJS} -o ${NAME} + +all: ${NAME} + +clean: + @${RM} ${OBJS} + +fclean: clean + @${RM} ${NAME} + +re: fclean all + +.PHONY: all clean fclean re \ No newline at end of file diff --git a/cpp08/ex01/Span.cpp b/cpp08/ex01/Span.cpp new file mode 100644 index 0000000..cbddf19 --- /dev/null +++ b/cpp08/ex01/Span.cpp @@ -0,0 +1,58 @@ +/* ************************************************************************** */ +/* */ +/* ::: :::::::: */ +/* Span.cpp :+: :+: :+: */ +/* +:+ +:+ +:+ */ +/* By: apommier +#+ +:+ +#+ */ +/* +#+#+#+#+#+ +#+ */ +/* Created: 2022/08/07 20:32:51 by apommier #+# #+# */ +/* Updated: 2022/08/07 22:04:55 by apommier ### ########.fr */ +/* */ +/* ************************************************************************** */ + +Span::Span() +{ + this->_storageSize = 0; +} + +Span::Span(unsigned int size) +{ + this->_storageSize = size; +} + +Span::Span(const Span ©) +{ + *this = copy; +} + +Span::~Span() +{ + +} + +void Span::addNumber() +{ + +} + +int Span::shortestSpan() +{ + +} + +int Span::longestSpan() +{ + +} + +void Span::addRangeOfIterators() +{ + +} + +Span &Span::operator=( const Span &rhs ) +{ + this->_storageSize = rhs._storageSize; + this->_storage = rhs._storage; + return (*this); +} \ No newline at end of file diff --git a/cpp08/ex01/Span.hpp b/cpp08/ex01/Span.hpp new file mode 100644 index 0000000..bded2f2 --- /dev/null +++ b/cpp08/ex01/Span.hpp @@ -0,0 +1,45 @@ +/* ************************************************************************** */ +/* */ +/* ::: :::::::: */ +/* Span.hpp :+: :+: :+: */ +/* +:+ +:+ +:+ */ +/* By: apommier +#+ +:+ +#+ */ +/* +#+#+#+#+#+ +#+ */ +/* Created: 2022/08/07 20:33:52 by apommier #+# #+# */ +/* Updated: 2022/08/07 22:04:22 by apommier ### ########.fr */ +/* */ +/* ************************************************************************** */ + +class Span{ + public : + + Span(); + Span(unsigned int size); + Span(const Span ©); + ~Span(); + void addNumber(); + int shortestSpan(); + int longestSpan(); + void addRangeOfIterators(); + + Span &operator=( const Span &rhs ); + + class fullContainer : public std::exception { + char const *what() const throw() + { + return ("Container is full !"); + } + }; + + class notEnoughNumber : public std::exception { + char const *what() const throw() + { + return ("You need at least 2 number to find a span!"); + } + }; + + private : + + std::vector _storage; + int _storageSize; +} \ No newline at end of file diff --git a/cpp08/ex01/main.cpp b/cpp08/ex01/main.cpp new file mode 100644 index 0000000..a317382 --- /dev/null +++ b/cpp08/ex01/main.cpp @@ -0,0 +1,16 @@ +/* ************************************************************************** */ +/* */ +/* ::: :::::::: */ +/* main.cpp :+: :+: :+: */ +/* +:+ +:+ +:+ */ +/* By: apommier +#+ +:+ +#+ */ +/* +#+#+#+#+#+ +#+ */ +/* Created: 2022/08/07 20:32:50 by apommier #+# #+# */ +/* Updated: 2022/08/07 20:33:25 by apommier ### ########.fr */ +/* */ +/* ************************************************************************** */ + +int main() +{ + +} \ No newline at end of file diff --git a/cpp08/ex02/Makefile b/cpp08/ex02/Makefile new file mode 100644 index 0000000..a30ba23 --- /dev/null +++ b/cpp08/ex02/Makefile @@ -0,0 +1,37 @@ +# **************************************************************************** # +# # +# ::: :::::::: # +# Makefile :+: :+: :+: # +# +:+ +:+ +:+ # +# By: apommier +#+ +:+ +#+ # +# +#+#+#+#+#+ +#+ # +# Created: 2022/08/07 19:53:32 by apommier #+# #+# # +# Updated: 2022/08/07 19:53:35 by apommier ### ########.fr # +# # +# **************************************************************************** # + +NAME = a.out +SRCS = main.cpp + +OBJS = ${SRCS:.cpp=.o} +CC = c++ +CFLAGS = -Wall -Wextra -Werror -std=c++98 +RM = rm -rf + +.cpp.o: + $(CC) ${CFLAGS} -c $< -o $(<:.cpp=.o) + +${NAME}: ${OBJS} + ${CC} ${LIB} ${OBJS} -o ${NAME} + +all: ${NAME} + +clean: + @${RM} ${OBJS} + +fclean: clean + @${RM} ${NAME} + +re: fclean all + +.PHONY: all clean fclean re \ No newline at end of file diff --git a/cpp08/ex02/MutantStack.hpp b/cpp08/ex02/MutantStack.hpp new file mode 100644 index 0000000..e69de29 diff --git a/cpp08/ex02/main.cpp b/cpp08/ex02/main.cpp new file mode 100644 index 0000000..e69de29