├── QUEUE └── mains │ ├── size_main.cpp_new.cpp │ ├── front_main.cpp │ ├── back_main.cpp │ ├── .empty_main.cpp │ ├── empty_main.cpp │ ├── size_main.cpp │ ├── pop_main.cpp │ └── push_main.cpp ├── LIST └── mains │ ├── unique_main.cpp_new.cpp │ ├── reverseIterator_main.cpp │ ├── swap_main.cpp │ ├── assign_main.cpp │ ├── maxSize_main.cpp │ ├── .empty_main.cpp │ ├── begin_main.cpp │ ├── end_main.cpp │ ├── front_main.cpp │ ├── rend_main.cpp │ ├── empty_main.cpp │ ├── rbegin_main.cpp │ ├── pushBack_main.cpp │ ├── short_main.cpp │ ├── reverse_main.cpp │ ├── pushFront_main.cpp │ ├── popBack_main.cpp │ ├── operator=_main.cpp │ ├── back_main.cpp │ ├── resize_main.cpp │ ├── popFront_main.cpp │ └── size_main.cpp ├── MAP └── mains │ ├── valueComp_main.cpp_new.cpp │ ├── size_main.cpp │ ├── .empty_main.cpp │ ├── maxSize_main.cpp │ ├── empty_main.cpp │ ├── rend_main.cpp │ ├── operator=_main.cpp │ ├── valueComp_main.cpp │ ├── operator[]_main.cpp │ ├── equalRange_main.cpp │ ├── count_main.cpp │ ├── find_main.cpp │ ├── keyComp_main.cpp │ ├── clear_main.cpp │ ├── relationalOperators_main.cpp │ ├── upperBound_main.cpp │ ├── end_main.cpp │ └── lowerBound_main.cpp ├── SET └── mains │ ├── valueComp_main.cpp_new.cpp │ ├── .empty_main.cpp │ ├── begin_main.cpp │ ├── end_main.cpp │ ├── maxSize_main.cpp │ ├── rbegin_main.cpp │ ├── rend_main.cpp │ ├── empty_main.cpp │ ├── size_main.cpp │ ├── count_main.cpp │ ├── equalRange_main.cpp │ ├── valueComp_main.cpp │ ├── keyComp_main.cpp │ ├── find_main.cpp │ ├── operator=_main.cpp │ ├── swap_main.cpp │ ├── clear_main.cpp │ ├── nonMemberSwap_main.cpp │ ├── lowerBound_main.cpp │ ├── upperBound_main.cpp │ ├── relationalOperators_main.cpp │ └── erase_main.cpp ├── VECTOR └── mains │ ├── swap_main.cpp_new.cpp │ ├── nonMemberSwap_main.cpp │ ├── relationalOperators_main.cpp │ ├── .empty_main.cpp │ ├── operator=_main.cpp │ ├── begin_main.cpp │ ├── end_main.cpp │ ├── front_main.cpp │ ├── empty_main.cpp │ ├── pushBack_main.cpp │ ├── at_main.cpp │ ├── back_main.cpp │ ├── popBack_main.cpp │ ├── .flip_main.cpp │ ├── maxSize_main.cpp │ ├── size_main.cpp │ ├── rbegin_main.cpp │ ├── resize_main.cpp │ ├── rend_main.cpp │ └── capacity_main.cpp ├── .gitignore ├── README.MD ├── STACK └── mains │ ├── top_main.cpp │ ├── .empty_main.cpp │ ├── empty_main.cpp │ ├── pop_main.cpp │ ├── push_main.cpp │ ├── size_main.cpp │ └── relationalOperators_main.cpp ├── test_utils.hpp ├── DEQUE └── mains │ ├── reverseIterator_main.cpp │ ├── maxSize_main.cpp │ ├── front_main.cpp │ ├── .empty_main.cpp │ ├── empty_main.cpp │ ├── begin_main.cpp │ ├── first_main.cpp │ ├── end_main.cpp │ ├── pushBack_main.cpp │ ├── back_main.cpp │ ├── pushFront_main.cpp │ ├── operator=_main.cpp │ ├── popBack_main.cpp │ ├── size_main.cpp │ ├── popFront_main.cpp │ ├── rbegin_main.cpp │ ├── rend_main.cpp │ ├── resize_main.cpp │ └── erase_main.cpp ├── MULTISET └── mains │ └── .empty_main.cpp ├── MULTIMAP └── mains │ └── .empty_main.cpp └── Run_tests.sh /QUEUE/mains/size_main.cpp_new.cpp: -------------------------------------------------------------------------------- 1 | -------------------------------------------------------------------------------- /LIST/mains/unique_main.cpp_new.cpp: -------------------------------------------------------------------------------- 1 | -------------------------------------------------------------------------------- /MAP/mains/valueComp_main.cpp_new.cpp: -------------------------------------------------------------------------------- 1 | -------------------------------------------------------------------------------- /SET/mains/valueComp_main.cpp_new.cpp: -------------------------------------------------------------------------------- 1 | -------------------------------------------------------------------------------- /VECTOR/mains/swap_main.cpp_new.cpp: -------------------------------------------------------------------------------- 1 | -------------------------------------------------------------------------------- /.gitignore: -------------------------------------------------------------------------------- 1 | .swp 2 | *.swp 3 | **/diff/ 4 | **/leak/ 5 | **/logs/ 6 | **/out/ 7 | **/stderror/ 8 | **/bin/ 9 | .include_path 10 | .path -------------------------------------------------------------------------------- /README.MD: -------------------------------------------------------------------------------- 1 | If you want to be a good developer, please make your own tests. You should only use testers when you're correcting someone or just before submitting your work to see what tests you haven't thought of doing. If you finish a project without testing it yourself, you've only done a quarter of it. 2 | 3 | - `git clone` wherever you prefer and `cd` to the folder 4 | - `./Run_test.sh` will ask for the path to your project the first time you run it, you can change the paths in `.path` and `.include_path` if you need to change 5 | - You can run `./Run_test.sh` with one or more arguments : 6 | - `clean` 7 | - `map` `vector` `list` ... (if you want to test specific containers) 8 | - Each container name folder will store your errors (`diff`, `stderror`, `leaks`...) 9 | - There is a main template named `.empty_main.cpp` in `container_name/mains/` if you want to add your own tests. 10 | - You must rename your file with the format `***_main.cpp` 11 | - Please make a pull request if you have interesting tests to add. 12 | 13 | This tester was forked from hbaudet, thanks to him and to oroberts, rofernan, lmartin, thgermai and bbrunet for their contribution. 14 | -------------------------------------------------------------------------------- /STACK/mains/top_main.cpp: -------------------------------------------------------------------------------- 1 | /* ************************************************************************** */ 2 | /* */ 3 | /* ::: :::::::: */ 4 | /* top_main.cpp :+: :+: :+: */ 5 | /* +:+ +:+ +:+ */ 6 | /* By: mchardin +#+ +:+ +#+ */ 7 | /* +#+#+#+#+#+ +#+ */ 8 | /* Created: 2020/12/02 13:07:06 by hbaudet #+# #+# */ 9 | /* Updated: 2021/09/29 19:33:20 by mchardin ### ########.fr */ 10 | /* */ 11 | /* ************************************************************************** */ 12 | 13 | #include "STACK_UC.HPP" 14 | #include 15 | #include "test_utils.hpp" 16 | #include "VECTOR_UC.HPP" 17 | #include 18 | 19 | #ifndef STD 20 | # define NAMESPACE ft 21 | #else 22 | # define NAMESPACE std 23 | #endif 24 | 25 | using namespace NAMESPACE; 26 | 27 | int main () 28 | { 29 | stack mystack; 30 | 31 | mystack.push(10); 32 | mystack.push(20); 33 | 34 | mystack.top() -= 5; 35 | 36 | cout << "mystack.top() is now " << mystack.top() << '\n'; 37 | 38 | return 0; 39 | } 40 | -------------------------------------------------------------------------------- /STACK/mains/.empty_main.cpp: -------------------------------------------------------------------------------- 1 | /* ************************************************************************** */ 2 | /* */ 3 | /* ::: :::::::: */ 4 | /* .empty_main.cpp :+: :+: :+: */ 5 | /* +:+ +:+ +:+ */ 6 | /* By: hbaudet +#+ +:+ +#+ */ 7 | /* +#+#+#+#+#+ +#+ */ 8 | /* Created: 2020/12/02 13:07:06 by hbaudet #+# #+# */ 9 | /* Updated: 2021/01/18 16:06:37 by hbaudet ### ########.fr */ 10 | /* */ 11 | /* ************************************************************************** */ 12 | 13 | #include "STACK_UC.HPP" 14 | #include 15 | #include "LIST_UC.HPP" 16 | #include "hbaudet_utils.hpp" 17 | #include 18 | 19 | #ifndef STD 20 | # define NAMESPACE ft 21 | #else 22 | # define NAMESPACE std 23 | #endif 24 | 25 | using namespace NAMESPACE; 26 | 27 | int main() 28 | { 29 | /* THIS IS A TEMPLATE MAIN 30 | ** WRITE ANY TEST YOU WANT TO PERFORM 31 | ** SAVE IT UNDER 'something_main.cpp' 32 | ** IT WILL BE RUN WITH FT::LIST AND STD::LIST 33 | ** BOTH OUTPUTS WILL BE COMPARED 34 | */ 35 | 36 | return (0); 37 | } 38 | -------------------------------------------------------------------------------- /test_utils.hpp: -------------------------------------------------------------------------------- 1 | /* ************************************************************************** */ 2 | /* */ 3 | /* ::: :::::::: */ 4 | /* hbaudet_utils.hpp :+: :+: :+: */ 5 | /* +:+ +:+ +:+ */ 6 | /* By: hbaudet +#+ +:+ +#+ */ 7 | /* +#+#+#+#+#+ +#+ */ 8 | /* Created: 2020/12/03 14:20:31 by hbaudet #+# #+# */ 9 | /* Updated: 2021/01/18 15:54:58 by hbaudet ### ########.fr */ 10 | /* */ 11 | /* ************************************************************************** */ 12 | 13 | #ifndef TEST_UTILS_HPP 14 | # define TEST_UTILS_HPP 15 | 16 | # include 17 | # include 18 | # include 19 | 20 | # ifdef DEBUG 21 | # define PRINT 1 22 | # else 23 | # define PRINT 0 24 | # endif 25 | 26 | 27 | namespace ft 28 | { 29 | static std::ostream& cout = std::cout; 30 | typedef std::string string; 31 | 32 | 33 | # ifndef TO_STRING 34 | # define TO_STRING 35 | string to_string(size_t n) 36 | { 37 | std::stringstream tmp; 38 | 39 | tmp << n; 40 | 41 | return tmp.str(); 42 | } 43 | # endif 44 | } 45 | 46 | #endif -------------------------------------------------------------------------------- /STACK/mains/empty_main.cpp: -------------------------------------------------------------------------------- 1 | /* ************************************************************************** */ 2 | /* */ 3 | /* ::: :::::::: */ 4 | /* empty_main.cpp :+: :+: :+: */ 5 | /* +:+ +:+ +:+ */ 6 | /* By: mchardin +#+ +:+ +#+ */ 7 | /* +#+#+#+#+#+ +#+ */ 8 | /* Created: 2020/12/02 13:07:06 by hbaudet #+# #+# */ 9 | /* Updated: 2021/09/29 19:31:44 by mchardin ### ########.fr */ 10 | /* */ 11 | /* ************************************************************************** */ 12 | 13 | #include "STACK_UC.HPP" 14 | #include 15 | #include "test_utils.hpp" 16 | #include "VECTOR_UC.HPP" 17 | #include 18 | 19 | #ifndef STD 20 | # define NAMESPACE ft 21 | #else 22 | # define NAMESPACE std 23 | #endif 24 | 25 | using namespace NAMESPACE; 26 | 27 | int main () 28 | { 29 | stack mystack; 30 | int sum (0); 31 | 32 | for (int i=1;i<=10;i++) mystack.push(i); 33 | 34 | while (!mystack.empty()) 35 | { 36 | sum += mystack.top(); 37 | mystack.pop(); 38 | } 39 | 40 | cout << "total: " << sum << '\n'; 41 | 42 | return 0; 43 | } 44 | -------------------------------------------------------------------------------- /STACK/mains/pop_main.cpp: -------------------------------------------------------------------------------- 1 | /* ************************************************************************** */ 2 | /* */ 3 | /* ::: :::::::: */ 4 | /* pop_main.cpp :+: :+: :+: */ 5 | /* +:+ +:+ +:+ */ 6 | /* By: mchardin +#+ +:+ +#+ */ 7 | /* +#+#+#+#+#+ +#+ */ 8 | /* Created: 2020/12/02 13:07:06 by hbaudet #+# #+# */ 9 | /* Updated: 2021/09/29 19:31:41 by mchardin ### ########.fr */ 10 | /* */ 11 | /* ************************************************************************** */ 12 | 13 | #include "STACK_UC.HPP" 14 | #include 15 | #include "test_utils.hpp" 16 | #include "VECTOR_UC.HPP" 17 | #include 18 | 19 | #ifndef STD 20 | # define NAMESPACE ft 21 | #else 22 | # define NAMESPACE std 23 | #endif 24 | 25 | using namespace NAMESPACE; 26 | 27 | int main () 28 | { 29 | stack mystack; 30 | 31 | for (int i=0; i<5; ++i) mystack.push(i); 32 | 33 | cout << "Popping out elements..."; 34 | while (!mystack.empty()) 35 | { 36 | cout << ' ' << mystack.top(); 37 | mystack.pop(); 38 | } 39 | cout << '\n'; 40 | 41 | return 0; 42 | } 43 | -------------------------------------------------------------------------------- /STACK/mains/push_main.cpp: -------------------------------------------------------------------------------- 1 | /* ************************************************************************** */ 2 | /* */ 3 | /* ::: :::::::: */ 4 | /* push_main.cpp :+: :+: :+: */ 5 | /* +:+ +:+ +:+ */ 6 | /* By: mchardin +#+ +:+ +#+ */ 7 | /* +#+#+#+#+#+ +#+ */ 8 | /* Created: 2020/12/02 13:07:06 by hbaudet #+# #+# */ 9 | /* Updated: 2021/09/29 19:32:05 by mchardin ### ########.fr */ 10 | /* */ 11 | /* ************************************************************************** */ 12 | 13 | #include "STACK_UC.HPP" 14 | #include 15 | #include "test_utils.hpp" 16 | #include "VECTOR_UC.HPP" 17 | #include 18 | 19 | #ifndef STD 20 | # define NAMESPACE ft 21 | #else 22 | # define NAMESPACE std 23 | #endif 24 | 25 | using namespace NAMESPACE; 26 | 27 | int main () 28 | { 29 | stack mystack; 30 | 31 | for (int i=0; i<5; ++i) mystack.push(i); 32 | 33 | cout << "Popping out elements..."; 34 | while (!mystack.empty()) 35 | { 36 | cout << ' ' << mystack.top(); 37 | mystack.pop(); 38 | } 39 | cout << '\n'; 40 | 41 | return 0; 42 | } 43 | -------------------------------------------------------------------------------- /STACK/mains/size_main.cpp: -------------------------------------------------------------------------------- 1 | /* ************************************************************************** */ 2 | /* */ 3 | /* ::: :::::::: */ 4 | /* size_main.cpp :+: :+: :+: */ 5 | /* +:+ +:+ +:+ */ 6 | /* By: mchardin +#+ +:+ +#+ */ 7 | /* +#+#+#+#+#+ +#+ */ 8 | /* Created: 2020/12/02 13:07:06 by hbaudet #+# #+# */ 9 | /* Updated: 2021/09/29 19:32:45 by mchardin ### ########.fr */ 10 | /* */ 11 | /* ************************************************************************** */ 12 | 13 | #include "STACK_UC.HPP" 14 | #include 15 | #include "test_utils.hpp" 16 | #include "VECTOR_UC.HPP" 17 | #include 18 | 19 | #ifndef STD 20 | # define NAMESPACE ft 21 | #else 22 | # define NAMESPACE std 23 | #endif 24 | 25 | using namespace NAMESPACE; 26 | 27 | int main () 28 | { 29 | stack myints; 30 | cout << "0. size: " << myints.size() << '\n'; 31 | 32 | for (int i=0; i<5; i++) myints.push(i); 33 | cout << "1. size: " << myints.size() << '\n'; 34 | 35 | myints.pop(); 36 | cout << "2. size: " << myints.size() << '\n'; 37 | 38 | return 0; 39 | } 40 | -------------------------------------------------------------------------------- /LIST/mains/reverseIterator_main.cpp: -------------------------------------------------------------------------------- 1 | /* ************************************************************************** */ 2 | /* */ 3 | /* ::: :::::::: */ 4 | /* reverseIterator_main.cpp :+: :+: :+: */ 5 | /* +:+ +:+ +:+ */ 6 | /* By: hbaudet +#+ +:+ +#+ */ 7 | /* +#+#+#+#+#+ +#+ */ 8 | /* Created: 2020/12/02 13:07:06 by hbaudet #+# #+# */ 9 | /* Updated: 2021/01/18 16:03:53 by hbaudet ### ########.fr */ 10 | /* */ 11 | /* ************************************************************************** */ 12 | 13 | #include "test_utils.hpp" 14 | #include "LIST_UC.HPP" 15 | #include 16 | 17 | #ifndef STD 18 | # define NAMESPACE ft 19 | #else 20 | # define NAMESPACE std 21 | #endif 22 | 23 | using namespace NAMESPACE; 24 | 25 | int main() 26 | { 27 | list lst; 28 | 29 | for (int i = 0; i < 7; i++) 30 | lst.push_back(i * 3.75f); 31 | 32 | list::reverse_iterator rit(lst.begin()); 33 | list::reverse_iterator rit2(lst.end()); 34 | 35 | rit--; 36 | rit2--; 37 | while (rit != rit2) 38 | { 39 | std::cout << *rit << ' ' << '\n'; 40 | --rit; 41 | } 42 | 43 | 44 | 45 | return (0); 46 | } 47 | -------------------------------------------------------------------------------- /DEQUE/mains/reverseIterator_main.cpp: -------------------------------------------------------------------------------- 1 | /* ************************************************************************** */ 2 | /* */ 3 | /* ::: :::::::: */ 4 | /* reverseIterator_main.cpp :+: :+: :+: */ 5 | /* +:+ +:+ +:+ */ 6 | /* By: hbaudet +#+ +:+ +#+ */ 7 | /* +#+#+#+#+#+ +#+ */ 8 | /* Created: 2020/12/02 13:07:06 by hbaudet #+# #+# */ 9 | /* Updated: 2021/01/18 16:01:20 by hbaudet ### ########.fr */ 10 | /* */ 11 | /* ************************************************************************** */ 12 | 13 | #include "test_utils.hpp" 14 | #include "DEQUE_UC.HPP" 15 | #include 16 | 17 | #ifndef STD 18 | # define NAMESPACE ft 19 | #else 20 | # define NAMESPACE std 21 | #endif 22 | 23 | using namespace NAMESPACE; 24 | 25 | int main() 26 | { 27 | deque lst; 28 | 29 | for (int i = 0; i < 7; i++) 30 | lst.push_back(i * 3.75f); 31 | 32 | deque::reverse_iterator rit(lst.begin()); 33 | deque::reverse_iterator rit2(lst.end()); 34 | 35 | rit--; 36 | rit2--; 37 | while (rit != rit2) 38 | { 39 | std::cout << *rit << ' ' << '\n'; 40 | --rit; 41 | } 42 | 43 | 44 | 45 | return (0); 46 | } 47 | -------------------------------------------------------------------------------- /MAP/mains/size_main.cpp: -------------------------------------------------------------------------------- 1 | /* ************************************************************************** */ 2 | /* */ 3 | /* ::: :::::::: */ 4 | /* size_main.cpp :+: :+: :+: */ 5 | /* +:+ +:+ +:+ */ 6 | /* By: hbaudet +#+ +:+ +#+ */ 7 | /* +#+#+#+#+#+ +#+ */ 8 | /* Created: 2020/12/02 13:07:06 by hbaudet #+# #+# */ 9 | /* Updated: 2021/01/18 16:05:04 by hbaudet ### ########.fr */ 10 | /* */ 11 | /* ************************************************************************** */ 12 | 13 | #include "test_utils.hpp" 14 | #include "MAP_UC.HPP" 15 | #include 16 | 17 | #ifndef STD 18 | # define NAMESPACE ft 19 | #else 20 | # define NAMESPACE std 21 | #endif 22 | 23 | using namespace NAMESPACE; 24 | 25 | template 26 | void print(map& lst) 27 | { 28 | for (typename map::iterator it = lst.begin(); it != lst.end(); it++) 29 | cout << it->first << " => " << it->second << '\n'; 30 | } 31 | 32 | int main () 33 | { 34 | map mymap; 35 | mymap['a']=101; 36 | mymap['b']=202; 37 | mymap['c']=302; 38 | 39 | cout << "mymap.size() is " << mymap.size() << '\n'; 40 | 41 | return 0; 42 | } 43 | -------------------------------------------------------------------------------- /SET/mains/.empty_main.cpp: -------------------------------------------------------------------------------- 1 | /* ************************************************************************** */ 2 | /* */ 3 | /* ::: :::::::: */ 4 | /* .empty_main.cpp :+: :+: :+: */ 5 | /* +:+ +:+ +:+ */ 6 | /* By: hbaudet +#+ +:+ +#+ */ 7 | /* +#+#+#+#+#+ +#+ */ 8 | /* Created: 2020/12/02 13:07:06 by hbaudet #+# #+# */ 9 | /* Updated: 2021/01/19 09:30:14 by hbaudet ### ########.fr */ 10 | /* */ 11 | /* ************************************************************************** */ 12 | 13 | #include "hbaudet_utils.hpp" 14 | #include "SET_UC.HPP" 15 | #include 16 | 17 | #ifndef STD 18 | # define NAMESPACE ft 19 | #else 20 | # define NAMESPACE std 21 | #endif 22 | 23 | using namespace NAMESPACE; 24 | 25 | template 26 | void print(set& lst) 27 | { 28 | for (typename set::iterator it = lst.begin(); it != lst.end(); it++) 29 | cout << it->first << " => " << it->second << '\n'; 30 | } 31 | 32 | int main() 33 | { 34 | /* THIS IS A TEMPLATE MAIN 35 | ** WRITE ANY TEST YOU WANT TO PERFORM 36 | ** SAVE IT UNDER 'something_main.cpp' 37 | ** IT WILL BE RUN WITH FT::LIST AND STD::LIST 38 | ** BOTH OUTPUTS WILL BE COMPARED 39 | */ 40 | 41 | return (0); 42 | } 43 | -------------------------------------------------------------------------------- /MAP/mains/.empty_main.cpp: -------------------------------------------------------------------------------- 1 | /* ************************************************************************** */ 2 | /* */ 3 | /* ::: :::::::: */ 4 | /* .empty_main.cpp :+: :+: :+: */ 5 | /* +:+ +:+ +:+ */ 6 | /* By: hbaudet +#+ +:+ +#+ */ 7 | /* +#+#+#+#+#+ +#+ */ 8 | /* Created: 2020/12/02 13:07:06 by hbaudet #+# #+# */ 9 | /* Updated: 2021/01/18 16:04:59 by hbaudet ### ########.fr */ 10 | /* */ 11 | /* ************************************************************************** */ 12 | 13 | #include "hbaudet_utils.hpp" 14 | #include "MAP_UC.HPP" 15 | #include 16 | 17 | #ifndef STD 18 | # define NAMESPACE ft 19 | #else 20 | # define NAMESPACE std 21 | #endif 22 | 23 | using namespace NAMESPACE; 24 | 25 | template 26 | void print(map& lst) 27 | { 28 | for (typename map::iterator it = lst.begin(); it != lst.end(); it++) 29 | cout << it->first << " => " << it->second << '\n'; 30 | } 31 | 32 | int main() 33 | { 34 | /* THIS IS A TEMPLATE MAIN 35 | ** WRITE ANY TEST YOU WANT TO PERFORM 36 | ** SAVE IT UNDER 'something_main.cpp' 37 | ** IT WILL BE RUN WITH FT::LIST AND STD::LIST 38 | ** BOTH OUTPUTS WILL BE COMPARED 39 | */ 40 | 41 | return (0); 42 | } 43 | -------------------------------------------------------------------------------- /SET/mains/begin_main.cpp: -------------------------------------------------------------------------------- 1 | /* ************************************************************************** */ 2 | /* */ 3 | /* ::: :::::::: */ 4 | /* begin_main.cpp :+: :+: :+: */ 5 | /* +:+ +:+ +:+ */ 6 | /* By: hbaudet +#+ +:+ +#+ */ 7 | /* +#+#+#+#+#+ +#+ */ 8 | /* Created: 2020/12/02 13:07:06 by hbaudet #+# #+# */ 9 | /* Updated: 2021/01/19 09:53:34 by hbaudet ### ########.fr */ 10 | /* */ 11 | /* ************************************************************************** */ 12 | 13 | #include "test_utils.hpp" 14 | #include "SET_UC.HPP" 15 | #include 16 | 17 | #ifndef STD 18 | # define NAMESPACE ft 19 | #else 20 | # define NAMESPACE std 21 | #endif 22 | 23 | using namespace NAMESPACE; 24 | 25 | template 26 | void print(set& lst) 27 | { 28 | for (typename set::iterator it = lst.begin(); it != lst.end(); it++) 29 | cout << it->first << " => " << it->second << '\n'; 30 | } 31 | 32 | int main () 33 | { 34 | int myints[] = {75,23,65,42,13}; 35 | set myset (myints,myints+5); 36 | 37 | cout << "myset contains:"; 38 | for (set::iterator it=myset.begin(); it!=myset.end(); ++it) 39 | cout << ' ' << *it; 40 | 41 | cout << '\n'; 42 | 43 | return 0; 44 | } 45 | -------------------------------------------------------------------------------- /SET/mains/end_main.cpp: -------------------------------------------------------------------------------- 1 | /* ************************************************************************** */ 2 | /* */ 3 | /* ::: :::::::: */ 4 | /* end_main.cpp :+: :+: :+: */ 5 | /* +:+ +:+ +:+ */ 6 | /* By: hbaudet +#+ +:+ +#+ */ 7 | /* +#+#+#+#+#+ +#+ */ 8 | /* Created: 2020/12/02 13:07:06 by hbaudet #+# #+# */ 9 | /* Updated: 2021/01/19 10:56:59 by hbaudet ### ########.fr */ 10 | /* */ 11 | /* ************************************************************************** */ 12 | 13 | #include "test_utils.hpp" 14 | #include "SET_UC.HPP" 15 | #include 16 | 17 | #ifndef STD 18 | # define NAMESPACE ft 19 | #else 20 | # define NAMESPACE std 21 | #endif 22 | 23 | using namespace NAMESPACE; 24 | 25 | template 26 | void print(set& lst) 27 | { 28 | for (typename set::iterator it = lst.begin(); it != lst.end(); it++) 29 | cout << it->first << " => " << it->second << '\n'; 30 | } 31 | 32 | int main () 33 | { 34 | int myints[] = {75,23,65,42,13}; 35 | set myset (myints,myints+5); 36 | 37 | cout << "myset contains:"; 38 | for (set::iterator it=myset.begin(); it!=myset.end(); ++it) 39 | cout << ' ' << *it; 40 | 41 | cout << '\n'; 42 | 43 | return 0; 44 | } 45 | -------------------------------------------------------------------------------- /MULTISET/mains/.empty_main.cpp: -------------------------------------------------------------------------------- 1 | /* ************************************************************************** */ 2 | /* */ 3 | /* ::: :::::::: */ 4 | /* .empty_main.cpp :+: :+: :+: */ 5 | /* +:+ +:+ +:+ */ 6 | /* By: hbaudet +#+ +:+ +#+ */ 7 | /* +#+#+#+#+#+ +#+ */ 8 | /* Created: 2020/12/02 13:07:06 by hbaudet #+# #+# */ 9 | /* Updated: 2021/01/19 09:29:14 by hbaudet ### ########.fr */ 10 | /* */ 11 | /* ************************************************************************** */ 12 | 13 | #include "hbaudet_utils.hpp" 14 | #include "MULSTISET_UC.HPP" 15 | #include 16 | 17 | #ifndef STD 18 | # define NAMESPACE ft 19 | #else 20 | # define NAMESPACE std 21 | #endif 22 | 23 | using namespace NAMESPACE; 24 | 25 | template 26 | void print(multiset& lst) 27 | { 28 | for (typename multiset::iterator it = lst.begin(); it != lst.end(); it++) 29 | cout << it->first << " => " << it->second << '\n'; 30 | } 31 | 32 | int main() 33 | { 34 | /* THIS IS A TEMPLATE MAIN 35 | ** WRITE ANY TEST YOU WANT TO PERFORM 36 | ** SAVE IT UNDER 'something_main.cpp' 37 | ** IT WILL BE RUN WITH FT::LIST AND STD::LIST 38 | ** BOTH OUTPUTS WILL BE COMPARED 39 | */ 40 | 41 | return (0); 42 | } 43 | -------------------------------------------------------------------------------- /SET/mains/maxSize_main.cpp: -------------------------------------------------------------------------------- 1 | /* ************************************************************************** */ 2 | /* */ 3 | /* ::: :::::::: */ 4 | /* maxSize_main.cpp :+: :+: :+: */ 5 | /* +:+ +:+ +:+ */ 6 | /* By: hbaudet +#+ +:+ +#+ */ 7 | /* +#+#+#+#+#+ +#+ */ 8 | /* Created: 2020/12/02 13:07:06 by hbaudet #+# #+# */ 9 | /* Updated: 2021/01/20 10:23:36 by hbaudet ### ########.fr */ 10 | /* */ 11 | /* ************************************************************************** */ 12 | 13 | #include "test_utils.hpp" 14 | #include "SET_UC.HPP" 15 | #include 16 | 17 | #ifndef STD 18 | # define NAMESPACE ft 19 | #else 20 | # define NAMESPACE std 21 | #endif 22 | 23 | using namespace NAMESPACE; 24 | 25 | template 26 | void print(set& lst) 27 | { 28 | for (typename set::iterator it = lst.begin(); it != lst.end(); it++) 29 | cout << it->first << " => " << it->second << '\n'; 30 | } 31 | 32 | int main () 33 | { 34 | int i; 35 | set myset; 36 | 37 | if (myset.max_size()>1000) 38 | { 39 | for (i=0; i<1000; i++) myset.insert(i); 40 | cout << "The set contains 1000 elements.\n"; 41 | } 42 | else cout << "The set could not hold 1000 elements.\n"; 43 | 44 | return 0; 45 | } 46 | -------------------------------------------------------------------------------- /MULTIMAP/mains/.empty_main.cpp: -------------------------------------------------------------------------------- 1 | /* ************************************************************************** */ 2 | /* */ 3 | /* ::: :::::::: */ 4 | /* .empty_main.cpp :+: :+: :+: */ 5 | /* +:+ +:+ +:+ */ 6 | /* By: hbaudet +#+ +:+ +#+ */ 7 | /* +#+#+#+#+#+ +#+ */ 8 | /* Created: 2020/12/02 13:07:06 by hbaudet #+# #+# */ 9 | /* Updated: 2021/01/19 09:25:56 by hbaudet ### ########.fr */ 10 | /* */ 11 | /* ************************************************************************** */ 12 | 13 | #include "hbaudet_utils.hpp" 14 | #include "MULTIMAP_UC.HPP" 15 | #include 16 | 17 | #ifndef STD 18 | # define NAMESPACE ft 19 | #else 20 | # define NAMESPACE std 21 | #endif 22 | 23 | using namespace NAMESPACE; 24 | 25 | template 26 | void print(multimap& lst) 27 | { 28 | for (typename multimap::iterator it = lst.begin(); it != lst.end(); it++) 29 | cout << it->first << " => " << it->second << '\n'; 30 | } 31 | 32 | int main() 33 | { 34 | /* THIS IS A TEMPLATE MAIN 35 | ** WRITE ANY TEST YOU WANT TO PERFORM 36 | ** SAVE IT UNDER 'something_main.cpp' 37 | ** IT WILL BE RUN WITH FT::LIST AND STD::LIST 38 | ** BOTH OUTPUTS WILL BE COMPARED 39 | */ 40 | 41 | return (0); 42 | } 43 | -------------------------------------------------------------------------------- /MAP/mains/maxSize_main.cpp: -------------------------------------------------------------------------------- 1 | /* ************************************************************************** */ 2 | /* */ 3 | /* ::: :::::::: */ 4 | /* maxSize_main.cpp :+: :+: :+: */ 5 | /* +:+ +:+ +:+ */ 6 | /* By: hbaudet +#+ +:+ +#+ */ 7 | /* +#+#+#+#+#+ +#+ */ 8 | /* Created: 2020/12/02 13:07:06 by hbaudet #+# #+# */ 9 | /* Updated: 2021/01/18 16:05:15 by hbaudet ### ########.fr */ 10 | /* */ 11 | /* ************************************************************************** */ 12 | 13 | #include "test_utils.hpp" 14 | #include "MAP_UC.HPP" 15 | #include 16 | 17 | #ifndef STD 18 | # define NAMESPACE ft 19 | #else 20 | # define NAMESPACE std 21 | #endif 22 | 23 | using namespace NAMESPACE; 24 | 25 | template 26 | void print(map& lst) 27 | { 28 | for (typename map::iterator it = lst.begin(); it != lst.end(); it++) 29 | cout << it->first << " => " << it->second << '\n'; 30 | } 31 | 32 | int main () 33 | { 34 | int i; 35 | map mymap; 36 | 37 | if (mymap.max_size()>1000) 38 | { 39 | for (i=0; i<1000; i++) mymap[i]=0; 40 | cout << "The map contains 1000 elements.\n"; 41 | } 42 | else cout << "The map could not hold 1000 elements.\n"; 43 | 44 | return 0; 45 | } 46 | -------------------------------------------------------------------------------- /SET/mains/rbegin_main.cpp: -------------------------------------------------------------------------------- 1 | /* ************************************************************************** */ 2 | /* */ 3 | /* ::: :::::::: */ 4 | /* rbegin_main.cpp :+: :+: :+: */ 5 | /* +:+ +:+ +:+ */ 6 | /* By: hbaudet +#+ +:+ +#+ */ 7 | /* +#+#+#+#+#+ +#+ */ 8 | /* Created: 2020/12/02 13:07:06 by hbaudet #+# #+# */ 9 | /* Updated: 2021/01/20 10:24:44 by hbaudet ### ########.fr */ 10 | /* */ 11 | /* ************************************************************************** */ 12 | 13 | #include "test_utils.hpp" 14 | #include "SET_UC.HPP" 15 | #include 16 | 17 | #ifndef STD 18 | # define NAMESPACE ft 19 | #else 20 | # define NAMESPACE std 21 | #endif 22 | 23 | using namespace NAMESPACE; 24 | 25 | template 26 | void print(set& lst) 27 | { 28 | for (typename set::iterator it = lst.begin(); it != lst.end(); it++) 29 | cout << it->first << " => " << it->second << '\n'; 30 | } 31 | 32 | int main () 33 | { 34 | int myints[] = {21,64,17,78,49}; 35 | set myset (myints,myints+5); 36 | 37 | set::reverse_iterator rit; 38 | 39 | cout << "myset contains:"; 40 | for (rit=myset.rbegin(); rit != myset.rend(); ++rit) 41 | cout << ' ' << *rit; 42 | 43 | cout << '\n'; 44 | 45 | return 0; 46 | } 47 | -------------------------------------------------------------------------------- /SET/mains/rend_main.cpp: -------------------------------------------------------------------------------- 1 | /* ************************************************************************** */ 2 | /* */ 3 | /* ::: :::::::: */ 4 | /* rend_main.cpp :+: :+: :+: */ 5 | /* +:+ +:+ +:+ */ 6 | /* By: hbaudet +#+ +:+ +#+ */ 7 | /* +#+#+#+#+#+ +#+ */ 8 | /* Created: 2020/12/02 13:07:06 by hbaudet #+# #+# */ 9 | /* Updated: 2021/01/20 10:25:05 by hbaudet ### ########.fr */ 10 | /* */ 11 | /* ************************************************************************** */ 12 | 13 | #include "test_utils.hpp" 14 | #include "SET_UC.HPP" 15 | #include 16 | 17 | #ifndef STD 18 | # define NAMESPACE ft 19 | #else 20 | # define NAMESPACE std 21 | #endif 22 | 23 | using namespace NAMESPACE; 24 | 25 | template 26 | void print(set& lst) 27 | { 28 | for (typename set::iterator it = lst.begin(); it != lst.end(); it++) 29 | cout << it->first << " => " << it->second << '\n'; 30 | } 31 | 32 | int main () 33 | { 34 | int myints[] = {21,64,17,78,49}; 35 | set myset (myints,myints+5); 36 | 37 | set::reverse_iterator rit; 38 | 39 | cout << "myset contains:"; 40 | for (rit=myset.rbegin(); rit != myset.rend(); ++rit) 41 | cout << ' ' << *rit; 42 | 43 | cout << '\n'; 44 | 45 | return 0; 46 | } 47 | -------------------------------------------------------------------------------- /LIST/mains/swap_main.cpp: -------------------------------------------------------------------------------- 1 | /* ************************************************************************** */ 2 | /* */ 3 | /* ::: :::::::: */ 4 | /* swap_main.cpp :+: :+: :+: */ 5 | /* +:+ +:+ +:+ */ 6 | /* By: hbaudet +#+ +:+ +#+ */ 7 | /* +#+#+#+#+#+ +#+ */ 8 | /* Created: 2020/12/02 13:07:06 by hbaudet #+# #+# */ 9 | /* Updated: 2021/01/18 16:03:39 by hbaudet ### ########.fr */ 10 | /* */ 11 | /* ************************************************************************** */ 12 | 13 | #include "test_utils.hpp" 14 | #include "LIST_UC.HPP" 15 | #include 16 | 17 | #ifndef STD 18 | # define NAMESPACE ft 19 | #else 20 | # define NAMESPACE std 21 | #endif 22 | 23 | using namespace NAMESPACE; 24 | 25 | int main () 26 | { 27 | list first (3,100); // three ints with a value of 100 28 | list second (5,200); // five ints with a value of 200 29 | 30 | first.swap(second); 31 | 32 | cout << "first contains:"; 33 | for (list::iterator it=first.begin(); it!=first.end(); it++) 34 | cout << ' ' << *it; 35 | cout << '\n'; 36 | 37 | cout << "second contains:"; 38 | for (list::iterator it=second.begin(); it!=second.end(); it++) 39 | cout << ' ' << *it; 40 | cout << '\n'; 41 | 42 | return 0; 43 | } 44 | -------------------------------------------------------------------------------- /MAP/mains/empty_main.cpp: -------------------------------------------------------------------------------- 1 | /* ************************************************************************** */ 2 | /* */ 3 | /* ::: :::::::: */ 4 | /* empty_main.cpp :+: :+: :+: */ 5 | /* +:+ +:+ +:+ */ 6 | /* By: hbaudet +#+ +:+ +#+ */ 7 | /* +#+#+#+#+#+ +#+ */ 8 | /* Created: 2020/12/02 13:07:06 by hbaudet #+# #+# */ 9 | /* Updated: 2021/01/18 16:05:26 by hbaudet ### ########.fr */ 10 | /* */ 11 | /* ************************************************************************** */ 12 | 13 | #include "test_utils.hpp" 14 | #include "MAP_UC.HPP" 15 | #include 16 | 17 | #ifndef STD 18 | # define NAMESPACE ft 19 | #else 20 | # define NAMESPACE std 21 | #endif 22 | 23 | using namespace NAMESPACE; 24 | 25 | template 26 | void print(map& lst) 27 | { 28 | for (typename map::iterator it = lst.begin(); it != lst.end(); it++) 29 | cout << it->first << " => " << it->second << '\n'; 30 | } 31 | 32 | int main () 33 | { 34 | map mymap; 35 | 36 | mymap['a']=10; 37 | mymap['b']=20; 38 | mymap['c']=30; 39 | 40 | while (!mymap.empty()) 41 | { 42 | cout << mymap.begin()->first << " => " << mymap.begin()->second << '\n'; 43 | mymap.erase(mymap.begin()); 44 | } 45 | 46 | return 0; 47 | } 48 | -------------------------------------------------------------------------------- /SET/mains/empty_main.cpp: -------------------------------------------------------------------------------- 1 | /* ************************************************************************** */ 2 | /* */ 3 | /* ::: :::::::: */ 4 | /* empty_main.cpp :+: :+: :+: */ 5 | /* +:+ +:+ +:+ */ 6 | /* By: hbaudet +#+ +:+ +#+ */ 7 | /* +#+#+#+#+#+ +#+ */ 8 | /* Created: 2020/12/02 13:07:06 by hbaudet #+# #+# */ 9 | /* Updated: 2021/01/19 09:58:25 by hbaudet ### ########.fr */ 10 | /* */ 11 | /* ************************************************************************** */ 12 | 13 | #include "test_utils.hpp" 14 | #include "SET_UC.HPP" 15 | #include 16 | 17 | #ifndef STD 18 | # define NAMESPACE ft 19 | #else 20 | # define NAMESPACE std 21 | #endif 22 | 23 | using namespace NAMESPACE; 24 | 25 | template 26 | void print(set& lst) 27 | { 28 | for (typename set::iterator it = lst.begin(); it != lst.end(); it++) 29 | cout << it->first << " => " << it->second << '\n'; 30 | } 31 | 32 | int main () 33 | { 34 | set myset; 35 | 36 | myset.insert(20); 37 | myset.insert(30); 38 | myset.insert(10); 39 | 40 | cout << "myset contains:"; 41 | while (!myset.empty()) 42 | { 43 | cout << ' ' << *myset.begin(); 44 | myset.erase(myset.begin()); 45 | } 46 | cout << '\n'; 47 | 48 | return 0; 49 | } 50 | -------------------------------------------------------------------------------- /VECTOR/mains/nonMemberSwap_main.cpp: -------------------------------------------------------------------------------- 1 | /* ************************************************************************** */ 2 | /* */ 3 | /* ::: :::::::: */ 4 | /* nonMemberSwap_main.cpp :+: :+: :+: */ 5 | /* +:+ +:+ +:+ */ 6 | /* By: hbaudet +#+ +:+ +#+ */ 7 | /* +#+#+#+#+#+ +#+ */ 8 | /* Created: 2020/12/02 13:07:06 by hbaudet #+# #+# */ 9 | /* Updated: 2021/01/18 16:07:18 by hbaudet ### ########.fr */ 10 | /* */ 11 | /* ************************************************************************** */ 12 | 13 | #include "test_utils.hpp" 14 | #include "VECTOR_UC.HPP" 15 | #include 16 | 17 | #ifndef STD 18 | # define NAMESPACE ft 19 | #else 20 | # define NAMESPACE std 21 | #endif 22 | 23 | using namespace NAMESPACE; 24 | 25 | int main() 26 | { 27 | unsigned int i; 28 | vector foo (3,100); // three ints with a value of 100 29 | vector bar (5,200); // five ints with a value of 200 30 | 31 | foo.swap(bar); 32 | 33 | cout << "foo contains:"; 34 | for (vector::iterator it = foo.begin(); it!=foo.end(); ++it) 35 | cout << ' ' << *it; 36 | cout << '\n'; 37 | 38 | cout << "bar contains:"; 39 | for (vector::iterator it = bar.begin(); it!=bar.end(); ++it) 40 | cout << ' ' << *it; 41 | cout << '\n'; 42 | 43 | return 0; 44 | } 45 | -------------------------------------------------------------------------------- /VECTOR/mains/relationalOperators_main.cpp: -------------------------------------------------------------------------------- 1 | /* ************************************************************************** */ 2 | /* */ 3 | /* ::: :::::::: */ 4 | /* relationalOperators_main.cpp :+: :+: :+: */ 5 | /* +:+ +:+ +:+ */ 6 | /* By: hbaudet +#+ +:+ +#+ */ 7 | /* +#+#+#+#+#+ +#+ */ 8 | /* Created: 2020/12/02 13:07:06 by hbaudet #+# #+# */ 9 | /* Updated: 2021/01/18 16:07:08 by hbaudet ### ########.fr */ 10 | /* */ 11 | /* ************************************************************************** */ 12 | 13 | #include "test_utils.hpp" 14 | #include "VECTOR_UC.HPP" 15 | #include 16 | 17 | #ifndef STD 18 | # define NAMESPACE ft 19 | #else 20 | # define NAMESPACE std 21 | #endif 22 | 23 | using namespace NAMESPACE; 24 | 25 | int main () 26 | { 27 | vector foo (3,100); // three ints with a value of 100 28 | vector bar (2,200); // two ints with a value of 200 29 | 30 | if (foo==bar) cout << "foo and bar are equal\n"; 31 | if (foo!=bar) cout << "foo and bar are not equal\n"; 32 | if (foo< bar) cout << "foo is less than bar\n"; 33 | if (foo> bar) cout << "foo is greater than bar\n"; 34 | if (foo<=bar) cout << "foo is less than or equal to bar\n"; 35 | if (foo>=bar) cout << "foo is greater than or equal to bar\n"; 36 | 37 | return 0; 38 | } 39 | -------------------------------------------------------------------------------- /MAP/mains/rend_main.cpp: -------------------------------------------------------------------------------- 1 | /* ************************************************************************** */ 2 | /* */ 3 | /* ::: :::::::: */ 4 | /* rend_main.cpp :+: :+: :+: */ 5 | /* +:+ +:+ +:+ */ 6 | /* By: hbaudet +#+ +:+ +#+ */ 7 | /* +#+#+#+#+#+ +#+ */ 8 | /* Created: 2020/12/02 13:07:06 by hbaudet #+# #+# */ 9 | /* Updated: 2021/01/18 16:05:05 by hbaudet ### ########.fr */ 10 | /* */ 11 | /* ************************************************************************** */ 12 | 13 | #include "test_utils.hpp" 14 | #include "MAP_UC.HPP" 15 | #include 16 | 17 | #ifndef STD 18 | # define NAMESPACE ft 19 | #else 20 | # define NAMESPACE std 21 | #endif 22 | 23 | using namespace NAMESPACE; 24 | 25 | template 26 | void print(map& lst) 27 | { 28 | for (typename map::iterator it = lst.begin(); it != lst.end(); it++) 29 | cout << it->first << " => " << it->second << '\n'; 30 | } 31 | 32 | int main () 33 | { 34 | map mymap; 35 | 36 | mymap['x'] = 100; 37 | mymap['y'] = 200; 38 | mymap['z'] = 300; 39 | 40 | // show content: 41 | map::reverse_iterator rit; 42 | for (rit=mymap.rbegin(); rit!=mymap.rend(); ++rit) 43 | cout << rit->first << " => " << rit->second << '\n'; 44 | 45 | return 0; 46 | } 47 | -------------------------------------------------------------------------------- /SET/mains/size_main.cpp: -------------------------------------------------------------------------------- 1 | /* ************************************************************************** */ 2 | /* */ 3 | /* ::: :::::::: */ 4 | /* size_main.cpp :+: :+: :+: */ 5 | /* +:+ +:+ +:+ */ 6 | /* By: hbaudet +#+ +:+ +#+ */ 7 | /* +#+#+#+#+#+ +#+ */ 8 | /* Created: 2020/12/02 13:07:06 by hbaudet #+# #+# */ 9 | /* Updated: 2021/01/20 10:25:45 by hbaudet ### ########.fr */ 10 | /* */ 11 | /* ************************************************************************** */ 12 | 13 | #include "test_utils.hpp" 14 | #include "SET_UC.HPP" 15 | #include 16 | 17 | #ifndef STD 18 | # define NAMESPACE ft 19 | #else 20 | # define NAMESPACE std 21 | #endif 22 | 23 | using namespace NAMESPACE; 24 | 25 | template 26 | void print(set& lst) 27 | { 28 | for (typename set::iterator it = lst.begin(); it != lst.end(); it++) 29 | cout << it->first << " => " << it->second << '\n'; 30 | } 31 | 32 | int main () 33 | { 34 | set myints; 35 | cout << "0. size: " << myints.size() << '\n'; 36 | 37 | for (int i=0; i<10; ++i) myints.insert(i); 38 | cout << "1. size: " << myints.size() << '\n'; 39 | 40 | myints.insert (100); 41 | cout << "2. size: " << myints.size() << '\n'; 42 | 43 | myints.erase(5); 44 | cout << "3. size: " << myints.size() << '\n'; 45 | 46 | return 0; 47 | } 48 | -------------------------------------------------------------------------------- /SET/mains/count_main.cpp: -------------------------------------------------------------------------------- 1 | /* ************************************************************************** */ 2 | /* */ 3 | /* ::: :::::::: */ 4 | /* count_main.cpp :+: :+: :+: */ 5 | /* +:+ +:+ +:+ */ 6 | /* By: hbaudet +#+ +:+ +#+ */ 7 | /* +#+#+#+#+#+ +#+ */ 8 | /* Created: 2020/12/02 13:07:06 by hbaudet #+# #+# */ 9 | /* Updated: 2021/01/19 09:57:54 by hbaudet ### ########.fr */ 10 | /* */ 11 | /* ************************************************************************** */ 12 | 13 | #include "test_utils.hpp" 14 | #include "SET_UC.HPP" 15 | #include 16 | 17 | #ifndef STD 18 | # define NAMESPACE ft 19 | #else 20 | # define NAMESPACE std 21 | #endif 22 | 23 | using namespace NAMESPACE; 24 | 25 | template 26 | void print(set& lst) 27 | { 28 | for (typename set::iterator it = lst.begin(); it != lst.end(); it++) 29 | cout << it->first << " => " << it->second << '\n'; 30 | } 31 | 32 | int main () 33 | { 34 | set myset; 35 | 36 | // set some initial values: 37 | for (int i=1; i<5; ++i) myset.insert(i*3); // set: 3 6 9 12 38 | 39 | for (int i=0; i<10; ++i) 40 | { 41 | cout << i; 42 | if (myset.count(i)!=0) 43 | cout << " is an element of myset.\n"; 44 | else 45 | cout << " is not an element of myset.\n"; 46 | } 47 | 48 | return 0; 49 | } 50 | -------------------------------------------------------------------------------- /SET/mains/equalRange_main.cpp: -------------------------------------------------------------------------------- 1 | /* ************************************************************************** */ 2 | /* */ 3 | /* ::: :::::::: */ 4 | /* equalRange_main.cpp :+: :+: :+: */ 5 | /* +:+ +:+ +:+ */ 6 | /* By: hbaudet +#+ +:+ +#+ */ 7 | /* +#+#+#+#+#+ +#+ */ 8 | /* Created: 2020/12/02 13:07:06 by hbaudet #+# #+# */ 9 | /* Updated: 2021/01/20 10:20:47 by hbaudet ### ########.fr */ 10 | /* */ 11 | /* ************************************************************************** */ 12 | 13 | #include "test_utils.hpp" 14 | #include "SET_UC.HPP" 15 | #include 16 | 17 | #ifndef STD 18 | # define NAMESPACE ft 19 | #else 20 | # define NAMESPACE std 21 | #endif 22 | 23 | using namespace NAMESPACE; 24 | 25 | template 26 | void print(set& lst) 27 | { 28 | for (typename set::iterator it = lst.begin(); it != lst.end(); it++) 29 | cout << it->first << " => " << it->second << '\n'; 30 | } 31 | 32 | int main () 33 | { 34 | set myset; 35 | 36 | for (int i=1; i<=5; i++) myset.insert(i*10); // myset: 10 20 30 40 50 37 | 38 | pair::const_iterator,set::const_iterator> ret; 39 | ret = myset.equal_range(30); 40 | 41 | cout << "the lower bound points to: " << *ret.first << '\n'; 42 | cout << "the upper bound points to: " << *ret.second << '\n'; 43 | 44 | return 0; 45 | } 46 | -------------------------------------------------------------------------------- /SET/mains/valueComp_main.cpp: -------------------------------------------------------------------------------- 1 | /* ************************************************************************** */ 2 | /* */ 3 | /* ::: :::::::: */ 4 | /* valueComp_main.cpp :+: :+: :+: */ 5 | /* +:+ +:+ +:+ */ 6 | /* By: hbaudet +#+ +:+ +#+ */ 7 | /* +#+#+#+#+#+ +#+ */ 8 | /* Created: 2020/12/02 13:07:06 by hbaudet #+# #+# */ 9 | /* Updated: 2021/01/20 10:26:54 by hbaudet ### ########.fr */ 10 | /* */ 11 | /* ************************************************************************** */ 12 | 13 | #include "test_utils.hpp" 14 | #include "SET_UC.HPP" 15 | #include 16 | 17 | #ifndef STD 18 | # define NAMESPACE ft 19 | #else 20 | # define NAMESPACE std 21 | #endif 22 | 23 | using namespace NAMESPACE; 24 | 25 | template 26 | void print(set& lst) 27 | { 28 | for (typename set::iterator it = lst.begin(); it != lst.end(); it++) 29 | cout << it->first << " => " << it->second << '\n'; 30 | } 31 | 32 | int main () 33 | { 34 | set myset; 35 | 36 | set::value_compare mycomp = myset.value_comp(); 37 | 38 | for (int i=0; i<=5; i++) myset.insert(i); 39 | 40 | cout << "myset contains:"; 41 | 42 | int highest=*myset.rbegin(); 43 | set::iterator it=myset.begin(); 44 | do { 45 | cout << ' ' << *it; 46 | } while ( mycomp(*(++it),highest) ); 47 | 48 | cout << '\n'; 49 | 50 | return 0; 51 | } 52 | -------------------------------------------------------------------------------- /MAP/mains/operator=_main.cpp: -------------------------------------------------------------------------------- 1 | /* ************************************************************************** */ 2 | /* */ 3 | /* ::: :::::::: */ 4 | /* operator=_main.cpp :+: :+: :+: */ 5 | /* +:+ +:+ +:+ */ 6 | /* By: hbaudet +#+ +:+ +#+ */ 7 | /* +#+#+#+#+#+ +#+ */ 8 | /* Created: 2020/12/02 13:07:06 by hbaudet #+# #+# */ 9 | /* Updated: 2021/01/18 16:05:11 by hbaudet ### ########.fr */ 10 | /* */ 11 | /* ************************************************************************** */ 12 | 13 | #include "test_utils.hpp" 14 | #include "MAP_UC.HPP" 15 | #include 16 | 17 | #ifndef STD 18 | # define NAMESPACE ft 19 | #else 20 | # define NAMESPACE std 21 | #endif 22 | 23 | using namespace NAMESPACE; 24 | 25 | template 26 | void print(map& lst) 27 | { 28 | for (typename map::iterator it = lst.begin(); it != lst.end(); it++) 29 | cout << it->first << " => " << it->second << '\n'; 30 | } 31 | 32 | int main () 33 | { 34 | map first; 35 | map second; 36 | 37 | first['x']=8; 38 | first['y']=16; 39 | first['z']=32; 40 | 41 | second=first; // second now contains 3 ints 42 | first=map(); // and first is now empty 43 | 44 | cout << "Size of first: " << first.size() << '\n'; 45 | cout << "Size of second: " << second.size() << '\n'; 46 | return 0; 47 | } 48 | -------------------------------------------------------------------------------- /SET/mains/keyComp_main.cpp: -------------------------------------------------------------------------------- 1 | /* ************************************************************************** */ 2 | /* */ 3 | /* ::: :::::::: */ 4 | /* keyComp_main.cpp :+: :+: :+: */ 5 | /* +:+ +:+ +:+ */ 6 | /* By: hbaudet +#+ +:+ +#+ */ 7 | /* +#+#+#+#+#+ +#+ */ 8 | /* Created: 2020/12/02 13:07:06 by hbaudet #+# #+# */ 9 | /* Updated: 2021/01/20 10:22:36 by hbaudet ### ########.fr */ 10 | /* */ 11 | /* ************************************************************************** */ 12 | 13 | #include "test_utils.hpp" 14 | #include "SET_UC.HPP" 15 | #include 16 | 17 | #ifndef STD 18 | # define NAMESPACE ft 19 | #else 20 | # define NAMESPACE std 21 | #endif 22 | 23 | using namespace NAMESPACE; 24 | 25 | template 26 | void print(set& lst) 27 | { 28 | for (typename set::iterator it = lst.begin(); it != lst.end(); it++) 29 | cout << it->first << " => " << it->second << '\n'; 30 | } 31 | 32 | int main () 33 | { 34 | set myset; 35 | int highest; 36 | 37 | set::key_compare mycomp = myset.key_comp(); 38 | 39 | for (int i=0; i<=5; i++) myset.insert(i); 40 | 41 | cout << "myset contains:"; 42 | 43 | highest=*myset.rbegin(); 44 | set::iterator it=myset.begin(); 45 | do { 46 | cout << ' ' << *it; 47 | } while ( mycomp(*(++it),highest) ); 48 | 49 | cout << '\n'; 50 | 51 | return 0; 52 | } 53 | -------------------------------------------------------------------------------- /STACK/mains/relationalOperators_main.cpp: -------------------------------------------------------------------------------- 1 | /* ************************************************************************** */ 2 | /* */ 3 | /* ::: :::::::: */ 4 | /* relationalOperators_main.cpp :+: :+: :+: */ 5 | /* +:+ +:+ +:+ */ 6 | /* By: mchardin +#+ +:+ +#+ */ 7 | /* +#+#+#+#+#+ +#+ */ 8 | /* Created: 2020/12/02 13:07:06 by hbaudet #+# #+# */ 9 | /* Updated: 2021/09/29 19:32:21 by mchardin ### ########.fr */ 10 | /* */ 11 | /* ************************************************************************** */ 12 | 13 | #include "STACK_UC.HPP" 14 | #include 15 | #include "test_utils.hpp" 16 | #include "VECTOR_UC.HPP" 17 | #include 18 | 19 | #ifndef STD 20 | # define NAMESPACE ft 21 | #else 22 | # define NAMESPACE std 23 | #endif 24 | 25 | using namespace NAMESPACE; 26 | 27 | int main () 28 | { 29 | stack a, b, c; 30 | a.push(10); 31 | a.push(20); 32 | a.push(30); 33 | 34 | b.push(10); 35 | b.push(20); 36 | b.push(30); 37 | 38 | c.push(30); 39 | c.push(20); 40 | c.push(10); 41 | 42 | if (a==b) cout << "a and b are equal\n"; 43 | if (b!=c) cout << "b and c are not equal\n"; 44 | if (bb) cout << "c is greater than b\n"; 46 | if (a<=b) cout << "a is less than or equal to b\n"; 47 | if (a>=b) cout << "a is greater than or equal to b\n"; 48 | 49 | return 0; 50 | } 51 | -------------------------------------------------------------------------------- /SET/mains/find_main.cpp: -------------------------------------------------------------------------------- 1 | /* ************************************************************************** */ 2 | /* */ 3 | /* ::: :::::::: */ 4 | /* find_main.cpp :+: :+: :+: */ 5 | /* +:+ +:+ +:+ */ 6 | /* By: hbaudet +#+ +:+ +#+ */ 7 | /* +#+#+#+#+#+ +#+ */ 8 | /* Created: 2020/12/02 13:07:06 by hbaudet #+# #+# */ 9 | /* Updated: 2021/01/20 10:21:40 by hbaudet ### ########.fr */ 10 | /* */ 11 | /* ************************************************************************** */ 12 | 13 | #include "test_utils.hpp" 14 | #include "SET_UC.HPP" 15 | #include 16 | 17 | #ifndef STD 18 | # define NAMESPACE ft 19 | #else 20 | # define NAMESPACE std 21 | #endif 22 | 23 | using namespace NAMESPACE; 24 | 25 | template 26 | void print(set& lst) 27 | { 28 | for (typename set::iterator it = lst.begin(); it != lst.end(); it++) 29 | cout << it->first << " => " << it->second << '\n'; 30 | } 31 | 32 | int main () 33 | { 34 | set myset; 35 | set::iterator it; 36 | 37 | // set some initial values: 38 | for (int i=1; i<=5; i++) myset.insert(i*10); // set: 10 20 30 40 50 39 | 40 | it=myset.find(20); 41 | myset.erase (it); 42 | myset.erase (myset.find(40)); 43 | 44 | cout << "myset contains:"; 45 | for (it=myset.begin(); it!=myset.end(); ++it) 46 | cout << ' ' << *it; 47 | cout << '\n'; 48 | 49 | return 0; 50 | } 51 | -------------------------------------------------------------------------------- /MAP/mains/valueComp_main.cpp: -------------------------------------------------------------------------------- 1 | /* ************************************************************************** */ 2 | /* */ 3 | /* ::: :::::::: */ 4 | /* valueComp_main.cpp :+: :+: :+: */ 5 | /* +:+ +:+ +:+ */ 6 | /* By: hbaudet +#+ +:+ +#+ */ 7 | /* +#+#+#+#+#+ +#+ */ 8 | /* Created: 2020/12/02 13:07:06 by hbaudet #+# #+# */ 9 | /* Updated: 2021/01/18 16:05:00 by hbaudet ### ########.fr */ 10 | /* */ 11 | /* ************************************************************************** */ 12 | 13 | #include "test_utils.hpp" 14 | #include "MAP_UC.HPP" 15 | #include 16 | 17 | #ifndef STD 18 | # define NAMESPACE ft 19 | #else 20 | # define NAMESPACE std 21 | #endif 22 | 23 | using namespace NAMESPACE; 24 | 25 | template 26 | void print(map& lst) 27 | { 28 | for (typename map::iterator it = lst.begin(); it != lst.end(); it++) 29 | cout << it->first << " => " << it->second << '\n'; 30 | } 31 | 32 | int main () 33 | { 34 | map mymap; 35 | 36 | mymap['x']=1001; 37 | mymap['y']=2002; 38 | mymap['z']=3003; 39 | 40 | cout << "mymap contains:\n"; 41 | 42 | pair highest = *mymap.rbegin(); // last element 43 | 44 | map::iterator it = mymap.begin(); 45 | do { 46 | cout << it->first << " => " << it->second << '\n'; 47 | } while ( mymap.value_comp()(*it++, highest) ); 48 | 49 | return 0; 50 | } 51 | -------------------------------------------------------------------------------- /SET/mains/operator=_main.cpp: -------------------------------------------------------------------------------- 1 | /* ************************************************************************** */ 2 | /* */ 3 | /* ::: :::::::: */ 4 | /* operator=_main.cpp :+: :+: :+: */ 5 | /* +:+ +:+ +:+ */ 6 | /* By: hbaudet +#+ +:+ +#+ */ 7 | /* +#+#+#+#+#+ +#+ */ 8 | /* Created: 2020/12/02 13:07:06 by hbaudet #+# #+# */ 9 | /* Updated: 2021/01/20 10:24:27 by hbaudet ### ########.fr */ 10 | /* */ 11 | /* ************************************************************************** */ 12 | 13 | #include "test_utils.hpp" 14 | #include "SET_UC.HPP" 15 | #include 16 | 17 | #ifndef STD 18 | # define NAMESPACE ft 19 | #else 20 | # define NAMESPACE std 21 | #endif 22 | 23 | using namespace NAMESPACE; 24 | 25 | template 26 | void print(set& lst) 27 | { 28 | for (typename set::iterator it = lst.begin(); it != lst.end(); it++) 29 | cout << it->first << " => " << it->second << '\n'; 30 | } 31 | 32 | int main () 33 | { 34 | int myints[]={ 12,82,37,64,15 }; 35 | set first (myints,myints+5); // set with 5 ints 36 | set second; // empty set 37 | 38 | second = first; // now second contains the 5 ints 39 | first = set(); // and first is empty 40 | 41 | cout << "Size of first: " << int (first.size()) << '\n'; 42 | cout << "Size of second: " << int (second.size()) << '\n'; 43 | return 0; 44 | } 45 | -------------------------------------------------------------------------------- /MAP/mains/operator[]_main.cpp: -------------------------------------------------------------------------------- 1 | /* ************************************************************************** */ 2 | /* */ 3 | /* ::: :::::::: */ 4 | /* operator[]_main.cpp :+: :+: :+: */ 5 | /* +:+ +:+ +:+ */ 6 | /* By: hbaudet +#+ +:+ +#+ */ 7 | /* +#+#+#+#+#+ +#+ */ 8 | /* Created: 2020/12/02 13:07:06 by hbaudet #+# #+# */ 9 | /* Updated: 2021/01/18 16:05:13 by hbaudet ### ########.fr */ 10 | /* */ 11 | /* ************************************************************************** */ 12 | 13 | #include "test_utils.hpp" 14 | #include "MAP_UC.HPP" 15 | #include 16 | 17 | #ifndef STD 18 | # define NAMESPACE ft 19 | #else 20 | # define NAMESPACE std 21 | #endif 22 | 23 | using namespace NAMESPACE; 24 | 25 | template 26 | void print(map& lst) 27 | { 28 | for (typename map::iterator it = lst.begin(); it != lst.end(); it++) 29 | cout << it->first << " => " << it->second << '\n'; 30 | } 31 | 32 | int main () 33 | { 34 | map mymap; 35 | 36 | mymap['a']="an element"; 37 | mymap['b']="another element"; 38 | mymap['c']=mymap['b']; 39 | 40 | cout << "mymap['a'] is " << mymap['a'] << '\n'; 41 | cout << "mymap['b'] is " << mymap['b'] << '\n'; 42 | cout << "mymap['c'] is " << mymap['c'] << '\n'; 43 | cout << "mymap['d'] is " << mymap['d'] << '\n'; 44 | 45 | cout << "mymap now contains " << mymap.size() << " elements.\n"; 46 | 47 | return 0; 48 | } 49 | -------------------------------------------------------------------------------- /MAP/mains/equalRange_main.cpp: -------------------------------------------------------------------------------- 1 | /* ************************************************************************** */ 2 | /* */ 3 | /* ::: :::::::: */ 4 | /* equalRange_main.cpp :+: :+: :+: */ 5 | /* +:+ +:+ +:+ */ 6 | /* By: hbaudet +#+ +:+ +#+ */ 7 | /* +#+#+#+#+#+ +#+ */ 8 | /* Created: 2020/12/02 13:07:06 by hbaudet #+# #+# */ 9 | /* Updated: 2021/01/19 10:01:55 by hbaudet ### ########.fr */ 10 | /* */ 11 | /* ************************************************************************** */ 12 | 13 | #include "test_utils.hpp" 14 | #include "MAP_UC.HPP" 15 | #include 16 | 17 | #ifndef STD 18 | # define NAMESPACE ft 19 | #else 20 | # define NAMESPACE std 21 | #endif 22 | 23 | using namespace NAMESPACE; 24 | 25 | template 26 | void print(map& lst) 27 | { 28 | for (typename map::iterator it = lst.begin(); it != lst.end(); it++) 29 | cout << it->first << " => " << it->second << '\n'; 30 | } 31 | 32 | int main () 33 | { 34 | map mymap; 35 | 36 | mymap['a']=10; 37 | mymap['b']=20; 38 | mymap['c']=30; 39 | 40 | pair::iterator,map::iterator> ret; 41 | ret = mymap.equal_range('b'); 42 | 43 | cout << "lower bound points to: "; 44 | cout << ret.first->first << " => " << ret.first->second << '\n'; 45 | 46 | cout << "upper bound points to: "; 47 | cout << ret.second->first << " => " << ret.second->second << '\n'; 48 | 49 | return 0; 50 | } 51 | -------------------------------------------------------------------------------- /MAP/mains/count_main.cpp: -------------------------------------------------------------------------------- 1 | /* ************************************************************************** */ 2 | /* */ 3 | /* ::: :::::::: */ 4 | /* count_main.cpp :+: :+: :+: */ 5 | /* +:+ +:+ +:+ */ 6 | /* By: hbaudet +#+ +:+ +#+ */ 7 | /* +#+#+#+#+#+ +#+ */ 8 | /* Created: 2020/12/02 13:07:06 by hbaudet #+# #+# */ 9 | /* Updated: 2021/01/18 16:05:27 by hbaudet ### ########.fr */ 10 | /* */ 11 | /* ************************************************************************** */ 12 | 13 | #include "test_utils.hpp" 14 | #include "MAP_UC.HPP" 15 | #include 16 | 17 | #ifndef STD 18 | # define NAMESPACE ft 19 | #else 20 | # define NAMESPACE std 21 | #endif 22 | 23 | using namespace NAMESPACE; 24 | 25 | template 26 | void print(map& lst) 27 | { 28 | for (typename map::iterator it = lst.begin(); it != lst.end(); it++) 29 | cout << it->first << " => " << it->second << '\n'; 30 | } 31 | 32 | int main () 33 | { 34 | map mymap; 35 | char c; 36 | 37 | mymap ['a']=101; 38 | cout << "assigned 'a'\n"; 39 | mymap ['c']=202; 40 | cout << "assiged 'c'\n"; 41 | mymap ['f']=303; 42 | cout << "assigned 'f'\n"; 43 | 44 | cout << "end of assignations\n"; 45 | for (c='a'; c<'h'; c++) 46 | { 47 | cout << c; 48 | if (mymap.count(c)>0) 49 | cout << " is an element of mymap.\n"; 50 | else 51 | cout << " is not an element of mymap.\n"; 52 | } 53 | 54 | return 0; 55 | } 56 | -------------------------------------------------------------------------------- /LIST/mains/assign_main.cpp: -------------------------------------------------------------------------------- 1 | /* ************************************************************************** */ 2 | /* */ 3 | /* ::: :::::::: */ 4 | /* assign_main.cpp :+: :+: :+: */ 5 | /* +:+ +:+ +:+ */ 6 | /* By: hbaudet +#+ +:+ +#+ */ 7 | /* +#+#+#+#+#+ +#+ */ 8 | /* Created: 2020/12/02 13:07:06 by hbaudet #+# #+# */ 9 | /* Updated: 2021/01/20 11:06:29 by hbaudet ### ########.fr */ 10 | /* */ 11 | /* ************************************************************************** */ 12 | 13 | #include "test_utils.hpp" 14 | #include "LIST_UC.HPP" 15 | #include 16 | 17 | #ifndef STD 18 | # define NAMESPACE ft 19 | #else 20 | # define NAMESPACE std 21 | #endif 22 | 23 | using namespace NAMESPACE; 24 | 25 | template 26 | void print(list& lst) 27 | { 28 | for (typename list::iterator it = lst.begin(); it != lst.end(); it++) 29 | cout << *it << ' '; 30 | cout << '\n'; 31 | } 32 | 33 | int main () 34 | { 35 | list first; 36 | list second; 37 | 38 | first.assign (7,100); // 7 ints with value 100 39 | print(first); 40 | 41 | second.assign (first.begin(), first.end()); // a copy of first 42 | print(second); 43 | 44 | int myints[]={1776,7,4}; 45 | first.assign (myints,myints+3); // assigning from array 46 | print(first); 47 | 48 | cout << "Size of first: " << int (first.size()) << '\n'; 49 | cout << "Size of second: " << int (second.size()) << '\n'; 50 | return 0; 51 | } 52 | -------------------------------------------------------------------------------- /LIST/mains/maxSize_main.cpp: -------------------------------------------------------------------------------- 1 | /* ************************************************************************** */ 2 | /* */ 3 | /* ::: :::::::: */ 4 | /* maxSize_main.cpp :+: :+: :+: */ 5 | /* +:+ +:+ +:+ */ 6 | /* By: hbaudet +#+ +:+ +#+ */ 7 | /* +#+#+#+#+#+ +#+ */ 8 | /* Created: 2020/12/02 13:07:06 by hbaudet #+# #+# */ 9 | /* Updated: 2021/01/18 16:04:20 by hbaudet ### ########.fr */ 10 | /* */ 11 | /* ************************************************************************** */ 12 | 13 | #include "test_utils.hpp" 14 | #include "LIST_UC.HPP" 15 | #include 16 | 17 | #ifndef STD 18 | # define NAMESPACE ft 19 | #else 20 | # define NAMESPACE std 21 | #endif 22 | 23 | using namespace NAMESPACE; 24 | 25 | template 26 | void print(list >& lst) 27 | { 28 | for (typename list >::iterator it = lst.begin(); it != lst.end(); it++) 29 | { 30 | for (typename list::iterator it2 = it->begin(); it2 != it->end(); it2++) 31 | cout << *it2 << ' '; 32 | cout << '\n'; 33 | } 34 | } 35 | 36 | template 37 | void print(list& lst) 38 | { 39 | for (typename list::iterator it = lst.begin(); it != lst.end(); it++) 40 | cout << *it << ' '; 41 | cout << '\n'; 42 | } 43 | 44 | int main () 45 | { 46 | list mylist; 47 | 48 | cout << "Enter number of elements: "; 49 | 50 | if (10000 +#+ +:+ +#+ */ 7 | /* +#+#+#+#+#+ +#+ */ 8 | /* Created: 2020/12/02 13:07:06 by hbaudet #+# #+# */ 9 | /* Updated: 2021/01/20 10:26:04 by hbaudet ### ########.fr */ 10 | /* */ 11 | /* ************************************************************************** */ 12 | 13 | #include "test_utils.hpp" 14 | #include "SET_UC.HPP" 15 | #include 16 | 17 | #ifndef STD 18 | # define NAMESPACE ft 19 | #else 20 | # define NAMESPACE std 21 | #endif 22 | 23 | using namespace NAMESPACE; 24 | 25 | template 26 | void print(set& lst) 27 | { 28 | for (typename set::iterator it = lst.begin(); it != lst.end(); it++) 29 | cout << it->first << " => " << it->second << '\n'; 30 | } 31 | 32 | int main () 33 | { 34 | int myints[]={12,75,10,32,20,25}; 35 | set first (myints,myints+3); // 10,12,75 36 | set second (myints+3,myints+6); // 20,25,32 37 | 38 | first.swap(second); 39 | 40 | cout << "first contains:"; 41 | for (set::iterator it=first.begin(); it!=first.end(); ++it) 42 | cout << ' ' << *it; 43 | cout << '\n'; 44 | 45 | cout << "second contains:"; 46 | for (set::iterator it=second.begin(); it!=second.end(); ++it) 47 | cout << ' ' << *it; 48 | cout << '\n'; 49 | 50 | return 0; 51 | } 52 | -------------------------------------------------------------------------------- /SET/mains/clear_main.cpp: -------------------------------------------------------------------------------- 1 | /* ************************************************************************** */ 2 | /* */ 3 | /* ::: :::::::: */ 4 | /* clear_main.cpp :+: :+: :+: */ 5 | /* +:+ +:+ +:+ */ 6 | /* By: hbaudet +#+ +:+ +#+ */ 7 | /* +#+#+#+#+#+ +#+ */ 8 | /* Created: 2020/12/02 13:07:06 by hbaudet #+# #+# */ 9 | /* Updated: 2021/01/19 09:57:30 by hbaudet ### ########.fr */ 10 | /* */ 11 | /* ************************************************************************** */ 12 | 13 | #include "test_utils.hpp" 14 | #include "SET_UC.HPP" 15 | #include 16 | 17 | #ifndef STD 18 | # define NAMESPACE ft 19 | #else 20 | # define NAMESPACE std 21 | #endif 22 | 23 | using namespace NAMESPACE; 24 | 25 | template 26 | void print(set& lst) 27 | { 28 | for (typename set::iterator it = lst.begin(); it != lst.end(); it++) 29 | cout << it->first << " => " << it->second << '\n'; 30 | } 31 | 32 | int main () 33 | { 34 | set myset; 35 | 36 | myset.insert (100); 37 | myset.insert (200); 38 | myset.insert (300); 39 | 40 | cout << "myset contains:"; 41 | for (set::iterator it=myset.begin(); it!=myset.end(); ++it) 42 | cout << ' ' << *it; 43 | cout << '\n'; 44 | 45 | myset.clear(); 46 | myset.insert (1101); 47 | myset.insert (2202); 48 | 49 | cout << "myset contains:"; 50 | for (set::iterator it=myset.begin(); it!=myset.end(); ++it) 51 | cout << ' ' << *it; 52 | cout << '\n'; 53 | 54 | return 0; 55 | } 56 | -------------------------------------------------------------------------------- /MAP/mains/find_main.cpp: -------------------------------------------------------------------------------- 1 | /* ************************************************************************** */ 2 | /* */ 3 | /* ::: :::::::: */ 4 | /* find_main.cpp :+: :+: :+: */ 5 | /* +:+ +:+ +:+ */ 6 | /* By: hbaudet +#+ +:+ +#+ */ 7 | /* +#+#+#+#+#+ +#+ */ 8 | /* Created: 2020/12/02 13:07:06 by hbaudet #+# #+# */ 9 | /* Updated: 2021/01/18 16:05:21 by hbaudet ### ########.fr */ 10 | /* */ 11 | /* ************************************************************************** */ 12 | 13 | #include "test_utils.hpp" 14 | #include "MAP_UC.HPP" 15 | #include 16 | 17 | #ifndef STD 18 | # define NAMESPACE ft 19 | #else 20 | # define NAMESPACE std 21 | #endif 22 | 23 | using namespace NAMESPACE; 24 | 25 | template 26 | void print(map& lst) 27 | { 28 | for (typename map::iterator it = lst.begin(); it != lst.end(); it++) 29 | cout << it->first << " => " << it->second << '\n'; 30 | } 31 | 32 | int main () 33 | { 34 | map mymap; 35 | map::iterator it; 36 | 37 | mymap['a']=50; 38 | mymap['b']=100; 39 | mymap['c']=150; 40 | mymap['d']=200; 41 | 42 | it = mymap.find('b'); 43 | if (it != mymap.end()) 44 | mymap.erase (it); 45 | 46 | // print content: 47 | cout << "elements in mymap:" << '\n'; 48 | cout << "a => " << mymap.find('a')->second << '\n'; 49 | cout << "c => " << mymap.find('c')->second << '\n'; 50 | cout << "d => " << mymap.find('d')->second << '\n'; 51 | 52 | return 0; 53 | } 54 | -------------------------------------------------------------------------------- /SET/mains/nonMemberSwap_main.cpp: -------------------------------------------------------------------------------- 1 | /* ************************************************************************** */ 2 | /* */ 3 | /* ::: :::::::: */ 4 | /* nonMemberSwap_main.cpp :+: :+: :+: */ 5 | /* +:+ +:+ +:+ */ 6 | /* By: hbaudet +#+ +:+ +#+ */ 7 | /* +#+#+#+#+#+ +#+ */ 8 | /* Created: 2020/12/02 13:07:06 by hbaudet #+# #+# */ 9 | /* Updated: 2021/01/20 10:27:36 by hbaudet ### ########.fr */ 10 | /* */ 11 | /* ************************************************************************** */ 12 | 13 | #include "test_utils.hpp" 14 | #include "SET_UC.HPP" 15 | #include 16 | 17 | #ifndef STD 18 | # define NAMESPACE ft 19 | #else 20 | # define NAMESPACE std 21 | #endif 22 | 23 | using namespace NAMESPACE; 24 | 25 | template 26 | void print(set& lst) 27 | { 28 | for (typename set::iterator it = lst.begin(); it != lst.end(); it++) 29 | cout << it->first << " => " << it->second << '\n'; 30 | } 31 | 32 | int main () 33 | { 34 | int myints[]={12,75,10,32,20,25}; 35 | set first (myints,myints+3); // 10,12,75 36 | set second (myints+3,myints+6); // 20,25,32 37 | 38 | swap(first,second); 39 | 40 | cout << "first contains:"; 41 | for (set::iterator it=first.begin(); it!=first.end(); ++it) 42 | cout << ' ' << *it; 43 | cout << '\n'; 44 | 45 | cout << "second contains:"; 46 | for (set::iterator it=second.begin(); it!=second.end(); ++it) 47 | cout << ' ' << *it; 48 | cout << '\n'; 49 | 50 | return 0; 51 | } 52 | -------------------------------------------------------------------------------- /DEQUE/mains/maxSize_main.cpp: -------------------------------------------------------------------------------- 1 | /* ************************************************************************** */ 2 | /* */ 3 | /* ::: :::::::: */ 4 | /* maxSize_main.cpp :+: :+: :+: */ 5 | /* +:+ +:+ +:+ */ 6 | /* By: hbaudet +#+ +:+ +#+ */ 7 | /* +#+#+#+#+#+ +#+ */ 8 | /* Created: 2020/12/02 13:07:06 by hbaudet #+# #+# */ 9 | /* Updated: 2021/01/18 16:01:49 by hbaudet ### ########.fr */ 10 | /* */ 11 | /* ************************************************************************** */ 12 | 13 | #include "test_utils.hpp" 14 | #include "DEQUE_UC.HPP" 15 | #include 16 | #include 17 | 18 | #ifndef STD 19 | # define NAMESPACE ft 20 | #else 21 | # define NAMESPACE std 22 | #endif 23 | 24 | using namespace NAMESPACE; 25 | 26 | template 27 | void print(deque >& lst) 28 | { 29 | for (typename deque >::iterator it = lst.begin(); it != lst.end(); it++) 30 | { 31 | for (typename deque::iterator it2 = it->begin(); it2 != it->end(); it2++) 32 | cout << *it2 << ' '; 33 | cout << '\n'; 34 | } 35 | } 36 | 37 | template 38 | void print(deque& lst) 39 | { 40 | for (typename deque::iterator it = lst.begin(); it != lst.end(); it++) 41 | cout << *it << ' '; 42 | cout << '\n'; 43 | } 44 | 45 | int main () 46 | { 47 | unsigned int i; 48 | deque mydeque; 49 | 50 | i = 15000; 51 | 52 | if (i +#+ +:+ +#+ */ 7 | /* +#+#+#+#+#+ +#+ */ 8 | /* Created: 2020/12/02 13:07:06 by hbaudet #+# #+# */ 9 | /* Updated: 2021/01/21 13:31:41 by hbaudet ### ########.fr */ 10 | /* */ 11 | /* ************************************************************************** */ 12 | 13 | #include "hbaudet_utils.hpp" 14 | #include "LIST_UC.HPP" 15 | #include 16 | 17 | #ifndef STD 18 | # define NAMESPACE ft 19 | #else 20 | # define NAMESPACE std 21 | #endif 22 | 23 | using namespace NAMESPACE; 24 | 25 | template 26 | void print(list >& lst) 27 | { 28 | for (typename list >::iterator it = lst.begin(); it != lst.end(); it++) 29 | { 30 | for (typename list::iterator it2 = it->begin(); it2 != it->end(); it2++) 31 | cout << *it2 << ' '; 32 | cout << '\n'; 33 | } 34 | } 35 | 36 | template 37 | void print(list& lst) 38 | { 39 | for (typename list::iterator it = lst.begin(); it != lst.end(); it++) 40 | cout << *it << ' '; 41 | cout << '\n'; 42 | } 43 | 44 | int main() 45 | { 46 | /* THIS IS A TEMPLATE MAIN 47 | ** WRITE ANY TEST YOU WANT TO PERFORM 48 | ** SAVE IT UNDER 'something_main.cpp' 49 | ** IT WILL BE RUN WITH FT::LIST AND STD::LIST 50 | ** BOTH OUTPUTS WILL BE COMPARED 51 | */ 52 | 53 | return (0); 54 | } 55 | -------------------------------------------------------------------------------- /MAP/mains/keyComp_main.cpp: -------------------------------------------------------------------------------- 1 | /* ************************************************************************** */ 2 | /* */ 3 | /* ::: :::::::: */ 4 | /* keyComp_main.cpp :+: :+: :+: */ 5 | /* +:+ +:+ +:+ */ 6 | /* By: hbaudet +#+ +:+ +#+ */ 7 | /* +#+#+#+#+#+ +#+ */ 8 | /* Created: 2020/12/02 13:07:06 by hbaudet #+# #+# */ 9 | /* Updated: 2021/01/18 16:05:18 by hbaudet ### ########.fr */ 10 | /* */ 11 | /* ************************************************************************** */ 12 | 13 | #include "test_utils.hpp" 14 | #include "MAP_UC.HPP" 15 | #include 16 | 17 | #ifndef STD 18 | # define NAMESPACE ft 19 | #else 20 | # define NAMESPACE std 21 | #endif 22 | 23 | using namespace NAMESPACE; 24 | 25 | template 26 | void print(map& lst) 27 | { 28 | for (typename map::iterator it = lst.begin(); it != lst.end(); it++) 29 | cout << it->first << " => " << it->second << '\n'; 30 | } 31 | 32 | int main () 33 | { 34 | map mymap; 35 | 36 | map::key_compare mycomp = mymap.key_comp(); 37 | 38 | mymap['a']=100; 39 | mymap['b']=200; 40 | mymap['c']=300; 41 | 42 | 43 | char highest = mymap.rbegin()->first; // key value of last element 44 | 45 | 46 | cout << "mymap contains:\n"; 47 | map::iterator it = mymap.begin(); 48 | do { 49 | cout << it->first << " => " << it->second << '\n'; 50 | } while ( mycomp((*it++).first, highest) ); 51 | 52 | cout << '\n'; 53 | 54 | return 0; 55 | } 56 | -------------------------------------------------------------------------------- /DEQUE/mains/front_main.cpp: -------------------------------------------------------------------------------- 1 | /* ************************************************************************** */ 2 | /* */ 3 | /* ::: :::::::: */ 4 | /* front_main.cpp :+: :+: :+: */ 5 | /* +:+ +:+ +:+ */ 6 | /* By: hbaudet +#+ +:+ +#+ */ 7 | /* +#+#+#+#+#+ +#+ */ 8 | /* Created: 2020/12/02 13:07:06 by hbaudet #+# #+# */ 9 | /* Updated: 2021/01/18 16:02:01 by hbaudet ### ########.fr */ 10 | /* */ 11 | /* ************************************************************************** */ 12 | 13 | #include "test_utils.hpp" 14 | #include "DEQUE_UC.HPP" 15 | #include 16 | 17 | #ifndef STD 18 | # define NAMESPACE ft 19 | #else 20 | # define NAMESPACE std 21 | #endif 22 | 23 | using namespace NAMESPACE; 24 | 25 | template 26 | void print(deque >& lst) 27 | { 28 | for (typename deque >::iterator it = lst.begin(); it != lst.end(); it++) 29 | { 30 | for (typename deque::iterator it2 = it->begin(); it2 != it->end(); it2++) 31 | cout << *it2 << ' '; 32 | cout << '\n'; 33 | } 34 | } 35 | 36 | template 37 | void print(deque& lst) 38 | { 39 | for (typename deque::iterator it = lst.begin(); it != lst.end(); it++) 40 | cout << *it << ' '; 41 | cout << '\n'; 42 | } 43 | 44 | int main () 45 | { 46 | deque mydeque; 47 | 48 | mydeque.push_front(77); 49 | mydeque.push_back(20); 50 | 51 | mydeque.front() -= mydeque.back(); 52 | 53 | cout << "mydeque.front() is now " << mydeque.front() << '\n'; 54 | 55 | return 0; 56 | } 57 | -------------------------------------------------------------------------------- /SET/mains/lowerBound_main.cpp: -------------------------------------------------------------------------------- 1 | /* ************************************************************************** */ 2 | /* */ 3 | /* ::: :::::::: */ 4 | /* lowerBound_main.cpp :+: :+: :+: */ 5 | /* +:+ +:+ +:+ */ 6 | /* By: hbaudet +#+ +:+ +#+ */ 7 | /* +#+#+#+#+#+ +#+ */ 8 | /* Created: 2020/12/02 13:07:06 by hbaudet #+# #+# */ 9 | /* Updated: 2021/01/20 10:22:58 by hbaudet ### ########.fr */ 10 | /* */ 11 | /* ************************************************************************** */ 12 | 13 | #include "test_utils.hpp" 14 | #include "SET_UC.HPP" 15 | #include 16 | 17 | #ifndef STD 18 | # define NAMESPACE ft 19 | #else 20 | # define NAMESPACE std 21 | #endif 22 | 23 | using namespace NAMESPACE; 24 | 25 | template 26 | void print(set& lst) 27 | { 28 | for (typename set::iterator it = lst.begin(); it != lst.end(); it++) 29 | cout << it->first << " => " << it->second << '\n'; 30 | } 31 | 32 | int main () 33 | { 34 | set myset; 35 | set::iterator itlow,itup; 36 | 37 | for (int i=1; i<10; i++) myset.insert(i*10); // 10 20 30 40 50 60 70 80 90 38 | 39 | itlow=myset.lower_bound (30); // ^ 40 | itup=myset.upper_bound (60); // ^ 41 | 42 | myset.erase(itlow,itup); // 10 20 70 80 90 43 | 44 | cout << "myset contains:"; 45 | for (set::iterator it=myset.begin(); it!=myset.end(); ++it) 46 | cout << ' ' << *it; 47 | cout << '\n'; 48 | 49 | return 0; 50 | } 51 | -------------------------------------------------------------------------------- /SET/mains/upperBound_main.cpp: -------------------------------------------------------------------------------- 1 | /* ************************************************************************** */ 2 | /* */ 3 | /* ::: :::::::: */ 4 | /* upperBound_main.cpp :+: :+: :+: */ 5 | /* +:+ +:+ +:+ */ 6 | /* By: hbaudet +#+ +:+ +#+ */ 7 | /* +#+#+#+#+#+ +#+ */ 8 | /* Created: 2020/12/02 13:07:06 by hbaudet #+# #+# */ 9 | /* Updated: 2021/01/20 10:26:29 by hbaudet ### ########.fr */ 10 | /* */ 11 | /* ************************************************************************** */ 12 | 13 | #include "test_utils.hpp" 14 | #include "SET_UC.HPP" 15 | #include 16 | 17 | #ifndef STD 18 | # define NAMESPACE ft 19 | #else 20 | # define NAMESPACE std 21 | #endif 22 | 23 | using namespace NAMESPACE; 24 | 25 | template 26 | void print(set& lst) 27 | { 28 | for (typename set::iterator it = lst.begin(); it != lst.end(); it++) 29 | cout << it->first << " => " << it->second << '\n'; 30 | } 31 | 32 | int main () 33 | { 34 | set myset; 35 | set::iterator itlow,itup; 36 | 37 | for (int i=1; i<10; i++) myset.insert(i*10); // 10 20 30 40 50 60 70 80 90 38 | 39 | itlow=myset.lower_bound (30); // ^ 40 | itup=myset.upper_bound (60); // ^ 41 | 42 | myset.erase(itlow,itup); // 10 20 70 80 90 43 | 44 | cout << "myset contains:"; 45 | for (set::iterator it=myset.begin(); it!=myset.end(); ++it) 46 | cout << ' ' << *it; 47 | cout << '\n'; 48 | 49 | return 0; 50 | } 51 | -------------------------------------------------------------------------------- /DEQUE/mains/.empty_main.cpp: -------------------------------------------------------------------------------- 1 | /* ************************************************************************** */ 2 | /* */ 3 | /* ::: :::::::: */ 4 | /* .empty_main.cpp :+: :+: :+: */ 5 | /* +:+ +:+ +:+ */ 6 | /* By: hbaudet +#+ +:+ +#+ */ 7 | /* +#+#+#+#+#+ +#+ */ 8 | /* Created: 2020/12/02 13:07:06 by hbaudet #+# #+# */ 9 | /* Updated: 2021/01/18 15:57:42 by hbaudet ### ########.fr */ 10 | /* */ 11 | /* ************************************************************************** */ 12 | 13 | #include "DEQUE_UC.HPP" 14 | #include "hbaudet_utils.hpp" 15 | #include 16 | 17 | #ifndef STD 18 | # define NAMESPACE ft 19 | #else 20 | # define NAMESPACE std 21 | #endif 22 | 23 | using namespace NAMESPACE; 24 | 25 | template 26 | void print(deque >& lst) 27 | { 28 | for (typename deque >::iterator it = lst.begin(); it != lst.end(); it++) 29 | { 30 | for (typename deque::iterator it2 = it->begin(); it2 != it->end(); it2++) 31 | cout << *it2 << ' '; 32 | cout << '\n'; 33 | } 34 | } 35 | 36 | template 37 | void print(deque& lst) 38 | { 39 | for (typename deque::iterator it = lst.begin(); it != lst.end(); it++) 40 | cout << *it << ' '; 41 | cout << '\n'; 42 | } 43 | 44 | int main() 45 | { 46 | /* THIS IS A TEMPLATE MAIN 47 | ** WRITE ANY TEST YOU WANT TO PERFORM 48 | ** SAVE IT UNDER 'something_main.cpp' 49 | ** IT WILL BE RUN WITH FT::LIST AND STD::LIST 50 | ** BOTH OUTPUTS WILL BE COMPARED 51 | */ 52 | 53 | return (0); 54 | } 55 | -------------------------------------------------------------------------------- /SET/mains/relationalOperators_main.cpp: -------------------------------------------------------------------------------- 1 | /* ************************************************************************** */ 2 | /* */ 3 | /* ::: :::::::: */ 4 | /* relationalOperators_main.cpp :+: :+: :+: */ 5 | /* +:+ +:+ +:+ */ 6 | /* By: hbaudet +#+ +:+ +#+ */ 7 | /* +#+#+#+#+#+ +#+ */ 8 | /* Created: 2020/12/02 13:07:06 by hbaudet #+# #+# */ 9 | /* Updated: 2021/01/20 10:27:19 by hbaudet ### ########.fr */ 10 | /* */ 11 | /* ************************************************************************** */ 12 | 13 | #include "test_utils.hpp" 14 | #include "SET_UC.HPP" 15 | #include 16 | 17 | #ifndef STD 18 | # define NAMESPACE ft 19 | #else 20 | # define NAMESPACE std 21 | #endif 22 | 23 | using namespace NAMESPACE; 24 | 25 | template 26 | void print(set& lst) 27 | { 28 | for (typename set::iterator it = lst.begin(); it != lst.end(); it++) 29 | cout << it->first << " => " << it->second << '\n'; 30 | } 31 | 32 | int main () 33 | { 34 | set foo,bar; 35 | foo.insert(10); 36 | bar.insert(20); 37 | bar.insert(30); 38 | foo.insert(40); 39 | 40 | // foo ({10,40}) vs bar ({20,30}): 41 | if (foo==bar) cout << "foo and bar are equal\n"; 42 | if (foo!=bar) cout << "foo and bar are not equal\n"; 43 | if (foo< bar) cout << "foo is less than bar\n"; 44 | if (foo> bar) cout << "foo is greater than bar\n"; 45 | if (foo<=bar) cout << "foo is less than or equal to bar\n"; 46 | if (foo>=bar) cout << "foo is greater than or equal to bar\n"; 47 | 48 | return 0; 49 | } 50 | -------------------------------------------------------------------------------- /MAP/mains/clear_main.cpp: -------------------------------------------------------------------------------- 1 | /* ************************************************************************** */ 2 | /* */ 3 | /* ::: :::::::: */ 4 | /* clear_main.cpp :+: :+: :+: */ 5 | /* +:+ +:+ +:+ */ 6 | /* By: hbaudet +#+ +:+ +#+ */ 7 | /* +#+#+#+#+#+ +#+ */ 8 | /* Created: 2020/12/02 13:07:06 by hbaudet #+# #+# */ 9 | /* Updated: 2021/01/18 16:05:29 by hbaudet ### ########.fr */ 10 | /* */ 11 | /* ************************************************************************** */ 12 | 13 | #include "test_utils.hpp" 14 | #include "MAP_UC.HPP" 15 | #include 16 | 17 | #ifndef STD 18 | # define NAMESPACE ft 19 | #else 20 | # define NAMESPACE std 21 | #endif 22 | 23 | using namespace NAMESPACE; 24 | 25 | template 26 | void print(map& lst) 27 | { 28 | for (typename map::iterator it = lst.begin(); it != lst.end(); it++) 29 | cout << it->first << " => " << it->second << '\n'; 30 | } 31 | 32 | int main () 33 | { 34 | map mymap; 35 | 36 | mymap['x']=100; 37 | mymap['y']=200; 38 | mymap['z']=300; 39 | 40 | cout << "mymap contains:\n"; 41 | for (map::iterator it=mymap.begin(); it!=mymap.end(); ++it) 42 | cout << it->first << " => " << it->second << '\n'; 43 | 44 | mymap.clear(); 45 | mymap['a']=1101; 46 | mymap['b']=2202; 47 | 48 | cout << "mymap contains:\n"; 49 | for (map::iterator it=mymap.begin(); it!=mymap.end(); ++it) 50 | cout << it->first << " => " << it->second << '\n'; 51 | 52 | return 0; 53 | } 54 | -------------------------------------------------------------------------------- /VECTOR/mains/.empty_main.cpp: -------------------------------------------------------------------------------- 1 | /* ************************************************************************** */ 2 | /* */ 3 | /* ::: :::::::: */ 4 | /* .empty_main.cpp :+: :+: :+: */ 5 | /* +:+ +:+ +:+ */ 6 | /* By: hbaudet +#+ +:+ +#+ */ 7 | /* +#+#+#+#+#+ +#+ */ 8 | /* Created: 2020/12/02 13:07:06 by hbaudet #+# #+# */ 9 | /* Updated: 2021/01/20 21:54:51 by hbaudet ### ########.fr */ 10 | /* */ 11 | /* ************************************************************************** */ 12 | 13 | #include "hbaudet_utils.hpp" 14 | #include "VECTOR_UC.HPP" 15 | #include 16 | 17 | #ifndef STD 18 | # define NAMESPACE ft 19 | #else 20 | # define NAMESPACE std 21 | #endif 22 | 23 | using namespace NAMESPACE; 24 | 25 | template 26 | void print(vector >& lst) 27 | { 28 | for (typename vector >::iterator it = lst.begin(); it != lst.end(); it++) 29 | { 30 | for (typename vector::iterator it2 = it->begin(); it2 != it->end(); it2++) 31 | cout << *it2 << ' '; 32 | cout << '\n'; 33 | } 34 | } 35 | 36 | template 37 | void print(vector& lst) 38 | { 39 | for (typename vector::iterator it = lst.begin(); it != lst.end(); it++) 40 | cout << *it << ' '; 41 | cout << '\n'; 42 | } 43 | 44 | int main() 45 | { 46 | /* THIS IS A TEMPLATE MAIN 47 | ** WRITE ANY TEST YOU WANT TO PERFORM 48 | ** SAVE IT UNDER 'something_main.cpp' 49 | ** IT WILL BE RUN WITH FT::VECTOR AND STD::VECTOR 50 | ** BOTH OUTPUTS WILL BE COMPARED 51 | */ 52 | 53 | return (0); 54 | } 55 | -------------------------------------------------------------------------------- /SET/mains/erase_main.cpp: -------------------------------------------------------------------------------- 1 | /* ************************************************************************** */ 2 | /* */ 3 | /* ::: :::::::: */ 4 | /* erase_main.cpp :+: :+: :+: */ 5 | /* +:+ +:+ +:+ */ 6 | /* By: hbaudet +#+ +:+ +#+ */ 7 | /* +#+#+#+#+#+ +#+ */ 8 | /* Created: 2020/12/02 13:07:06 by hbaudet #+# #+# */ 9 | /* Updated: 2021/01/20 10:21:11 by hbaudet ### ########.fr */ 10 | /* */ 11 | /* ************************************************************************** */ 12 | 13 | #include "test_utils.hpp" 14 | #include "SET_UC.HPP" 15 | #include 16 | 17 | #ifndef STD 18 | # define NAMESPACE ft 19 | #else 20 | # define NAMESPACE std 21 | #endif 22 | 23 | using namespace NAMESPACE; 24 | 25 | template 26 | void print(set& lst) 27 | { 28 | for (typename set::iterator it = lst.begin(); it != lst.end(); it++) 29 | cout << it->first << " => " << it->second << '\n'; 30 | } 31 | 32 | int main () 33 | { 34 | set myset; 35 | set::iterator it; 36 | 37 | // insert some values: 38 | for (int i=1; i<10; i++) myset.insert(i*10); // 10 20 30 40 50 60 70 80 90 39 | 40 | it = myset.begin(); 41 | ++it; // "it" points now to 20 42 | 43 | myset.erase (it); 44 | 45 | myset.erase (40); 46 | 47 | it = myset.find (60); 48 | myset.erase (it, myset.end()); 49 | 50 | cout << "myset contains:"; 51 | for (it=myset.begin(); it!=myset.end(); ++it) 52 | cout << ' ' << *it; 53 | cout << '\n'; 54 | 55 | return 0; 56 | } 57 | -------------------------------------------------------------------------------- /LIST/mains/begin_main.cpp: -------------------------------------------------------------------------------- 1 | /* ************************************************************************** */ 2 | /* */ 3 | /* ::: :::::::: */ 4 | /* begin_main.cpp :+: :+: :+: */ 5 | /* +:+ +:+ +:+ */ 6 | /* By: hbaudet +#+ +:+ +#+ */ 7 | /* +#+#+#+#+#+ +#+ */ 8 | /* Created: 2020/12/02 13:07:06 by hbaudet #+# #+# */ 9 | /* Updated: 2021/01/18 16:04:37 by hbaudet ### ########.fr */ 10 | /* */ 11 | /* ************************************************************************** */ 12 | 13 | #include "test_utils.hpp" 14 | #include "LIST_UC.HPP" 15 | #include 16 | 17 | #ifndef STD 18 | # define NAMESPACE ft 19 | #else 20 | # define NAMESPACE std 21 | #endif 22 | 23 | using namespace NAMESPACE; 24 | 25 | template 26 | void print(list >& lst) 27 | { 28 | for (typename list >::iterator it = lst.begin(); it != lst.end(); it++) 29 | { 30 | for (typename list::iterator it2 = it->begin(); it2 != it->end(); it2++) 31 | cout << *it2 << ' '; 32 | cout << '\n'; 33 | } 34 | } 35 | 36 | template 37 | void print(list& lst) 38 | { 39 | for (typename list::iterator it = lst.begin(); it != lst.end(); it++) 40 | cout << *it << ' '; 41 | cout << '\n'; 42 | } 43 | 44 | int main () 45 | { 46 | int myints[] = {75,23,65,42,13}; 47 | list mylist (myints,myints+5); 48 | 49 | cout << "mylist contains:"; 50 | for (list::iterator it=mylist.begin(); it != mylist.end(); ++it) 51 | cout << ' ' << *it; 52 | 53 | cout << '\n'; 54 | 55 | return 0; 56 | } 57 | -------------------------------------------------------------------------------- /LIST/mains/end_main.cpp: -------------------------------------------------------------------------------- 1 | /* ************************************************************************** */ 2 | /* */ 3 | /* ::: :::::::: */ 4 | /* end_main.cpp :+: :+: :+: */ 5 | /* +:+ +:+ +:+ */ 6 | /* By: hbaudet +#+ +:+ +#+ */ 7 | /* +#+#+#+#+#+ +#+ */ 8 | /* Created: 2020/12/02 13:07:06 by hbaudet #+# #+# */ 9 | /* Updated: 2021/01/18 16:04:29 by hbaudet ### ########.fr */ 10 | /* */ 11 | /* ************************************************************************** */ 12 | 13 | #include "test_utils.hpp" 14 | #include "LIST_UC.HPP" 15 | #include 16 | 17 | #ifndef STD 18 | # define NAMESPACE ft 19 | #else 20 | # define NAMESPACE std 21 | #endif 22 | 23 | using namespace NAMESPACE; 24 | 25 | template 26 | void print(list >& lst) 27 | { 28 | for (typename list >::iterator it = lst.begin(); it != lst.end(); it++) 29 | { 30 | for (typename list::iterator it2 = it->begin(); it2 != it->end(); it2++) 31 | cout << *it2 << ' '; 32 | cout << '\n'; 33 | } 34 | } 35 | 36 | template 37 | void print(list& lst) 38 | { 39 | for (typename list::iterator it = lst.begin(); it != lst.end(); it++) 40 | cout << *it << ' '; 41 | cout << '\n'; 42 | } 43 | 44 | int main () 45 | { 46 | int myints[] = {75,23,65,42,13}; 47 | list mylist (myints,myints+5); 48 | 49 | cout << "mylist contains:"; 50 | for (list::iterator it=mylist.begin() ; it != mylist.end(); ++it) 51 | cout << ' ' << *it; 52 | 53 | cout << '\n'; 54 | 55 | return 0; 56 | } 57 | -------------------------------------------------------------------------------- /LIST/mains/front_main.cpp: -------------------------------------------------------------------------------- 1 | /* ************************************************************************** */ 2 | /* */ 3 | /* ::: :::::::: */ 4 | /* front_main.cpp :+: :+: :+: */ 5 | /* +:+ +:+ +:+ */ 6 | /* By: hbaudet +#+ +:+ +#+ */ 7 | /* +#+#+#+#+#+ +#+ */ 8 | /* Created: 2020/12/02 13:07:06 by hbaudet #+# #+# */ 9 | /* Updated: 2021/01/18 16:04:26 by hbaudet ### ########.fr */ 10 | /* */ 11 | /* ************************************************************************** */ 12 | 13 | #include "test_utils.hpp" 14 | #include "LIST_UC.HPP" 15 | #include 16 | 17 | #ifndef STD 18 | # define NAMESPACE ft 19 | #else 20 | # define NAMESPACE std 21 | #endif 22 | 23 | using namespace NAMESPACE; 24 | 25 | template 26 | void print(list >& lst) 27 | { 28 | for (typename list >::iterator it = lst.begin(); it != lst.end(); it++) 29 | { 30 | for (typename list::iterator it2 = it->begin(); it2 != it->end(); it2++) 31 | cout << *it2 << ' '; 32 | cout << '\n'; 33 | } 34 | } 35 | 36 | template 37 | void print(list& lst) 38 | { 39 | for (typename list::iterator it = lst.begin(); it != lst.end(); it++) 40 | cout << *it << ' '; 41 | cout << '\n'; 42 | } 43 | 44 | int main () 45 | { 46 | list mylist; 47 | 48 | mylist.push_back(77); 49 | mylist.push_back(22); 50 | 51 | // now front equals 77, and back 22 52 | 53 | mylist.front() -= mylist.back(); 54 | 55 | cout << "mylist.front() is now " << mylist.front() << '\n'; 56 | 57 | return 0; 58 | } 59 | -------------------------------------------------------------------------------- /QUEUE/mains/front_main.cpp: -------------------------------------------------------------------------------- 1 | /* ************************************************************************** */ 2 | /* */ 3 | /* ::: :::::::: */ 4 | /* front_main.cpp :+: :+: :+: */ 5 | /* +:+ +:+ +:+ */ 6 | /* By: hbaudet +#+ +:+ +#+ */ 7 | /* +#+#+#+#+#+ +#+ */ 8 | /* Created: 2020/12/02 13:07:06 by hbaudet #+# #+# */ 9 | /* Updated: 2021/01/18 16:41:52 by hbaudet ### ########.fr */ 10 | /* */ 11 | /* ************************************************************************** */ 12 | 13 | #include 14 | #include "test_utils.hpp" 15 | #include "QUEUE_UC.HPP" 16 | #include "LIST_UC.HPP" 17 | 18 | #ifndef STD 19 | # define NAMESPACE ft 20 | #else 21 | # define NAMESPACE std 22 | #endif 23 | 24 | using namespace NAMESPACE; 25 | 26 | template 27 | void print(queue >& lst) 28 | { 29 | for (typename queue >::iterator it = lst.begin(); it != lst.end(); it++) 30 | { 31 | for (typename queue::iterator it2 = it->begin(); it2 != it->end(); it2++) 32 | cout << *it2 << ' '; 33 | cout << '\n'; 34 | } 35 | } 36 | 37 | template 38 | void print(queue& lst) 39 | { 40 | for (typename queue::iterator it = lst.begin(); it != lst.end(); it++) 41 | cout << *it << ' '; 42 | cout << '\n'; 43 | } 44 | 45 | int main () 46 | { 47 | queue myqueue; 48 | 49 | myqueue.push(77); 50 | myqueue.push(16); 51 | 52 | myqueue.front() -= myqueue.back(); // 77-16=61 53 | 54 | cout << "myqueue.front() is now " << myqueue.front() << '\n'; 55 | 56 | return 0; 57 | } 58 | -------------------------------------------------------------------------------- /VECTOR/mains/operator=_main.cpp: -------------------------------------------------------------------------------- 1 | /* ************************************************************************** */ 2 | /* */ 3 | /* ::: :::::::: */ 4 | /* operator=_main.cpp :+: :+: :+: */ 5 | /* +:+ +:+ +:+ */ 6 | /* By: hbaudet +#+ +:+ +#+ */ 7 | /* +#+#+#+#+#+ +#+ */ 8 | /* Created: 2020/12/02 13:07:06 by hbaudet #+# #+# */ 9 | /* Updated: 2021/01/18 16:07:15 by hbaudet ### ########.fr */ 10 | /* */ 11 | /* ************************************************************************** */ 12 | 13 | #include "test_utils.hpp" 14 | #include "VECTOR_UC.HPP" 15 | #include 16 | 17 | #ifndef STD 18 | # define NAMESPACE ft 19 | #else 20 | # define NAMESPACE std 21 | #endif 22 | 23 | using namespace NAMESPACE; 24 | 25 | template 26 | void print(vector >& lst) 27 | { 28 | for (typename vector >::iterator it = lst.begin(); it != lst.end(); it++) 29 | { 30 | for (typename vector::iterator it2 = it->begin(); it2 != it->end(); it2++) 31 | cout << *it2 << ' '; 32 | cout << '\n'; 33 | } 34 | } 35 | 36 | template 37 | void print(vector& lst) 38 | { 39 | for (typename vector::iterator it = lst.begin(); it != lst.end(); it++) 40 | cout << *it << ' '; 41 | cout << '\n'; 42 | } 43 | 44 | 45 | int main () 46 | { 47 | vector foo (3,0); 48 | vector bar (5,0); 49 | 50 | bar = foo; 51 | foo = vector(); 52 | 53 | cout << "Size of foo: " << int(foo.size()) << '\n'; 54 | cout << "Size of bar: " << int(bar.size()) << '\n'; 55 | return 0; 56 | } 57 | -------------------------------------------------------------------------------- /LIST/mains/rend_main.cpp: -------------------------------------------------------------------------------- 1 | /* ************************************************************************** */ 2 | /* */ 3 | /* ::: :::::::: */ 4 | /* rend_main.cpp :+: :+: :+: */ 5 | /* +:+ +:+ +:+ */ 6 | /* By: hbaudet +#+ +:+ +#+ */ 7 | /* +#+#+#+#+#+ +#+ */ 8 | /* Created: 2020/12/02 13:07:06 by hbaudet #+# #+# */ 9 | /* Updated: 2021/01/18 16:03:59 by hbaudet ### ########.fr */ 10 | /* */ 11 | /* ************************************************************************** */ 12 | 13 | #include "test_utils.hpp" 14 | #include "LIST_UC.HPP" 15 | #include 16 | 17 | #ifndef STD 18 | # define NAMESPACE ft 19 | #else 20 | # define NAMESPACE std 21 | #endif 22 | 23 | using namespace NAMESPACE; 24 | 25 | template 26 | void print(list >& lst) 27 | { 28 | for (typename list >::iterator it = lst.begin(); it != lst.end(); it++) 29 | { 30 | for (typename list::iterator it2 = it->begin(); it2 != it->end(); it2++) 31 | cout << *it2 << ' '; 32 | cout << '\n'; 33 | } 34 | } 35 | 36 | template 37 | void print(list& lst) 38 | { 39 | for (typename list::iterator it = lst.begin(); it != lst.end(); it++) 40 | cout << *it << ' '; 41 | cout << '\n'; 42 | } 43 | 44 | int main () 45 | { 46 | list mylist; 47 | for (int i=1; i<=5; ++i) mylist.push_back(i); 48 | 49 | cout << "mylist backwards:"; 50 | for (list::reverse_iterator rit=mylist.rbegin(); rit!=mylist.rend(); ++rit) 51 | cout << ' ' << *rit; 52 | 53 | cout << '\n'; 54 | 55 | return 0; 56 | } 57 | -------------------------------------------------------------------------------- /LIST/mains/empty_main.cpp: -------------------------------------------------------------------------------- 1 | /* ************************************************************************** */ 2 | /* */ 3 | /* ::: :::::::: */ 4 | /* empty_main.cpp :+: :+: :+: */ 5 | /* +:+ +:+ +:+ */ 6 | /* By: hbaudet +#+ +:+ +#+ */ 7 | /* +#+#+#+#+#+ +#+ */ 8 | /* Created: 2020/12/02 13:07:06 by hbaudet #+# #+# */ 9 | /* Updated: 2021/01/18 16:04:31 by hbaudet ### ########.fr */ 10 | /* */ 11 | /* ************************************************************************** */ 12 | 13 | #include "test_utils.hpp" 14 | #include "LIST_UC.HPP" 15 | #include 16 | 17 | #ifndef STD 18 | # define NAMESPACE ft 19 | #else 20 | # define NAMESPACE std 21 | #endif 22 | 23 | using namespace NAMESPACE; 24 | 25 | template 26 | void print(list >& lst) 27 | { 28 | for (typename list >::iterator it = lst.begin(); it != lst.end(); it++) 29 | { 30 | for (typename list::iterator it2 = it->begin(); it2 != it->end(); it2++) 31 | cout << *it2 << ' '; 32 | cout << '\n'; 33 | } 34 | } 35 | 36 | template 37 | void print(list& lst) 38 | { 39 | for (typename list::iterator it = lst.begin(); it != lst.end(); it++) 40 | cout << *it << ' '; 41 | cout << '\n'; 42 | } 43 | 44 | int main () 45 | { 46 | list mylist; 47 | int sum (0); 48 | 49 | for (int i=1;i<=10;++i) mylist.push_back(i); 50 | 51 | while (!mylist.empty()) 52 | { 53 | sum += mylist.front(); 54 | mylist.pop_front(); 55 | } 56 | 57 | cout << "total: " << sum << '\n'; 58 | 59 | return 0; 60 | } 61 | -------------------------------------------------------------------------------- /LIST/mains/rbegin_main.cpp: -------------------------------------------------------------------------------- 1 | /* ************************************************************************** */ 2 | /* */ 3 | /* ::: :::::::: */ 4 | /* rbegin_main.cpp :+: :+: :+: */ 5 | /* +:+ +:+ +:+ */ 6 | /* By: hbaudet +#+ +:+ +#+ */ 7 | /* +#+#+#+#+#+ +#+ */ 8 | /* Created: 2020/12/02 13:07:06 by hbaudet #+# #+# */ 9 | /* Updated: 2021/01/18 16:04:06 by hbaudet ### ########.fr */ 10 | /* */ 11 | /* ************************************************************************** */ 12 | 13 | #include "test_utils.hpp" 14 | #include "LIST_UC.HPP" 15 | #include 16 | 17 | #ifndef STD 18 | # define NAMESPACE ft 19 | #else 20 | # define NAMESPACE std 21 | #endif 22 | 23 | using namespace NAMESPACE; 24 | 25 | template 26 | void print(list >& lst) 27 | { 28 | for (typename list >::iterator it = lst.begin(); it != lst.end(); it++) 29 | { 30 | for (typename list::iterator it2 = it->begin(); it2 != it->end(); it2++) 31 | cout << *it2 << ' '; 32 | cout << '\n'; 33 | } 34 | } 35 | 36 | template 37 | void print(list& lst) 38 | { 39 | for (typename list::iterator it = lst.begin(); it != lst.end(); it++) 40 | cout << *it << ' '; 41 | cout << '\n'; 42 | } 43 | 44 | int main () 45 | { 46 | list mylist; 47 | for (int i=1; i<=5; ++i) mylist.push_back(i); 48 | 49 | cout << "mylist backwards:"; 50 | for (list::reverse_iterator rit=mylist.rbegin(); rit!=mylist.rend(); ++rit) 51 | cout << ' ' << *rit; 52 | 53 | cout << '\n'; 54 | 55 | return 0; 56 | } 57 | -------------------------------------------------------------------------------- /QUEUE/mains/back_main.cpp: -------------------------------------------------------------------------------- 1 | /* ************************************************************************** */ 2 | /* */ 3 | /* ::: :::::::: */ 4 | /* back_main.cpp :+: :+: :+: */ 5 | /* +:+ +:+ +:+ */ 6 | /* By: hbaudet +#+ +:+ +#+ */ 7 | /* +#+#+#+#+#+ +#+ */ 8 | /* Created: 2020/12/02 13:07:06 by hbaudet #+# #+# */ 9 | /* Updated: 2021/01/18 16:40:59 by hbaudet ### ########.fr */ 10 | /* */ 11 | /* ************************************************************************** */ 12 | 13 | #include 14 | #include "test_utils.hpp" 15 | #include "QUEUE_UC.HPP" 16 | #include "LIST_UC.HPP" 17 | 18 | #ifndef STD 19 | # define NAMESPACE ft 20 | #else 21 | # define NAMESPACE std 22 | #endif 23 | 24 | using namespace NAMESPACE; 25 | 26 | template 27 | void print(queue >& lst) 28 | { 29 | for (typename queue >::iterator it = lst.begin(); it != lst.end(); it++) 30 | { 31 | for (typename queue::iterator it2 = it->begin(); it2 != it->end(); it2++) 32 | cout << *it2 << ' '; 33 | cout << '\n'; 34 | } 35 | } 36 | 37 | template 38 | void print(queue& lst) 39 | { 40 | for (typename queue::iterator it = lst.begin(); it != lst.end(); it++) 41 | cout << *it << ' '; 42 | cout << '\n'; 43 | } 44 | 45 | int main () 46 | { 47 | queue myqueue; 48 | 49 | myqueue.push(12); 50 | myqueue.push(75); // this is now the back 51 | 52 | myqueue.back() -= myqueue.front(); 53 | 54 | cout << "myqueue.back() is now " << myqueue.back() << '\n'; 55 | 56 | return 0; 57 | } 58 | -------------------------------------------------------------------------------- /MAP/mains/relationalOperators_main.cpp: -------------------------------------------------------------------------------- 1 | /* ************************************************************************** */ 2 | /* */ 3 | /* ::: :::::::: */ 4 | /* relationalOperators_main.cpp :+: :+: :+: */ 5 | /* +:+ +:+ +:+ */ 6 | /* By: hbaudet +#+ +:+ +#+ */ 7 | /* +#+#+#+#+#+ +#+ */ 8 | /* Created: 2020/12/02 13:07:06 by hbaudet #+# #+# */ 9 | /* Updated: 2021/01/18 16:05:08 by hbaudet ### ########.fr */ 10 | /* */ 11 | /* ************************************************************************** */ 12 | 13 | #include "test_utils.hpp" 14 | #include "MAP_UC.HPP" 15 | #include 16 | 17 | #ifndef STD 18 | # define NAMESPACE ft 19 | #else 20 | # define NAMESPACE std 21 | #endif 22 | 23 | using namespace NAMESPACE; 24 | 25 | template 26 | void print(map& lst) 27 | { 28 | for (typename map::iterator it = lst.begin(); it != lst.end(); it++) 29 | cout << it->first << " => " << it->second << '\n'; 30 | } 31 | 32 | int main () 33 | { 34 | map foo,bar; 35 | foo['a']=100; 36 | foo['b']=200; 37 | bar['a']=10; 38 | bar['z']=1000; 39 | 40 | // foo ({{a,100},{b,200}}) vs bar ({a,10},{z,1000}}): 41 | if (foo==bar) cout << "foo and bar are equal\n"; 42 | if (foo!=bar) cout << "foo and bar are not equal\n"; 43 | if (foo< bar) cout << "foo is less than bar\n"; 44 | if (foo> bar) cout << "foo is greater than bar\n"; 45 | if (foo<=bar) cout << "foo is less than or equal to bar\n"; 46 | if (foo>=bar) cout << "foo is greater than or equal to bar\n"; 47 | 48 | return 0; 49 | } 50 | -------------------------------------------------------------------------------- /MAP/mains/upperBound_main.cpp: -------------------------------------------------------------------------------- 1 | /* ************************************************************************** */ 2 | /* */ 3 | /* ::: :::::::: */ 4 | /* upperBound_main.cpp :+: :+: :+: */ 5 | /* +:+ +:+ +:+ */ 6 | /* By: hbaudet +#+ +:+ +#+ */ 7 | /* +#+#+#+#+#+ +#+ */ 8 | /* Created: 2020/12/02 13:07:06 by hbaudet #+# #+# */ 9 | /* Updated: 2021/01/18 16:05:01 by hbaudet ### ########.fr */ 10 | /* */ 11 | /* ************************************************************************** */ 12 | 13 | #include "test_utils.hpp" 14 | #include "MAP_UC.HPP" 15 | #include 16 | 17 | #ifndef STD 18 | # define NAMESPACE ft 19 | #else 20 | # define NAMESPACE std 21 | #endif 22 | 23 | using namespace NAMESPACE; 24 | 25 | template 26 | void print(map& lst) 27 | { 28 | for (typename map::iterator it = lst.begin(); it != lst.end(); it++) 29 | cout << it->first << " => " << it->second << '\n'; 30 | } 31 | 32 | int main () 33 | { 34 | map mymap; 35 | map::iterator itlow,itup; 36 | 37 | mymap['a']=20; 38 | mymap['b']=40; 39 | mymap['c']=60; 40 | mymap['d']=80; 41 | mymap['e']=100; 42 | 43 | itlow=mymap.lower_bound ('b'); // itlow points to b 44 | itup=mymap.upper_bound ('d'); // itup points to e (not d!) 45 | 46 | mymap.erase(itlow,itup); // erases [itlow,itup) 47 | 48 | // print content: 49 | for (map::iterator it=mymap.begin(); it!=mymap.end(); ++it) 50 | cout << it->first << " => " << it->second << '\n'; 51 | 52 | return 0; 53 | } 54 | -------------------------------------------------------------------------------- /LIST/mains/pushBack_main.cpp: -------------------------------------------------------------------------------- 1 | /* ************************************************************************** */ 2 | /* */ 3 | /* ::: :::::::: */ 4 | /* pushBack_main.cpp :+: :+: :+: */ 5 | /* +:+ +:+ +:+ */ 6 | /* By: hbaudet +#+ +:+ +#+ */ 7 | /* +#+#+#+#+#+ +#+ */ 8 | /* Created: 2020/12/02 13:07:06 by hbaudet #+# #+# */ 9 | /* Updated: 2021/01/18 16:04:10 by hbaudet ### ########.fr */ 10 | /* */ 11 | /* ************************************************************************** */ 12 | 13 | #include "test_utils.hpp" 14 | #include "LIST_UC.HPP" 15 | #include 16 | 17 | #ifndef STD 18 | # define NAMESPACE ft 19 | #else 20 | # define NAMESPACE std 21 | #endif 22 | 23 | using namespace NAMESPACE; 24 | 25 | template 26 | void print(list >& lst) 27 | { 28 | for (typename list >::iterator it = lst.begin(); it != lst.end(); it++) 29 | { 30 | for (typename list::iterator it2 = it->begin(); it2 != it->end(); it2++) 31 | cout << *it2 << ' '; 32 | cout << '\n'; 33 | } 34 | } 35 | 36 | template 37 | void print(list& lst) 38 | { 39 | for (typename list::iterator it = lst.begin(); it != lst.end(); it++) 40 | cout << *it << ' '; 41 | cout << '\n'; 42 | } 43 | 44 | int main () 45 | { 46 | list mylist; 47 | int myint(87); 48 | 49 | 50 | do { 51 | myint += 67; 52 | myint /= 3; 53 | myint *= 2; 54 | mylist.push_back (myint); 55 | } while (mylist.size() < 42); 56 | 57 | cout << "mylist stores " << mylist.size() << " numbers.\n"; 58 | 59 | return 0; 60 | } 61 | -------------------------------------------------------------------------------- /DEQUE/mains/empty_main.cpp: -------------------------------------------------------------------------------- 1 | /* ************************************************************************** */ 2 | /* */ 3 | /* ::: :::::::: */ 4 | /* empty_main.cpp :+: :+: :+: */ 5 | /* +:+ +:+ +:+ */ 6 | /* By: hbaudet +#+ +:+ +#+ */ 7 | /* +#+#+#+#+#+ +#+ */ 8 | /* Created: 2020/12/02 13:07:06 by hbaudet #+# #+# */ 9 | /* Updated: 2021/01/18 16:02:08 by hbaudet ### ########.fr */ 10 | /* */ 11 | /* ************************************************************************** */ 12 | 13 | #include "test_utils.hpp" 14 | #include "DEQUE_UC.HPP" 15 | #include 16 | 17 | #ifndef STD 18 | # define NAMESPACE ft 19 | #else 20 | # define NAMESPACE std 21 | #endif 22 | 23 | using namespace NAMESPACE; 24 | 25 | template 26 | void print(deque >& lst) 27 | { 28 | for (typename deque >::iterator it = lst.begin(); it != lst.end(); it++) 29 | { 30 | for (typename deque::iterator it2 = it->begin(); it2 != it->end(); it2++) 31 | cout << *it2 << ' '; 32 | cout << '\n'; 33 | } 34 | } 35 | 36 | template 37 | void print(deque& lst) 38 | { 39 | for (typename deque::iterator it = lst.begin(); it != lst.end(); it++) 40 | cout << *it << ' '; 41 | cout << '\n'; 42 | } 43 | 44 | int main () 45 | { 46 | deque mydeque; 47 | int sum (0); 48 | 49 | for (int i=1;i<=10;i++) mydeque.push_back(i); 50 | 51 | while (!mydeque.empty()) 52 | { 53 | sum += mydeque.front(); 54 | mydeque.pop_front(); 55 | } 56 | 57 | cout << "total: " << sum << '\n'; 58 | 59 | return 0; 60 | } 61 | -------------------------------------------------------------------------------- /LIST/mains/short_main.cpp: -------------------------------------------------------------------------------- 1 | /* ************************************************************************** */ 2 | /* */ 3 | /* ::: :::::::: */ 4 | /* short_main.cpp :+: :+: :+: */ 5 | /* +:+ +:+ +:+ */ 6 | /* By: hbaudet +#+ +:+ +#+ */ 7 | /* +#+#+#+#+#+ +#+ */ 8 | /* Created: 2020/10/19 10:03:48 by hbaudet #+# #+# */ 9 | /* Updated: 2021/01/18 16:03:52 by hbaudet ### ########.fr */ 10 | /* */ 11 | /* ************************************************************************** */ 12 | 13 | #include "test_utils.hpp" 14 | #include "LIST_UC.HPP" 15 | #include 16 | 17 | #ifndef STD 18 | # define NAMESPACE ft 19 | #else 20 | # define NAMESPACE std 21 | #endif 22 | 23 | using namespace NAMESPACE; 24 | 25 | int main() 26 | { 27 | // List i; 28 | 29 | // i.push_back(5); 30 | 31 | list li; 32 | list lst(5, 0); 33 | list test; 34 | 35 | li.push_back(7); 36 | li.push_back(9); 37 | li.push_back(456); 38 | li.push_back(45); 39 | li.push_back(42); 40 | 41 | list::iterator it = li.begin(); 42 | list::iterator ti = li.end(); 43 | 44 | ti--; 45 | ti--; 46 | cout << *(++it) << '\n'; 47 | 48 | 49 | while (*it != 42) 50 | { 51 | if (*it == *ti) 52 | cout << "Reached n - 1 elem\n"; 53 | it++; 54 | } 55 | 56 | 57 | cout << *it << '\n'; 58 | cout << *ti << '\n'; 59 | 60 | li.pop_back(); 61 | cout << *(--(li.end())) << '\n'; 62 | 63 | for (list::iterator iter = lst.begin(); iter != lst.end(); iter++) 64 | cout << *iter << ' '; 65 | cout << '\n'; 66 | 67 | return 0; 68 | } 69 | -------------------------------------------------------------------------------- /LIST/mains/reverse_main.cpp: -------------------------------------------------------------------------------- 1 | /* ************************************************************************** */ 2 | /* */ 3 | /* ::: :::::::: */ 4 | /* reverse_main.cpp :+: :+: :+: */ 5 | /* +:+ +:+ +:+ */ 6 | /* By: hbaudet +#+ +:+ +#+ */ 7 | /* +#+#+#+#+#+ +#+ */ 8 | /* Created: 2020/12/02 13:07:06 by hbaudet #+# #+# */ 9 | /* Updated: 2021/01/18 16:03:55 by hbaudet ### ########.fr */ 10 | /* */ 11 | /* ************************************************************************** */ 12 | 13 | #include "test_utils.hpp" 14 | #include "LIST_UC.HPP" 15 | #include 16 | 17 | #ifndef STD 18 | # define NAMESPACE ft 19 | #else 20 | # define NAMESPACE std 21 | #endif 22 | 23 | using namespace NAMESPACE; 24 | 25 | template 26 | void print(list >& lst) 27 | { 28 | for (typename list >::iterator it = lst.begin(); it != lst.end(); it++) 29 | { 30 | for (typename list::iterator it2 = it->begin(); it2 != it->end(); it2++) 31 | cout << *it2 << ' '; 32 | cout << '\n'; 33 | } 34 | } 35 | 36 | template 37 | void print(list& lst) 38 | { 39 | for (typename list::iterator it = lst.begin(); it != lst.end(); it++) 40 | cout << *it << ' '; 41 | cout << '\n'; 42 | } 43 | 44 | int main () 45 | { 46 | list mylist; 47 | 48 | for (int i=1; i<10; ++i) mylist.push_back(i); 49 | 50 | mylist.reverse(); 51 | 52 | cout << "mylist contains:"; 53 | for (list::iterator it=mylist.begin(); it!=mylist.end(); ++it) 54 | cout << ' ' << *it; 55 | 56 | cout << '\n'; 57 | 58 | return 0; 59 | } 60 | -------------------------------------------------------------------------------- /QUEUE/mains/.empty_main.cpp: -------------------------------------------------------------------------------- 1 | /* ************************************************************************** */ 2 | /* */ 3 | /* ::: :::::::: */ 4 | /* .empty_main.cpp :+: :+: :+: */ 5 | /* +:+ +:+ +:+ */ 6 | /* By: hbaudet +#+ +:+ +#+ */ 7 | /* +#+#+#+#+#+ +#+ */ 8 | /* Created: 2020/12/02 13:07:06 by hbaudet #+# #+# */ 9 | /* Updated: 2021/01/20 21:45:08 by hbaudet ### ########.fr */ 10 | /* */ 11 | /* ************************************************************************** */ 12 | 13 | #include 14 | #include 15 | #include "hbaudet_utils.hpp" 16 | #include "QUEUE_UC.HPP" 17 | #include "LIST_UC.HPP" 18 | 19 | #ifndef STD 20 | # define NAMESPACE ft 21 | #else 22 | # define NAMESPACE std 23 | #endif 24 | 25 | using namespace NAMESPACE; 26 | 27 | template 28 | void print(queue >& lst) 29 | { 30 | for (typename queue >::iterator it = lst.begin(); it != lst.end(); it++) 31 | { 32 | for (typename queue::iterator it2 = it->begin(); it2 != it->end(); it2++) 33 | cout << *it2 << ' '; 34 | cout << '\n'; 35 | } 36 | } 37 | 38 | template 39 | void print(queue& lst) 40 | { 41 | for (typename queue::iterator it = lst.begin(); it != lst.end(); it++) 42 | cout << *it << ' '; 43 | cout << '\n'; 44 | } 45 | 46 | int main() 47 | { 48 | /* THIS IS A TEMPLATE MAIN 49 | ** WRITE ANY TEST YOU WANT TO PERFORM 50 | ** SAVE IT UNDER 'something_main.cpp' 51 | ** IT WILL BE RUN WITH FT::queue AND STD::queue 52 | ** BOTH OUTPUTS WILL BE COMPARED 53 | */ 54 | 55 | return (0); 56 | } 57 | -------------------------------------------------------------------------------- /VECTOR/mains/begin_main.cpp: -------------------------------------------------------------------------------- 1 | /* ************************************************************************** */ 2 | /* */ 3 | /* ::: :::::::: */ 4 | /* begin_main.cpp :+: :+: :+: */ 5 | /* +:+ +:+ +:+ */ 6 | /* By: hbaudet +#+ +:+ +#+ */ 7 | /* +#+#+#+#+#+ +#+ */ 8 | /* Created: 2020/12/02 13:07:06 by hbaudet #+# #+# */ 9 | /* Updated: 2021/01/18 16:07:37 by hbaudet ### ########.fr */ 10 | /* */ 11 | /* ************************************************************************** */ 12 | 13 | #include "test_utils.hpp" 14 | #include "VECTOR_UC.HPP" 15 | #include 16 | 17 | #ifndef STD 18 | # define NAMESPACE ft 19 | #else 20 | # define NAMESPACE std 21 | #endif 22 | 23 | using namespace NAMESPACE; 24 | 25 | template 26 | void print(vector >& lst) 27 | { 28 | for (typename vector >::iterator it = lst.begin(); it != lst.end(); it++) 29 | { 30 | for (typename vector::iterator it2 = it->begin(); it2 != it->end(); it2++) 31 | cout << *it2 << ' '; 32 | cout << '\n'; 33 | } 34 | } 35 | 36 | template 37 | void print(vector& lst) 38 | { 39 | for (typename vector::iterator it = lst.begin(); it != lst.end(); it++) 40 | cout << *it << ' '; 41 | cout << '\n'; 42 | } 43 | 44 | 45 | int main () 46 | { 47 | vector myvector; 48 | for (int i=1; i<=5; i++) myvector.push_back(i); 49 | 50 | cout << "myvector contains:"; 51 | for (vector::iterator it = myvector.begin() ; it != myvector.end(); ++it) 52 | cout << ' ' << *it; 53 | cout << '\n'; 54 | 55 | return 0; 56 | } 57 | -------------------------------------------------------------------------------- /VECTOR/mains/end_main.cpp: -------------------------------------------------------------------------------- 1 | /* ************************************************************************** */ 2 | /* */ 3 | /* ::: :::::::: */ 4 | /* end_main.cpp :+: :+: :+: */ 5 | /* +:+ +:+ +:+ */ 6 | /* By: hbaudet +#+ +:+ +#+ */ 7 | /* +#+#+#+#+#+ +#+ */ 8 | /* Created: 2020/12/02 13:07:06 by hbaudet #+# #+# */ 9 | /* Updated: 2021/01/18 16:07:30 by hbaudet ### ########.fr */ 10 | /* */ 11 | /* ************************************************************************** */ 12 | 13 | #include "test_utils.hpp" 14 | #include "VECTOR_UC.HPP" 15 | #include 16 | 17 | #ifndef STD 18 | # define NAMESPACE ft 19 | #else 20 | # define NAMESPACE std 21 | #endif 22 | 23 | using namespace NAMESPACE; 24 | 25 | template 26 | void print(vector >& lst) 27 | { 28 | for (typename vector >::iterator it = lst.begin(); it != lst.end(); it++) 29 | { 30 | for (typename vector::iterator it2 = it->begin(); it2 != it->end(); it2++) 31 | cout << *it2 << ' '; 32 | cout << '\n'; 33 | } 34 | } 35 | 36 | template 37 | void print(vector& lst) 38 | { 39 | for (typename vector::iterator it = lst.begin(); it != lst.end(); it++) 40 | cout << *it << ' '; 41 | cout << '\n'; 42 | } 43 | 44 | 45 | int main () 46 | { 47 | vector myvector; 48 | for (int i=1; i<=5; i++) myvector.push_back(i); 49 | 50 | cout << "myvector contains:"; 51 | for (vector::iterator it = myvector.begin() ; it != myvector.end(); ++it) 52 | cout << ' ' << *it; 53 | cout << '\n'; 54 | 55 | return 0; 56 | } 57 | -------------------------------------------------------------------------------- /DEQUE/mains/begin_main.cpp: -------------------------------------------------------------------------------- 1 | /* ************************************************************************** */ 2 | /* */ 3 | /* ::: :::::::: */ 4 | /* begin_main.cpp :+: :+: :+: */ 5 | /* +:+ +:+ +:+ */ 6 | /* By: hbaudet +#+ +:+ +#+ */ 7 | /* +#+#+#+#+#+ +#+ */ 8 | /* Created: 2020/12/02 13:07:06 by hbaudet #+# #+# */ 9 | /* Updated: 2021/01/18 16:02:23 by hbaudet ### ########.fr */ 10 | /* */ 11 | /* ************************************************************************** */ 12 | 13 | #include "test_utils.hpp" 14 | #include "DEQUE_UC.HPP" 15 | #include 16 | 17 | #ifndef STD 18 | # define NAMESPACE ft 19 | #else 20 | # define NAMESPACE std 21 | #endif 22 | 23 | using namespace NAMESPACE; 24 | 25 | template 26 | void print(deque >& lst) 27 | { 28 | for (typename deque >::iterator it = lst.begin(); it != lst.end(); it++) 29 | { 30 | for (typename deque::iterator it2 = it->begin(); it2 != it->end(); it2++) 31 | cout << *it2 << ' '; 32 | cout << '\n'; 33 | } 34 | } 35 | 36 | template 37 | void print(deque& lst) 38 | { 39 | for (typename deque::iterator it = lst.begin(); it != lst.end(); it++) 40 | cout << *it << ' '; 41 | cout << '\n'; 42 | } 43 | 44 | int main () 45 | { 46 | deque mydeque; 47 | 48 | for (int i=1; i<=5; i++) mydeque.push_back(i); 49 | 50 | cout << "mydeque contains:"; 51 | 52 | deque::iterator it = mydeque.begin(); 53 | 54 | while (it != mydeque.end()) 55 | cout << ' ' << *it++; 56 | 57 | cout << '\n'; 58 | 59 | return 0; 60 | } 61 | -------------------------------------------------------------------------------- /DEQUE/mains/first_main.cpp: -------------------------------------------------------------------------------- 1 | /* ************************************************************************** */ 2 | /* */ 3 | /* ::: :::::::: */ 4 | /* first_main.cpp :+: :+: :+: */ 5 | /* +:+ +:+ +:+ */ 6 | /* By: hbaudet +#+ +:+ +#+ */ 7 | /* +#+#+#+#+#+ +#+ */ 8 | /* Created: 2020/10/19 10:03:48 by hbaudet #+# #+# */ 9 | /* Updated: 2021/01/18 16:02:03 by hbaudet ### ########.fr */ 10 | /* */ 11 | /* ************************************************************************** */ 12 | 13 | #include "test_utils.hpp" 14 | #include "DEQUE_UC.HPP" 15 | #include 16 | 17 | #ifndef STD 18 | # define NAMESPACE ft 19 | #else 20 | # define NAMESPACE std 21 | #endif 22 | 23 | using namespace NAMESPACE; 24 | 25 | int main() 26 | { 27 | // Deque i; 28 | 29 | // i.push_back(5); 30 | 31 | deque li; 32 | deque lst(5, 0); 33 | deque test; 34 | 35 | li.push_back(7); 36 | li.push_back(9); 37 | li.push_back(456); 38 | li.push_back(45); 39 | li.push_back(42); 40 | 41 | deque::iterator it = li.begin(); 42 | deque::iterator ti = li.end(); 43 | 44 | ti--; 45 | ti--; 46 | cout << *(++it) << '\n'; 47 | 48 | 49 | while (*it != 42) 50 | { 51 | if (*it == *ti) 52 | cout << "Reached n - 1 elem\n"; 53 | it++; 54 | } 55 | 56 | 57 | cout << *it << '\n'; 58 | cout << *ti << '\n'; 59 | 60 | li.pop_back(); 61 | cout << *(--(li.end())) << '\n'; 62 | 63 | for (deque::iterator iter = lst.begin(); iter != lst.end(); iter++) 64 | cout << *iter << ' '; 65 | cout << '\n'; 66 | 67 | return 0; 68 | } 69 | -------------------------------------------------------------------------------- /VECTOR/mains/front_main.cpp: -------------------------------------------------------------------------------- 1 | /* ************************************************************************** */ 2 | /* */ 3 | /* ::: :::::::: */ 4 | /* front_main.cpp :+: :+: :+: */ 5 | /* +:+ +:+ +:+ */ 6 | /* By: hbaudet +#+ +:+ +#+ */ 7 | /* +#+#+#+#+#+ +#+ */ 8 | /* Created: 2020/12/02 13:07:06 by hbaudet #+# #+# */ 9 | /* Updated: 2021/01/18 16:07:25 by hbaudet ### ########.fr */ 10 | /* */ 11 | /* ************************************************************************** */ 12 | 13 | #include "test_utils.hpp" 14 | #include "VECTOR_UC.HPP" 15 | #include 16 | 17 | #ifndef STD 18 | # define NAMESPACE ft 19 | #else 20 | # define NAMESPACE std 21 | #endif 22 | 23 | using namespace NAMESPACE; 24 | 25 | template 26 | void print(vector >& lst) 27 | { 28 | for (typename vector >::iterator it = lst.begin(); it != lst.end(); it++) 29 | { 30 | for (typename vector::iterator it2 = it->begin(); it2 != it->end(); it2++) 31 | cout << *it2 << ' '; 32 | cout << '\n'; 33 | } 34 | } 35 | 36 | template 37 | void print(vector& lst) 38 | { 39 | for (typename vector::iterator it = lst.begin(); it != lst.end(); it++) 40 | cout << *it << ' '; 41 | cout << '\n'; 42 | } 43 | 44 | 45 | int main () 46 | { 47 | vector myvector; 48 | 49 | myvector.push_back(78); 50 | myvector.push_back(16); 51 | 52 | // now front equals 78, and back 16 53 | 54 | myvector.front() -= myvector.back(); 55 | 56 | cout << "myvector.front() is now " << myvector.front() << '\n'; 57 | 58 | return 0; 59 | } 60 | -------------------------------------------------------------------------------- /DEQUE/mains/end_main.cpp: -------------------------------------------------------------------------------- 1 | /* ************************************************************************** */ 2 | /* */ 3 | /* ::: :::::::: */ 4 | /* end_main.cpp :+: :+: :+: */ 5 | /* +:+ +:+ +:+ */ 6 | /* By: hbaudet +#+ +:+ +#+ */ 7 | /* +#+#+#+#+#+ +#+ */ 8 | /* Created: 2020/12/02 13:07:06 by hbaudet #+# #+# */ 9 | /* Updated: 2021/01/18 16:02:07 by hbaudet ### ########.fr */ 10 | /* */ 11 | /* ************************************************************************** */ 12 | 13 | #include "test_utils.hpp" 14 | #include "DEQUE_UC.HPP" 15 | #include 16 | 17 | #ifndef STD 18 | # define NAMESPACE ft 19 | #else 20 | # define NAMESPACE std 21 | #endif 22 | 23 | using namespace NAMESPACE; 24 | 25 | template 26 | void print(deque >& lst) 27 | { 28 | for (typename deque >::iterator it = lst.begin(); it != lst.end(); it++) 29 | { 30 | for (typename deque::iterator it2 = it->begin(); it2 != it->end(); it2++) 31 | cout << *it2 << ' '; 32 | cout << '\n'; 33 | } 34 | } 35 | 36 | template 37 | void print(deque& lst) 38 | { 39 | for (typename deque::iterator it = lst.begin(); it != lst.end(); it++) 40 | cout << *it << ' '; 41 | cout << '\n'; 42 | } 43 | 44 | int main () 45 | { 46 | deque mydeque; 47 | 48 | for (int i=1; i<=5; i++) mydeque.insert(mydeque.end(),i); 49 | 50 | cout << "mydeque contains:"; 51 | 52 | deque::iterator it = mydeque.begin(); 53 | 54 | while (it != mydeque.end() ) 55 | cout << ' ' << *it++; 56 | 57 | cout << '\n'; 58 | 59 | return 0; 60 | } 61 | -------------------------------------------------------------------------------- /QUEUE/mains/empty_main.cpp: -------------------------------------------------------------------------------- 1 | /* ************************************************************************** */ 2 | /* */ 3 | /* ::: :::::::: */ 4 | /* empty_main.cpp :+: :+: :+: */ 5 | /* +:+ +:+ +:+ */ 6 | /* By: hbaudet +#+ +:+ +#+ */ 7 | /* +#+#+#+#+#+ +#+ */ 8 | /* Created: 2020/12/02 13:07:06 by hbaudet #+# #+# */ 9 | /* Updated: 2021/01/18 16:41:28 by hbaudet ### ########.fr */ 10 | /* */ 11 | /* ************************************************************************** */ 12 | 13 | #include 14 | #include "test_utils.hpp" 15 | #include "QUEUE_UC.HPP" 16 | #include "LIST_UC.HPP" 17 | 18 | #ifndef STD 19 | # define NAMESPACE ft 20 | #else 21 | # define NAMESPACE std 22 | #endif 23 | 24 | using namespace NAMESPACE; 25 | 26 | template 27 | void print(queue >& lst) 28 | { 29 | for (typename queue >::iterator it = lst.begin(); it != lst.end(); it++) 30 | { 31 | for (typename queue::iterator it2 = it->begin(); it2 != it->end(); it2++) 32 | cout << *it2 << ' '; 33 | cout << '\n'; 34 | } 35 | } 36 | 37 | template 38 | void print(queue& lst) 39 | { 40 | for (typename queue::iterator it = lst.begin(); it != lst.end(); it++) 41 | cout << *it << ' '; 42 | cout << '\n'; 43 | } 44 | 45 | int main () 46 | { 47 | queue myqueue; 48 | int sum (0); 49 | 50 | for (int i=1;i<=10;i++) myqueue.push(i); 51 | 52 | while (!myqueue.empty()) 53 | { 54 | sum += myqueue.front(); 55 | myqueue.pop(); 56 | } 57 | 58 | cout << "total: " << sum << '\n'; 59 | 60 | return 0; 61 | } 62 | -------------------------------------------------------------------------------- /QUEUE/mains/size_main.cpp: -------------------------------------------------------------------------------- 1 | /* ************************************************************************** */ 2 | /* */ 3 | /* ::: :::::::: */ 4 | /* size_main.cpp :+: :+: :+: */ 5 | /* +:+ +:+ +:+ */ 6 | /* By: hbaudet +#+ +:+ +#+ */ 7 | /* +#+#+#+#+#+ +#+ */ 8 | /* Created: 2020/12/02 13:07:06 by hbaudet #+# #+# */ 9 | /* Updated: 2021/01/18 16:42:59 by hbaudet ### ########.fr */ 10 | /* */ 11 | /* ************************************************************************** */ 12 | 13 | #include 14 | #include "test_utils.hpp" 15 | #include "QUEUE_UC.HPP" 16 | #include "LIST_UC.HPP" 17 | 18 | #ifndef STD 19 | # define NAMESPACE ft 20 | #else 21 | # define NAMESPACE std 22 | #endif 23 | 24 | using namespace NAMESPACE; 25 | 26 | template 27 | void print(queue >& lst) 28 | { 29 | for (typename queue >::iterator it = lst.begin(); it != lst.end(); it++) 30 | { 31 | for (typename queue::iterator it2 = it->begin(); it2 != it->end(); it2++) 32 | cout << *it2 << ' '; 33 | cout << '\n'; 34 | } 35 | } 36 | 37 | template 38 | void print(queue& lst) 39 | { 40 | for (typename queue::iterator it = lst.begin(); it != lst.end(); it++) 41 | cout << *it << ' '; 42 | cout << '\n'; 43 | } 44 | 45 | int main () 46 | { 47 | queue myints; 48 | cout << "0. size: " << myints.size() << '\n'; 49 | 50 | for (int i=0; i<5; i++) myints.push(i); 51 | cout << "1. size: " << myints.size() << '\n'; 52 | 53 | myints.pop(); 54 | cout << "2. size: " << myints.size() << '\n'; 55 | 56 | return 0; 57 | } 58 | -------------------------------------------------------------------------------- /VECTOR/mains/empty_main.cpp: -------------------------------------------------------------------------------- 1 | /* ************************************************************************** */ 2 | /* */ 3 | /* ::: :::::::: */ 4 | /* empty_main.cpp :+: :+: :+: */ 5 | /* +:+ +:+ +:+ */ 6 | /* By: hbaudet +#+ +:+ +#+ */ 7 | /* +#+#+#+#+#+ +#+ */ 8 | /* Created: 2020/12/02 13:07:06 by hbaudet #+# #+# */ 9 | /* Updated: 2021/01/18 16:07:31 by hbaudet ### ########.fr */ 10 | /* */ 11 | /* ************************************************************************** */ 12 | 13 | #include "test_utils.hpp" 14 | #include "VECTOR_UC.HPP" 15 | #include 16 | 17 | #ifndef STD 18 | # define NAMESPACE ft 19 | #else 20 | # define NAMESPACE std 21 | #endif 22 | 23 | using namespace NAMESPACE; 24 | 25 | template 26 | void print(vector >& lst) 27 | { 28 | for (typename vector >::iterator it = lst.begin(); it != lst.end(); it++) 29 | { 30 | for (typename vector::iterator it2 = it->begin(); it2 != it->end(); it2++) 31 | cout << *it2 << ' '; 32 | cout << '\n'; 33 | } 34 | } 35 | 36 | template 37 | void print(vector& lst) 38 | { 39 | for (typename vector::iterator it = lst.begin(); it != lst.end(); it++) 40 | cout << *it << ' '; 41 | cout << '\n'; 42 | } 43 | 44 | 45 | int main () 46 | { 47 | vector myvector; 48 | int sum (0); 49 | 50 | for (int i=1;i<=10;i++) myvector.push_back(i); 51 | 52 | while (!myvector.empty()) 53 | { 54 | sum += myvector.back(); 55 | myvector.pop_back(); 56 | } 57 | 58 | cout << "total: " << sum << '\n'; 59 | 60 | return 0; 61 | } 62 | -------------------------------------------------------------------------------- /LIST/mains/pushFront_main.cpp: -------------------------------------------------------------------------------- 1 | /* ************************************************************************** */ 2 | /* */ 3 | /* ::: :::::::: */ 4 | /* pushFront_main.cpp :+: :+: :+: */ 5 | /* +:+ +:+ +:+ */ 6 | /* By: hbaudet +#+ +:+ +#+ */ 7 | /* +#+#+#+#+#+ +#+ */ 8 | /* Created: 2020/12/02 13:07:06 by hbaudet #+# #+# */ 9 | /* Updated: 2021/01/18 16:04:09 by hbaudet ### ########.fr */ 10 | /* */ 11 | /* ************************************************************************** */ 12 | 13 | #include "test_utils.hpp" 14 | #include "LIST_UC.HPP" 15 | #include 16 | 17 | #ifndef STD 18 | # define NAMESPACE ft 19 | #else 20 | # define NAMESPACE std 21 | #endif 22 | 23 | using namespace NAMESPACE; 24 | 25 | template 26 | void print(list >& lst) 27 | { 28 | for (typename list >::iterator it = lst.begin(); it != lst.end(); it++) 29 | { 30 | for (typename list::iterator it2 = it->begin(); it2 != it->end(); it2++) 31 | cout << *it2 << ' '; 32 | cout << '\n'; 33 | } 34 | } 35 | 36 | template 37 | void print(list& lst) 38 | { 39 | for (typename list::iterator it = lst.begin(); it != lst.end(); it++) 40 | cout << *it << ' '; 41 | cout << '\n'; 42 | } 43 | 44 | int main () 45 | { 46 | list mylist (2,100); // two ints with a value of 100 47 | mylist.push_front (200); 48 | mylist.push_front (300); 49 | 50 | cout << "mylist contains:"; 51 | for (list::iterator it=mylist.begin(); it!=mylist.end(); ++it) 52 | cout << ' ' << *it; 53 | 54 | cout << '\n'; 55 | return 0; 56 | } 57 | -------------------------------------------------------------------------------- /LIST/mains/popBack_main.cpp: -------------------------------------------------------------------------------- 1 | /* ************************************************************************** */ 2 | /* */ 3 | /* ::: :::::::: */ 4 | /* popBack_main.cpp :+: :+: :+: */ 5 | /* +:+ +:+ +:+ */ 6 | /* By: hbaudet +#+ +:+ +#+ */ 7 | /* +#+#+#+#+#+ +#+ */ 8 | /* Created: 2020/12/02 13:07:06 by hbaudet #+# #+# */ 9 | /* Updated: 2021/01/18 16:04:13 by hbaudet ### ########.fr */ 10 | /* */ 11 | /* ************************************************************************** */ 12 | 13 | #include "test_utils.hpp" 14 | #include "LIST_UC.HPP" 15 | #include 16 | 17 | #ifndef STD 18 | # define NAMESPACE ft 19 | #else 20 | # define NAMESPACE std 21 | #endif 22 | 23 | using namespace NAMESPACE; 24 | 25 | template 26 | void print(list >& lst) 27 | { 28 | for (typename list >::iterator it = lst.begin(); it != lst.end(); it++) 29 | { 30 | for (typename list::iterator it2 = it->begin(); it2 != it->end(); it2++) 31 | cout << *it2 << ' '; 32 | cout << '\n'; 33 | } 34 | } 35 | 36 | template 37 | void print(list& lst) 38 | { 39 | for (typename list::iterator it = lst.begin(); it != lst.end(); it++) 40 | cout << *it << ' '; 41 | cout << '\n'; 42 | } 43 | 44 | int main () 45 | { 46 | list mylist; 47 | int sum (0); 48 | mylist.push_back (100); 49 | mylist.push_back (200); 50 | mylist.push_back (300); 51 | 52 | while (!mylist.empty()) 53 | { 54 | sum+=mylist.back(); 55 | mylist.pop_back(); 56 | } 57 | 58 | cout << "The elements of mylist summed " << sum << '\n'; 59 | 60 | return 0; 61 | } 62 | -------------------------------------------------------------------------------- /MAP/mains/end_main.cpp: -------------------------------------------------------------------------------- 1 | /* ************************************************************************** */ 2 | /* */ 3 | /* ::: :::::::: */ 4 | /* end_main.cpp :+: :+: :+: */ 5 | /* +:+ +:+ +:+ */ 6 | /* By: hbaudet +#+ +:+ +#+ */ 7 | /* +#+#+#+#+#+ +#+ */ 8 | /* Created: 2020/12/02 13:07:06 by hbaudet #+# #+# */ 9 | /* Updated: 2021/01/18 16:05:25 by hbaudet ### ########.fr */ 10 | /* */ 11 | /* ************************************************************************** */ 12 | 13 | #include "test_utils.hpp" 14 | #include "MAP_UC.HPP" 15 | #include 16 | 17 | #ifndef STD 18 | # define NAMESPACE ft 19 | #else 20 | # define NAMESPACE std 21 | #endif 22 | 23 | using namespace NAMESPACE; 24 | 25 | template 26 | void print(map& lst) 27 | { 28 | for (typename map::iterator it = lst.begin(); it != lst.end(); it++) 29 | cout << it->first << " => " << it->second << '\n'; 30 | } 31 | 32 | int main () 33 | { 34 | map mymap; 35 | 36 | mymap['b'] = 100; 37 | mymap['a'] = 200; 38 | mymap['c'] = 300; 39 | 40 | // show content: 41 | for (map::iterator it=mymap.begin(); it!=mymap.end(); ++it) 42 | cout << it->first << " => " << it->second << '\n'; 43 | 44 | cout << "\n\n========\n\n"; 45 | 46 | 47 | map::iterator it = mymap.end(); 48 | it--; 49 | cout << "end - 1 " << it->first << '\n'; 50 | for (it = --mymap.end(); it!=mymap.begin(); --it) 51 | cout << it->first << " => " << it->second << '\n'; 52 | cout << it->first << " => " << it->second << '\n'; 53 | 54 | return 0; 55 | } 56 | -------------------------------------------------------------------------------- /LIST/mains/operator=_main.cpp: -------------------------------------------------------------------------------- 1 | /* ************************************************************************** */ 2 | /* */ 3 | /* ::: :::::::: */ 4 | /* operator=_main.cpp :+: :+: :+: */ 5 | /* +:+ +:+ +:+ */ 6 | /* By: hbaudet +#+ +:+ +#+ */ 7 | /* +#+#+#+#+#+ +#+ */ 8 | /* Created: 2020/12/02 13:07:06 by hbaudet #+# #+# */ 9 | /* Updated: 2021/01/18 16:04:15 by hbaudet ### ########.fr */ 10 | /* */ 11 | /* ************************************************************************** */ 12 | 13 | #include "test_utils.hpp" 14 | #include "LIST_UC.HPP" 15 | #include 16 | 17 | #ifndef STD 18 | # define NAMESPACE ft 19 | #else 20 | # define NAMESPACE std 21 | #endif 22 | 23 | using namespace NAMESPACE; 24 | 25 | template 26 | void print(list >& lst) 27 | { 28 | for (typename list >::iterator it = lst.begin(); it != lst.end(); it++) 29 | { 30 | for (typename list::iterator it2 = it->begin(); it2 != it->end(); it2++) 31 | cout << *it2 << ' '; 32 | cout << '\n'; 33 | } 34 | } 35 | 36 | template 37 | void print(list& lst) 38 | { 39 | for (typename list::iterator it = lst.begin(); it != lst.end(); it++) 40 | cout << *it << ' '; 41 | cout << '\n'; 42 | } 43 | 44 | int main () 45 | { 46 | list first (3); // list of 3 zero-initialized ints 47 | list second (5); // list of 5 zero-initialized ints 48 | 49 | second = first; 50 | first = list(); 51 | 52 | cout << "Size of first: " << int (first.size()) << '\n'; 53 | cout << "Size of second: " << int (second.size()) << '\n'; 54 | return 0; 55 | } 56 | -------------------------------------------------------------------------------- /DEQUE/mains/pushBack_main.cpp: -------------------------------------------------------------------------------- 1 | /* ************************************************************************** */ 2 | /* */ 3 | /* ::: :::::::: */ 4 | /* pushBack_main.cpp :+: :+: :+: */ 5 | /* +:+ +:+ +:+ */ 6 | /* By: hbaudet +#+ +:+ +#+ */ 7 | /* +#+#+#+#+#+ +#+ */ 8 | /* Created: 2020/12/02 13:07:06 by hbaudet #+# #+# */ 9 | /* Updated: 2021/02/02 13:20:32 by hbaudet ### ########.fr */ 10 | /* */ 11 | /* ************************************************************************** */ 12 | 13 | #include "test_utils.hpp" 14 | #include "DEQUE_UC.HPP" 15 | #include 16 | #include 17 | 18 | #ifndef STD 19 | # define NAMESPACE ft 20 | #else 21 | # define NAMESPACE std 22 | #endif 23 | 24 | using namespace NAMESPACE; 25 | 26 | template 27 | void print(deque >& lst) 28 | { 29 | for (typename deque >::iterator it = lst.begin(); it != lst.end(); it++) 30 | { 31 | for (typename deque::iterator it2 = it->begin(); it2 != it->end(); it2++) 32 | cout << *it2 << ' '; 33 | cout << '\n'; 34 | } 35 | } 36 | 37 | template 38 | void print(deque& lst) 39 | { 40 | for (typename deque::iterator it = lst.begin(); it != lst.end(); it++) 41 | cout << *it << ' '; 42 | cout << '\n'; 43 | } 44 | 45 | int main () 46 | { 47 | deque mydeque; 48 | int myint = 42; 49 | 50 | do { 51 | myint += 4; 52 | myint *= -7; 53 | myint /= 2; 54 | mydeque.push_back (myint); 55 | } while (myint < 10000); 56 | 57 | print (mydeque); 58 | 59 | cout << "mydeque stores " << (int) mydeque.size() << " numbers.\n"; 60 | 61 | return 0; 62 | } -------------------------------------------------------------------------------- /LIST/mains/back_main.cpp: -------------------------------------------------------------------------------- 1 | /* ************************************************************************** */ 2 | /* */ 3 | /* ::: :::::::: */ 4 | /* back_main.cpp :+: :+: :+: */ 5 | /* +:+ +:+ +:+ */ 6 | /* By: hbaudet +#+ +:+ +#+ */ 7 | /* +#+#+#+#+#+ +#+ */ 8 | /* Created: 2020/12/02 13:07:06 by hbaudet #+# #+# */ 9 | /* Updated: 2021/01/18 16:04:38 by hbaudet ### ########.fr */ 10 | /* */ 11 | /* ************************************************************************** */ 12 | 13 | #include "test_utils.hpp" 14 | #include "LIST_UC.HPP" 15 | #include 16 | 17 | #ifndef STD 18 | # define NAMESPACE ft 19 | #else 20 | # define NAMESPACE std 21 | #endif 22 | 23 | using namespace NAMESPACE; 24 | 25 | template 26 | void print(list >& lst) 27 | { 28 | for (typename list >::iterator it = lst.begin(); it != lst.end(); it++) 29 | { 30 | for (typename list::iterator it2 = it->begin(); it2 != it->end(); it2++) 31 | cout << *it2 << ' '; 32 | cout << '\n'; 33 | } 34 | } 35 | 36 | template 37 | void print(list& lst) 38 | { 39 | for (typename list::iterator it = lst.begin(); it != lst.end(); it++) 40 | cout << *it << ' '; 41 | cout << '\n'; 42 | } 43 | 44 | int main () 45 | { 46 | list mylist; 47 | 48 | mylist.push_back(10); 49 | 50 | while (mylist.back() != 0) 51 | { 52 | mylist.push_back ( mylist.back() -1 ); 53 | } 54 | 55 | cout << "mylist contains:"; 56 | for (list::iterator it=mylist.begin(); it!=mylist.end() ; ++it) 57 | cout << ' ' << *it; 58 | 59 | cout << '\n'; 60 | 61 | return 0; 62 | } 63 | -------------------------------------------------------------------------------- /VECTOR/mains/pushBack_main.cpp: -------------------------------------------------------------------------------- 1 | /* ************************************************************************** */ 2 | /* */ 3 | /* ::: :::::::: */ 4 | /* pushBack_main.cpp :+: :+: :+: */ 5 | /* +:+ +:+ +:+ */ 6 | /* By: hbaudet +#+ +:+ +#+ */ 7 | /* +#+#+#+#+#+ +#+ */ 8 | /* Created: 2020/12/02 13:07:06 by hbaudet #+# #+# */ 9 | /* Updated: 2021/01/18 16:07:11 by hbaudet ### ########.fr */ 10 | /* */ 11 | /* ************************************************************************** */ 12 | 13 | #include "test_utils.hpp" 14 | #include "VECTOR_UC.HPP" 15 | #include 16 | 17 | #ifndef STD 18 | # define NAMESPACE ft 19 | #else 20 | # define NAMESPACE std 21 | #endif 22 | 23 | using namespace NAMESPACE; 24 | 25 | template 26 | void print(vector >& lst) 27 | { 28 | for (typename vector >::iterator it = lst.begin(); it != lst.end(); it++) 29 | { 30 | for (typename vector::iterator it2 = it->begin(); it2 != it->end(); it2++) 31 | cout << *it2 << ' '; 32 | cout << '\n'; 33 | } 34 | } 35 | 36 | template 37 | void print(vector& lst) 38 | { 39 | for (typename vector::iterator it = lst.begin(); it != lst.end(); it++) 40 | cout << *it << ' '; 41 | cout << '\n'; 42 | } 43 | 44 | int main () 45 | { 46 | vector myvector; 47 | int myint = 42; 48 | 49 | do { 50 | myint += 5; 51 | myint /= 9; 52 | myint -= 2; 53 | myint *= 42; 54 | myvector.push_back (myint); 55 | } while (myint < 1000000); 56 | 57 | print(myvector); 58 | cout << "myvector stores " << int(myvector.size()) << " numbers.\n"; 59 | 60 | return 0; 61 | } 62 | -------------------------------------------------------------------------------- /DEQUE/mains/back_main.cpp: -------------------------------------------------------------------------------- 1 | /* ************************************************************************** */ 2 | /* */ 3 | /* ::: :::::::: */ 4 | /* back_main.cpp :+: :+: :+: */ 5 | /* +:+ +:+ +:+ */ 6 | /* By: hbaudet +#+ +:+ +#+ */ 7 | /* +#+#+#+#+#+ +#+ */ 8 | /* Created: 2020/12/02 13:07:06 by hbaudet #+# #+# */ 9 | /* Updated: 2021/01/18 16:02:30 by hbaudet ### ########.fr */ 10 | /* */ 11 | /* ************************************************************************** */ 12 | 13 | #include "test_utils.hpp" 14 | #include "DEQUE_UC.HPP" 15 | #include 16 | 17 | #ifndef STD 18 | # define NAMESPACE ft 19 | #else 20 | # define NAMESPACE std 21 | #endif 22 | 23 | using namespace NAMESPACE; 24 | 25 | template 26 | void print(deque >& lst) 27 | { 28 | for (typename deque >::iterator it = lst.begin(); it != lst.end(); it++) 29 | { 30 | for (typename deque::iterator it2 = it->begin(); it2 != it->end(); it2++) 31 | cout << *it2 << ' '; 32 | cout << '\n'; 33 | } 34 | } 35 | 36 | template 37 | void print(deque& lst) 38 | { 39 | for (typename deque::iterator it = lst.begin(); it != lst.end(); it++) 40 | cout << *it << ' '; 41 | cout << '\n'; 42 | } 43 | 44 | int main () 45 | { 46 | deque mydeque; 47 | 48 | mydeque.push_back(10); 49 | 50 | while (mydeque.back() != 0) 51 | mydeque.push_back ( mydeque.back() -1 ); 52 | 53 | cout << "mydeque contains:"; 54 | 55 | for (deque::iterator it = mydeque.begin(); it!=mydeque.end(); ++it) 56 | cout << ' ' << *it; 57 | 58 | cout << '\n'; 59 | 60 | return 0; 61 | } 62 | -------------------------------------------------------------------------------- /DEQUE/mains/pushFront_main.cpp: -------------------------------------------------------------------------------- 1 | /* ************************************************************************** */ 2 | /* */ 3 | /* ::: :::::::: */ 4 | /* pushFront_main.cpp :+: :+: :+: */ 5 | /* +:+ +:+ +:+ */ 6 | /* By: hbaudet +#+ +:+ +#+ */ 7 | /* +#+#+#+#+#+ +#+ */ 8 | /* Created: 2020/12/02 13:07:06 by hbaudet #+# #+# */ 9 | /* Updated: 2021/01/18 16:01:35 by hbaudet ### ########.fr */ 10 | /* */ 11 | /* ************************************************************************** */ 12 | 13 | #include "test_utils.hpp" 14 | #include "DEQUE_UC.HPP" 15 | #include 16 | #include 17 | 18 | #ifndef STD 19 | # define NAMESPACE ft 20 | #else 21 | # define NAMESPACE std 22 | #endif 23 | 24 | using namespace NAMESPACE; 25 | 26 | template 27 | void print(deque >& lst) 28 | { 29 | for (typename deque >::iterator it = lst.begin(); it != lst.end(); it++) 30 | { 31 | for (typename deque::iterator it2 = it->begin(); it2 != it->end(); it2++) 32 | cout << *it2 << ' '; 33 | cout << '\n'; 34 | } 35 | } 36 | 37 | template 38 | void print(deque& lst) 39 | { 40 | for (typename deque::iterator it = lst.begin(); it != lst.end(); it++) 41 | cout << *it << ' '; 42 | cout << '\n'; 43 | } 44 | 45 | int main () 46 | { 47 | deque mydeque (2,100); // two ints with a value of 100 48 | mydeque.push_front (200); 49 | mydeque.push_front (300); 50 | 51 | cout << "mydeque contains:"; 52 | for (deque::iterator it = mydeque.begin(); it != mydeque.end(); ++it) 53 | cout << ' ' << *it; 54 | cout << '\n'; 55 | 56 | return 0; 57 | } 58 | -------------------------------------------------------------------------------- /VECTOR/mains/at_main.cpp: -------------------------------------------------------------------------------- 1 | /* ************************************************************************** */ 2 | /* */ 3 | /* ::: :::::::: */ 4 | /* at_main.cpp :+: :+: :+: */ 5 | /* +:+ +:+ +:+ */ 6 | /* By: hbaudet +#+ +:+ +#+ */ 7 | /* +#+#+#+#+#+ +#+ */ 8 | /* Created: 2020/12/02 13:07:06 by hbaudet #+# #+# */ 9 | /* Updated: 2021/01/18 16:07:40 by hbaudet ### ########.fr */ 10 | /* */ 11 | /* ************************************************************************** */ 12 | 13 | #include "test_utils.hpp" 14 | #include "VECTOR_UC.HPP" 15 | #include 16 | 17 | #ifndef STD 18 | # define NAMESPACE ft 19 | #else 20 | # define NAMESPACE std 21 | #endif 22 | 23 | using namespace NAMESPACE; 24 | 25 | template 26 | void print(vector >& lst) 27 | { 28 | for (typename vector >::iterator it = lst.begin(); it != lst.end(); it++) 29 | { 30 | for (typename vector::iterator it2 = it->begin(); it2 != it->end(); it2++) 31 | cout << *it2 << ' '; 32 | cout << '\n'; 33 | } 34 | } 35 | 36 | template 37 | void print(vector& lst) 38 | { 39 | for (typename vector::iterator it = lst.begin(); it != lst.end(); it++) 40 | cout << *it << ' '; 41 | cout << '\n'; 42 | } 43 | 44 | 45 | int main () 46 | { 47 | vector myvector (10); // 10 zero-initialized ints 48 | 49 | // assign some values: 50 | for (unsigned i=0; i +#+ +:+ +#+ */ 7 | /* +#+#+#+#+#+ +#+ */ 8 | /* Created: 2020/12/02 13:07:06 by hbaudet #+# #+# */ 9 | /* Updated: 2021/01/18 16:07:39 by hbaudet ### ########.fr */ 10 | /* */ 11 | /* ************************************************************************** */ 12 | 13 | #include "test_utils.hpp" 14 | #include "VECTOR_UC.HPP" 15 | #include 16 | 17 | #ifndef STD 18 | # define NAMESPACE ft 19 | #else 20 | # define NAMESPACE std 21 | #endif 22 | 23 | using namespace NAMESPACE; 24 | 25 | template 26 | void print(vector >& lst) 27 | { 28 | for (typename vector >::iterator it = lst.begin(); it != lst.end(); it++) 29 | { 30 | for (typename vector::iterator it2 = it->begin(); it2 != it->end(); it2++) 31 | cout << *it2 << ' '; 32 | cout << '\n'; 33 | } 34 | } 35 | 36 | template 37 | void print(vector& lst) 38 | { 39 | for (typename vector::iterator it = lst.begin(); it != lst.end(); it++) 40 | cout << *it << ' '; 41 | cout << '\n'; 42 | } 43 | 44 | 45 | int main () 46 | { 47 | vector myvector; 48 | 49 | myvector.push_back(10); 50 | 51 | while (myvector.back() != 0) 52 | { 53 | myvector.push_back ( myvector.back() -1 ); 54 | } 55 | 56 | cout << "myvector contains:"; 57 | for (unsigned i=0; i +#+ +:+ +#+ */ 7 | /* +#+#+#+#+#+ +#+ */ 8 | /* Created: 2020/12/02 13:07:06 by hbaudet #+# #+# */ 9 | /* Updated: 2021/01/18 16:01:45 by hbaudet ### ########.fr */ 10 | /* */ 11 | /* ************************************************************************** */ 12 | 13 | #include "test_utils.hpp" 14 | #include "DEQUE_UC.HPP" 15 | #include 16 | #include 17 | 18 | #ifndef STD 19 | # define NAMESPACE ft 20 | #else 21 | # define NAMESPACE std 22 | #endif 23 | 24 | using namespace NAMESPACE; 25 | 26 | template 27 | void print(deque >& lst) 28 | { 29 | for (typename deque >::iterator it = lst.begin(); it != lst.end(); it++) 30 | { 31 | for (typename deque::iterator it2 = it->begin(); it2 != it->end(); it2++) 32 | cout << *it2 << ' '; 33 | cout << '\n'; 34 | } 35 | } 36 | 37 | template 38 | void print(deque& lst) 39 | { 40 | for (typename deque::iterator it = lst.begin(); it != lst.end(); it++) 41 | cout << *it << ' '; 42 | cout << '\n'; 43 | } 44 | 45 | int main () 46 | { 47 | deque first (3); // deque with 3 zero-initialized ints 48 | deque second (5); // deque with 5 zero-initialized ints 49 | 50 | second = first; 51 | first = deque(); 52 | 53 | cout << "Size of first: " << int (first.size()) << '\n'; 54 | cout << "Size of second: " << int (second.size()) << '\n'; 55 | return 0; 56 | } 57 | -------------------------------------------------------------------------------- /DEQUE/mains/popBack_main.cpp: -------------------------------------------------------------------------------- 1 | /* ************************************************************************** */ 2 | /* */ 3 | /* ::: :::::::: */ 4 | /* popBack_main.cpp :+: :+: :+: */ 5 | /* +:+ +:+ +:+ */ 6 | /* By: hbaudet +#+ +:+ +#+ */ 7 | /* +#+#+#+#+#+ +#+ */ 8 | /* Created: 2020/12/02 13:07:06 by hbaudet #+# #+# */ 9 | /* Updated: 2021/01/18 16:01:40 by hbaudet ### ########.fr */ 10 | /* */ 11 | /* ************************************************************************** */ 12 | 13 | #include "test_utils.hpp" 14 | #include "DEQUE_UC.HPP" 15 | #include 16 | #include 17 | 18 | #ifndef STD 19 | # define NAMESPACE ft 20 | #else 21 | # define NAMESPACE std 22 | #endif 23 | 24 | using namespace NAMESPACE; 25 | 26 | template 27 | void print(deque >& lst) 28 | { 29 | for (typename deque >::iterator it = lst.begin(); it != lst.end(); it++) 30 | { 31 | for (typename deque::iterator it2 = it->begin(); it2 != it->end(); it2++) 32 | cout << *it2 << ' '; 33 | cout << '\n'; 34 | } 35 | } 36 | 37 | template 38 | void print(deque& lst) 39 | { 40 | for (typename deque::iterator it = lst.begin(); it != lst.end(); it++) 41 | cout << *it << ' '; 42 | cout << '\n'; 43 | } 44 | 45 | int main () 46 | { 47 | deque mydeque; 48 | int sum (0); 49 | mydeque.push_back (10); 50 | mydeque.push_back (20); 51 | mydeque.push_back (30); 52 | 53 | while (!mydeque.empty()) 54 | { 55 | sum+=mydeque.back(); 56 | mydeque.pop_back(); 57 | } 58 | 59 | cout << "The elements of mydeque add up to " << sum << '\n'; 60 | 61 | return 0; 62 | } 63 | -------------------------------------------------------------------------------- /LIST/mains/resize_main.cpp: -------------------------------------------------------------------------------- 1 | /* ************************************************************************** */ 2 | /* */ 3 | /* ::: :::::::: */ 4 | /* resize_main.cpp :+: :+: :+: */ 5 | /* +:+ +:+ +:+ */ 6 | /* By: hbaudet +#+ +:+ +#+ */ 7 | /* +#+#+#+#+#+ +#+ */ 8 | /* Created: 2020/12/02 13:07:06 by hbaudet #+# #+# */ 9 | /* Updated: 2021/01/18 16:03:57 by hbaudet ### ########.fr */ 10 | /* */ 11 | /* ************************************************************************** */ 12 | 13 | #include "test_utils.hpp" 14 | #include "LIST_UC.HPP" 15 | #include 16 | 17 | #ifndef STD 18 | # define NAMESPACE ft 19 | #else 20 | # define NAMESPACE std 21 | #endif 22 | 23 | using namespace NAMESPACE; 24 | 25 | template 26 | void print(list >& lst) 27 | { 28 | for (typename list >::iterator it = lst.begin(); it != lst.end(); it++) 29 | { 30 | for (typename list::iterator it2 = it->begin(); it2 != it->end(); it2++) 31 | cout << *it2 << ' '; 32 | cout << '\n'; 33 | } 34 | } 35 | 36 | template 37 | void print(list& lst) 38 | { 39 | for (typename list::iterator it = lst.begin(); it != lst.end(); it++) 40 | cout << *it << ' '; 41 | cout << '\n'; 42 | } 43 | 44 | int main () 45 | { 46 | list mylist; 47 | 48 | // set some initial content: 49 | for (int i=1; i<10; ++i) mylist.push_back(i); 50 | 51 | mylist.resize(5); 52 | mylist.resize(8,100); 53 | mylist.resize(12); 54 | 55 | cout << "mylist contains:"; 56 | for (list::iterator it=mylist.begin(); it!=mylist.end(); ++it) 57 | cout << ' ' << *it; 58 | 59 | cout << '\n'; 60 | } 61 | 62 | -------------------------------------------------------------------------------- /VECTOR/mains/popBack_main.cpp: -------------------------------------------------------------------------------- 1 | /* ************************************************************************** */ 2 | /* */ 3 | /* ::: :::::::: */ 4 | /* popBack_main.cpp :+: :+: :+: */ 5 | /* +:+ +:+ +:+ */ 6 | /* By: hbaudet +#+ +:+ +#+ */ 7 | /* +#+#+#+#+#+ +#+ */ 8 | /* Created: 2020/12/02 13:07:06 by hbaudet #+# #+# */ 9 | /* Updated: 2021/01/18 16:07:12 by hbaudet ### ########.fr */ 10 | /* */ 11 | /* ************************************************************************** */ 12 | 13 | #include "test_utils.hpp" 14 | #include "VECTOR_UC.HPP" 15 | #include 16 | 17 | #ifndef STD 18 | # define NAMESPACE ft 19 | #else 20 | # define NAMESPACE std 21 | #endif 22 | 23 | using namespace NAMESPACE; 24 | 25 | template 26 | void print(vector >& lst) 27 | { 28 | for (typename vector >::iterator it = lst.begin(); it != lst.end(); it++) 29 | { 30 | for (typename vector::iterator it2 = it->begin(); it2 != it->end(); it2++) 31 | cout << *it2 << ' '; 32 | cout << '\n'; 33 | } 34 | } 35 | 36 | template 37 | void print(vector& lst) 38 | { 39 | for (typename vector::iterator it = lst.begin(); it != lst.end(); it++) 40 | cout << *it << ' '; 41 | cout << '\n'; 42 | } 43 | 44 | int main () 45 | { 46 | vector myvector; 47 | int sum (0); 48 | myvector.push_back (100); 49 | myvector.push_back (200); 50 | myvector.push_back (300); 51 | 52 | while (!myvector.empty()) 53 | { 54 | sum+=myvector.back(); 55 | myvector.pop_back(); 56 | } 57 | 58 | cout << "The elements of myvector add up to " << sum << '\n'; 59 | 60 | return 0; 61 | } 62 | -------------------------------------------------------------------------------- /VECTOR/mains/.flip_main.cpp: -------------------------------------------------------------------------------- 1 | /* ************************************************************************** */ 2 | /* */ 3 | /* ::: :::::::: */ 4 | /* flip_main.cpp :+: :+: :+: */ 5 | /* +:+ +:+ +:+ */ 6 | /* By: hbaudet +#+ +:+ +#+ */ 7 | /* +#+#+#+#+#+ +#+ */ 8 | /* Created: 2020/12/02 13:07:06 by hbaudet #+# #+# */ 9 | /* Updated: 2021/01/18 16:07:27 by hbaudet ### ########.fr */ 10 | /* */ 11 | /* ************************************************************************** */ 12 | 13 | #include "hbaudet_utils.hpp" 14 | #include "VECTOR_UC.HPP" 15 | #include 16 | 17 | #ifndef STD 18 | # define NAMESPACE ft 19 | #else 20 | # define NAMESPACE std 21 | #endif 22 | 23 | using namespace NAMESPACE; 24 | 25 | template 26 | void print(vector >& lst) 27 | { 28 | for (typename vector >::iterator it = lst.begin(); it != lst.end(); it++) 29 | { 30 | for (typename vector::iterator it2 = it->begin(); it2 != it->end(); it2++) 31 | cout << *it2 << ' '; 32 | cout << '\n'; 33 | } 34 | } 35 | 36 | template 37 | void print(vector& lst) 38 | { 39 | for (typename vector::iterator it = lst.begin(); it != lst.end(); it++) 40 | cout << *it << ' '; 41 | cout << '\n'; 42 | } 43 | 44 | int main () 45 | { 46 | vector mask; 47 | 48 | mask.push_back(true); 49 | mask.push_back(false); 50 | mask.push_back(false); 51 | mask.push_back(true); 52 | 53 | mask.flip(); 54 | 55 | cout << boolalpha; 56 | cout << "mask contains:"; 57 | for (unsigned i=0; i +#+ +:+ +#+ */ 7 | /* +#+#+#+#+#+ +#+ */ 8 | /* Created: 2020/12/02 13:07:06 by hbaudet #+# #+# */ 9 | /* Updated: 2021/01/18 16:04:12 by hbaudet ### ########.fr */ 10 | /* */ 11 | /* ************************************************************************** */ 12 | 13 | #include "test_utils.hpp" 14 | #include "LIST_UC.HPP" 15 | #include 16 | 17 | #ifndef STD 18 | # define NAMESPACE ft 19 | #else 20 | # define NAMESPACE std 21 | #endif 22 | 23 | using namespace NAMESPACE; 24 | 25 | template 26 | void print(list >& lst) 27 | { 28 | for (typename list >::iterator it = lst.begin(); it != lst.end(); it++) 29 | { 30 | for (typename list::iterator it2 = it->begin(); it2 != it->end(); it2++) 31 | cout << *it2 << ' '; 32 | cout << '\n'; 33 | } 34 | } 35 | 36 | template 37 | void print(list& lst) 38 | { 39 | for (typename list::iterator it = lst.begin(); it != lst.end(); it++) 40 | cout << *it << ' '; 41 | cout << '\n'; 42 | } 43 | 44 | int main () 45 | { 46 | list mylist; 47 | mylist.push_back(100); 48 | mylist.push_back(200); 49 | mylist.push_back(300); 50 | 51 | cout << "Popping out the elements in mylist:"; 52 | while (!mylist.empty()) 53 | { 54 | cout << ' ' << mylist.front(); 55 | mylist.pop_front(); 56 | } 57 | 58 | cout << "\nFinal size of mylist is " << mylist.size() << '\n'; 59 | 60 | return 0; 61 | } 62 | -------------------------------------------------------------------------------- /LIST/mains/size_main.cpp: -------------------------------------------------------------------------------- 1 | /* ************************************************************************** */ 2 | /* */ 3 | /* ::: :::::::: */ 4 | /* size_main.cpp :+: :+: :+: */ 5 | /* +:+ +:+ +:+ */ 6 | /* By: hbaudet +#+ +:+ +#+ */ 7 | /* +#+#+#+#+#+ +#+ */ 8 | /* Created: 2020/12/02 13:07:06 by hbaudet #+# #+# */ 9 | /* Updated: 2021/01/18 16:03:50 by hbaudet ### ########.fr */ 10 | /* */ 11 | /* ************************************************************************** */ 12 | 13 | #include "test_utils.hpp" 14 | #include "LIST_UC.HPP" 15 | #include 16 | 17 | #ifndef STD 18 | # define NAMESPACE ft 19 | #else 20 | # define NAMESPACE std 21 | #endif 22 | 23 | using namespace NAMESPACE; 24 | 25 | template 26 | void print(list >& lst) 27 | { 28 | for (typename list >::iterator it = lst.begin(); it != lst.end(); it++) 29 | { 30 | for (typename list::iterator it2 = it->begin(); it2 != it->end(); it2++) 31 | cout << *it2 << ' '; 32 | cout << '\n'; 33 | } 34 | } 35 | 36 | template 37 | void print(list& lst) 38 | { 39 | for (typename list::iterator it = lst.begin(); it != lst.end(); it++) 40 | cout << *it << ' '; 41 | cout << '\n'; 42 | } 43 | 44 | int main () 45 | { 46 | list myints; 47 | cout << "0. size: " << myints.size() << '\n'; 48 | 49 | for (int i=0; i<10; i++) myints.push_back(i); 50 | cout << "1. size: " << myints.size() << '\n'; 51 | 52 | myints.insert (myints.begin(),10,100); 53 | cout << "2. size: " << myints.size() << '\n'; 54 | 55 | myints.pop_back(); 56 | cout << "3. size: " << myints.size() << '\n'; 57 | 58 | return 0; 59 | } 60 | -------------------------------------------------------------------------------- /MAP/mains/lowerBound_main.cpp: -------------------------------------------------------------------------------- 1 | /* ************************************************************************** */ 2 | /* */ 3 | /* ::: :::::::: */ 4 | /* lowerBound_main.cpp :+: :+: :+: */ 5 | /* +:+ +:+ +:+ */ 6 | /* By: hbaudet +#+ +:+ +#+ */ 7 | /* +#+#+#+#+#+ +#+ */ 8 | /* Created: 2020/12/02 13:07:06 by hbaudet #+# #+# */ 9 | /* Updated: 2021/01/18 16:05:17 by hbaudet ### ########.fr */ 10 | /* */ 11 | /* ************************************************************************** */ 12 | 13 | #include "test_utils.hpp" 14 | #include "MAP_UC.HPP" 15 | #include 16 | 17 | #ifndef STD 18 | # define NAMESPACE ft 19 | #else 20 | # define NAMESPACE std 21 | #endif 22 | 23 | using namespace NAMESPACE; 24 | 25 | template 26 | void print(map& lst) 27 | { 28 | for (typename map::iterator it = lst.begin(); it != lst.end(); it++) 29 | cout << it->first << " => " << it->second << '\n'; 30 | } 31 | 32 | int main () 33 | { 34 | map mymap; 35 | map::iterator itlow,itup; 36 | 37 | mymap['a']=20; 38 | mymap['b']=40; 39 | mymap['c']=60; 40 | mymap['d']=80; 41 | mymap['e']=100; 42 | 43 | itlow=mymap.lower_bound ('b'); // itlow points to b 44 | itup=mymap.upper_bound ('d'); // itup points to e (not d!) 45 | 46 | cout << "low : " << itlow->first << '\n'; 47 | cout << "up : " << itup->first << '\n'; 48 | 49 | mymap.erase(itlow,itup); // erases [itlow,itup) 50 | 51 | // print content: 52 | for (map::iterator it=mymap.begin(); it!=mymap.end(); ++it) 53 | cout << it->first << " => " << it->second << '\n'; 54 | 55 | return 0; 56 | } 57 | -------------------------------------------------------------------------------- /VECTOR/mains/maxSize_main.cpp: -------------------------------------------------------------------------------- 1 | /* ************************************************************************** */ 2 | /* */ 3 | /* ::: :::::::: */ 4 | /* maxSize_main.cpp :+: :+: :+: */ 5 | /* +:+ +:+ +:+ */ 6 | /* By: hbaudet +#+ +:+ +#+ */ 7 | /* +#+#+#+#+#+ +#+ */ 8 | /* Created: 2020/12/02 13:07:06 by hbaudet #+# #+# */ 9 | /* Updated: 2021/01/18 16:07:20 by hbaudet ### ########.fr */ 10 | /* */ 11 | /* ************************************************************************** */ 12 | 13 | #include "test_utils.hpp" 14 | #include "VECTOR_UC.HPP" 15 | #include 16 | 17 | #ifndef STD 18 | # define NAMESPACE ft 19 | #else 20 | # define NAMESPACE std 21 | #endif 22 | 23 | using namespace NAMESPACE; 24 | 25 | template 26 | void print(vector >& lst) 27 | { 28 | for (typename vector >::iterator it = lst.begin(); it != lst.end(); it++) 29 | { 30 | for (typename vector::iterator it2 = it->begin(); it2 != it->end(); it2++) 31 | cout << *it2 << ' '; 32 | cout << '\n'; 33 | } 34 | } 35 | 36 | template 37 | void print(vector& lst) 38 | { 39 | for (typename vector::iterator it = lst.begin(); it != lst.end(); it++) 40 | cout << *it << ' '; 41 | cout << '\n'; 42 | } 43 | 44 | 45 | int main () 46 | { 47 | vector myvector; 48 | 49 | // set some content in the vector: 50 | for (int i=0; i<100; i++) myvector.push_back(i); 51 | 52 | cout << "size: " << myvector.size() << "\n"; 53 | if (myvector.capacity() >= myvector.size()) 54 | cout << "capacity is fine\n"; 55 | if (myvector.max_size() > 10000) 56 | cout << "max_size is sufficient\n"; 57 | return 0; 58 | } 59 | -------------------------------------------------------------------------------- /Run_tests.sh: -------------------------------------------------------------------------------- 1 | #!/bin/zsh 2 | 3 | DIR=($(ls)) 4 | CLEAN="" 5 | COUNT=$# 6 | 7 | mkdir -p .INCLUDES/EMPTY/JUST_IN_CASE 2> /dev/null 8 | 9 | for ARG in "$@" 10 | do 11 | if [ "$ARG" = "clean" ] 12 | then 13 | CLEAN="clean" 14 | COUNT=$((COUNT-1)) 15 | break 16 | else 17 | CLEAN="" 18 | fi 19 | #add other options if need 20 | done 21 | 22 | if [ "$CLEAN" != "clean" ] 23 | then 24 | if [ "$(cat .path 2> /dev/null)" = "" ] 25 | then 26 | echo -e "\033[1m\033[34m"'Please enter the path (absolute or relative) to you ft_container repository, with no / at the end por favor' 27 | read PATH_TO_REPO 28 | echo "$PATH_TO_REPO" > .path 29 | echo "Enter your Include path if needed" 30 | read INCLUDE_PATH 31 | echo "$INCLUDE_PATH" > .include_path 32 | else 33 | PATH_TO_REPO="$(cat .path 2> /dev/null)" 34 | INCLUDE_PATH="$(cat .include_path 2> /dev/null)" 35 | fi 36 | cp "$PATH_TO_REPO"/**/*.hpp .INCLUDES 2> /dev/null 37 | for file in .INCLUDES/*.hpp 38 | do 39 | NAME="${file%.*}" 40 | mkdir -p tmp/.INCLUDES 2> /dev/null 41 | cp $file tmp/${NAME:u}_UC.HPP 2> /dev/null 42 | done 43 | mv tmp/.INCLUDES/* .INCLUDES/ 44 | rm -rf tmp 45 | else 46 | rm .include_path .path 2> /dev/null 47 | fi 48 | 49 | for I in "${DIR[@]}" 50 | do 51 | if (( $COUNT > 0 )) 52 | then 53 | CHECK="no" 54 | for ARG in "$@" 55 | do 56 | ARG=${ARG:u} 57 | if [ "$ARG" = "$I" ] 58 | then 59 | CHECK="yes" 60 | break 61 | fi 62 | done 63 | if [ "$CHECK" = "no" ] 64 | then 65 | continue 66 | fi 67 | fi 68 | if [[ -d "$I" ]] && [[ -f .INCLUDES/"$I"_UC.HPP ]] 69 | then 70 | cd "$I" 71 | ../.container_tester.sh "$INCLUDE_PATH" "$CLEAN" #2> /dev/null 72 | cd ../ 73 | else if [[ "$CLEAN" = "clean" ]] && [[ -d "$1" ]] 74 | cd "$I" 2> /dev/null && ../.container_tester.sh 2> /dev/null " " clean && cd ../ 75 | fi 76 | done 77 | 78 | 79 | 80 | if [ "$CLEAN" = "clean" ] 81 | then 82 | rm .path .include_path 2> /dev/null 83 | elif [[ "$OSTYPE" == "darwin"* ]] 84 | then 85 | echo "Valgrind deprecated on MacOS, please check leaks yourself" 86 | fi 87 | rm -rf .INCLUDES 2> /dev/null 88 | -------------------------------------------------------------------------------- /VECTOR/mains/size_main.cpp: -------------------------------------------------------------------------------- 1 | /* ************************************************************************** */ 2 | /* */ 3 | /* ::: :::::::: */ 4 | /* size_main.cpp :+: :+: :+: */ 5 | /* +:+ +:+ +:+ */ 6 | /* By: hbaudet +#+ +:+ +#+ */ 7 | /* +#+#+#+#+#+ +#+ */ 8 | /* Created: 2020/12/02 13:07:06 by hbaudet #+# #+# */ 9 | /* Updated: 2021/01/18 16:07:03 by hbaudet ### ########.fr */ 10 | /* */ 11 | /* ************************************************************************** */ 12 | 13 | #include "test_utils.hpp" 14 | #include "VECTOR_UC.HPP" 15 | #include 16 | 17 | #ifndef STD 18 | # define NAMESPACE ft 19 | #else 20 | # define NAMESPACE std 21 | #endif 22 | 23 | using namespace NAMESPACE; 24 | 25 | template 26 | void print(vector >& lst) 27 | { 28 | for (typename vector >::iterator it = lst.begin(); it != lst.end(); it++) 29 | { 30 | for (typename vector::iterator it2 = it->begin(); it2 != it->end(); it2++) 31 | cout << *it2 << ' '; 32 | cout << '\n'; 33 | } 34 | } 35 | 36 | template 37 | void print(vector& lst) 38 | { 39 | for (typename vector::iterator it = lst.begin(); it != lst.end(); it++) 40 | cout << *it << ' '; 41 | cout << '\n'; 42 | } 43 | 44 | int main () 45 | { 46 | vector myints; 47 | cout << "0. size: " << myints.size() << '\n'; 48 | 49 | for (int i=0; i<10; i++) myints.push_back(i); 50 | cout << "1. size: " << myints.size() << '\n'; 51 | 52 | myints.insert (myints.end(),10,100); 53 | cout << "2. size: " << myints.size() << '\n'; 54 | 55 | myints.pop_back(); 56 | cout << "3. size: " << myints.size() << '\n'; 57 | 58 | return 0; 59 | } 60 | -------------------------------------------------------------------------------- /QUEUE/mains/pop_main.cpp: -------------------------------------------------------------------------------- 1 | /* ************************************************************************** */ 2 | /* */ 3 | /* ::: :::::::: */ 4 | /* pop_main.cpp :+: :+: :+: */ 5 | /* +:+ +:+ +:+ */ 6 | /* By: hbaudet +#+ +:+ +#+ */ 7 | /* +#+#+#+#+#+ +#+ */ 8 | /* Created: 2020/12/02 13:07:06 by hbaudet #+# #+# */ 9 | /* Updated: 2021/01/20 12:30:44 by hbaudet ### ########.fr */ 10 | /* */ 11 | /* ************************************************************************** */ 12 | 13 | #include 14 | #include "test_utils.hpp" 15 | #include "QUEUE_UC.HPP" 16 | #include "LIST_UC.HPP" 17 | 18 | #ifndef STD 19 | # define NAMESPACE ft 20 | #else 21 | # define NAMESPACE std 22 | #endif 23 | 24 | using namespace NAMESPACE; 25 | 26 | template 27 | void print(queue >& lst) 28 | { 29 | for (typename queue >::iterator it = lst.begin(); it != lst.end(); it++) 30 | { 31 | for (typename queue::iterator it2 = it->begin(); it2 != it->end(); it2++) 32 | cout << *it2 << ' '; 33 | cout << '\n'; 34 | } 35 | } 36 | 37 | template 38 | void print(queue& lst) 39 | { 40 | for (typename queue::iterator it = lst.begin(); it != lst.end(); it++) 41 | cout << *it << ' '; 42 | cout << '\n'; 43 | } 44 | 45 | int main () 46 | { 47 | queue myqueue; 48 | int myint = 42; 49 | 50 | do { 51 | myint += 76; 52 | myint /= 3; 53 | myint *= 4; 54 | myqueue.push (myint); 55 | } while (myint < 10000); 56 | 57 | cout << "myqueue contains: "; 58 | while (!myqueue.empty()) 59 | { 60 | cout << ' ' << myqueue.front(); 61 | myqueue.pop(); 62 | } 63 | cout << '\n'; 64 | 65 | return 0; 66 | } 67 | -------------------------------------------------------------------------------- /QUEUE/mains/push_main.cpp: -------------------------------------------------------------------------------- 1 | /* ************************************************************************** */ 2 | /* */ 3 | /* ::: :::::::: */ 4 | /* push_main.cpp :+: :+: :+: */ 5 | /* +:+ +:+ +:+ */ 6 | /* By: hbaudet +#+ +:+ +#+ */ 7 | /* +#+#+#+#+#+ +#+ */ 8 | /* Created: 2020/12/02 13:07:06 by hbaudet #+# #+# */ 9 | /* Updated: 2021/01/20 12:31:26 by hbaudet ### ########.fr */ 10 | /* */ 11 | /* ************************************************************************** */ 12 | 13 | #include 14 | #include "test_utils.hpp" 15 | #include "QUEUE_UC.HPP" 16 | #include "LIST_UC.HPP" 17 | 18 | #ifndef STD 19 | # define NAMESPACE ft 20 | #else 21 | # define NAMESPACE std 22 | #endif 23 | 24 | using namespace NAMESPACE; 25 | 26 | template 27 | void print(queue >& lst) 28 | { 29 | for (typename queue >::iterator it = lst.begin(); it != lst.end(); it++) 30 | { 31 | for (typename queue::iterator it2 = it->begin(); it2 != it->end(); it2++) 32 | cout << *it2 << ' '; 33 | cout << '\n'; 34 | } 35 | } 36 | 37 | template 38 | void print(queue& lst) 39 | { 40 | for (typename queue::iterator it = lst.begin(); it != lst.end(); it++) 41 | cout << *it << ' '; 42 | cout << '\n'; 43 | } 44 | 45 | int main () 46 | { 47 | queue myqueue; 48 | int myint = 42; 49 | 50 | do { 51 | myint += 76; 52 | myint /= 3; 53 | myint *= 4; 54 | myqueue.push (myint); 55 | } while (myint < 10000); 56 | 57 | cout << "myqueue contains: "; 58 | while (!myqueue.empty()) 59 | { 60 | cout << ' ' << myqueue.front(); 61 | myqueue.pop(); 62 | } 63 | cout << '\n'; 64 | 65 | return 0; 66 | } 67 | -------------------------------------------------------------------------------- /DEQUE/mains/size_main.cpp: -------------------------------------------------------------------------------- 1 | /* ************************************************************************** */ 2 | /* */ 3 | /* ::: :::::::: */ 4 | /* size_main.cpp :+: :+: :+: */ 5 | /* +:+ +:+ +:+ */ 6 | /* By: hbaudet +#+ +:+ +#+ */ 7 | /* +#+#+#+#+#+ +#+ */ 8 | /* Created: 2020/12/02 13:07:06 by hbaudet #+# #+# */ 9 | /* Updated: 2021/01/18 16:01:15 by hbaudet ### ########.fr */ 10 | /* */ 11 | /* ************************************************************************** */ 12 | 13 | #include "test_utils.hpp" 14 | #include "DEQUE_UC.HPP" 15 | #include 16 | #include 17 | 18 | #ifndef STD 19 | # define NAMESPACE ft 20 | #else 21 | # define NAMESPACE std 22 | #endif 23 | 24 | using namespace NAMESPACE; 25 | 26 | template 27 | void print(deque >& lst) 28 | { 29 | for (typename deque >::iterator it = lst.begin(); it != lst.end(); it++) 30 | { 31 | for (typename deque::iterator it2 = it->begin(); it2 != it->end(); it2++) 32 | cout << *it2 << ' '; 33 | cout << '\n'; 34 | } 35 | } 36 | 37 | template 38 | void print(deque& lst) 39 | { 40 | for (typename deque::iterator it = lst.begin(); it != lst.end(); it++) 41 | cout << *it << ' '; 42 | cout << '\n'; 43 | } 44 | 45 | int main () 46 | { 47 | deque myints; 48 | cout << "0. size: " << myints.size() << '\n'; 49 | 50 | for (int i=0; i<5; i++) myints.push_back(i); 51 | cout << "1. size: " << myints.size() << '\n'; 52 | 53 | myints.insert (myints.begin(),5,100); 54 | cout << "2. size: " << myints.size() << '\n'; 55 | 56 | myints.pop_back(); 57 | cout << "3. size: " << myints.size() << '\n'; 58 | 59 | return 0; 60 | } 61 | -------------------------------------------------------------------------------- /VECTOR/mains/rbegin_main.cpp: -------------------------------------------------------------------------------- 1 | /* ************************************************************************** */ 2 | /* */ 3 | /* ::: :::::::: */ 4 | /* rbegin_main.cpp :+: :+: :+: */ 5 | /* +:+ +:+ +:+ */ 6 | /* By: hbaudet +#+ +:+ +#+ */ 7 | /* +#+#+#+#+#+ +#+ */ 8 | /* Created: 2020/12/02 13:07:06 by hbaudet #+# #+# */ 9 | /* Updated: 2021/01/18 16:07:10 by hbaudet ### ########.fr */ 10 | /* */ 11 | /* ************************************************************************** */ 12 | 13 | #include "test_utils.hpp" 14 | #include "VECTOR_UC.HPP" 15 | #include 16 | 17 | #ifndef STD 18 | # define NAMESPACE ft 19 | #else 20 | # define NAMESPACE std 21 | #endif 22 | 23 | using namespace NAMESPACE; 24 | 25 | template 26 | void print(vector >& lst) 27 | { 28 | for (typename vector >::iterator it = lst.begin(); it != lst.end(); it++) 29 | { 30 | for (typename vector::iterator it2 = it->begin(); it2 != it->end(); it2++) 31 | cout << *it2 << ' '; 32 | cout << '\n'; 33 | } 34 | } 35 | 36 | template 37 | void print(vector& lst) 38 | { 39 | for (typename vector::iterator it = lst.begin(); it != lst.end(); it++) 40 | cout << *it << ' '; 41 | cout << '\n'; 42 | } 43 | 44 | int main () 45 | { 46 | vector myvector (5); // 5 default-constructed ints 47 | 48 | int i=0; 49 | 50 | vector::reverse_iterator rit = myvector.rbegin(); 51 | for (; rit!= myvector.rend(); ++rit) 52 | *rit = ++i; 53 | 54 | cout << "myvector contains:"; 55 | for (vector::iterator it = myvector.begin(); it != myvector.end(); ++it) 56 | cout << ' ' << *it; 57 | cout << '\n'; 58 | 59 | return 0; 60 | } 61 | -------------------------------------------------------------------------------- /VECTOR/mains/resize_main.cpp: -------------------------------------------------------------------------------- 1 | /* ************************************************************************** */ 2 | /* */ 3 | /* ::: :::::::: */ 4 | /* resize_main.cpp :+: :+: :+: */ 5 | /* +:+ +:+ +:+ */ 6 | /* By: hbaudet +#+ +:+ +#+ */ 7 | /* +#+#+#+#+#+ +#+ */ 8 | /* Created: 2020/12/02 13:07:06 by hbaudet #+# #+# */ 9 | /* Updated: 2021/01/18 16:07:04 by hbaudet ### ########.fr */ 10 | /* */ 11 | /* ************************************************************************** */ 12 | 13 | #include "test_utils.hpp" 14 | #include "VECTOR_UC.HPP" 15 | #include 16 | 17 | #ifndef STD 18 | # define NAMESPACE ft 19 | #else 20 | # define NAMESPACE std 21 | #endif 22 | 23 | using namespace NAMESPACE; 24 | 25 | template 26 | void print(vector >& lst) 27 | { 28 | for (typename vector >::iterator it = lst.begin(); it != lst.end(); it++) 29 | { 30 | for (typename vector::iterator it2 = it->begin(); it2 != it->end(); it2++) 31 | cout << *it2 << ' '; 32 | cout << '\n'; 33 | } 34 | } 35 | 36 | template 37 | void print(vector& lst) 38 | { 39 | for (typename vector::iterator it = lst.begin(); it != lst.end(); it++) 40 | cout << *it << ' '; 41 | cout << '\n'; 42 | } 43 | 44 | int main () 45 | { 46 | vector myvector; 47 | 48 | // set some initial content: 49 | for (vector::size_type i=1;i<10;i++) myvector.push_back(i); 50 | 51 | myvector.resize(5); 52 | myvector.resize(8,100); 53 | myvector.resize(12); 54 | 55 | cout << "myvector contains:"; 56 | for (vector::size_type i=0;i +#+ +:+ +#+ */ 7 | /* +#+#+#+#+#+ +#+ */ 8 | /* Created: 2020/12/02 13:07:06 by hbaudet #+# #+# */ 9 | /* Updated: 2021/01/18 16:01:37 by hbaudet ### ########.fr */ 10 | /* */ 11 | /* ************************************************************************** */ 12 | 13 | #include "test_utils.hpp" 14 | #include "DEQUE_UC.HPP" 15 | #include 16 | #include 17 | 18 | #ifndef STD 19 | # define NAMESPACE ft 20 | #else 21 | # define NAMESPACE std 22 | #endif 23 | 24 | using namespace NAMESPACE; 25 | 26 | template 27 | void print(deque >& lst) 28 | { 29 | for (typename deque >::iterator it = lst.begin(); it != lst.end(); it++) 30 | { 31 | for (typename deque::iterator it2 = it->begin(); it2 != it->end(); it2++) 32 | cout << *it2 << ' '; 33 | cout << '\n'; 34 | } 35 | } 36 | 37 | template 38 | void print(deque& lst) 39 | { 40 | for (typename deque::iterator it = lst.begin(); it != lst.end(); it++) 41 | cout << *it << ' '; 42 | cout << '\n'; 43 | } 44 | 45 | int main () 46 | { 47 | deque mydeque; 48 | 49 | mydeque.push_back (100); 50 | mydeque.push_back (200); 51 | mydeque.push_back (300); 52 | 53 | cout << "Popping out the elements in mydeque:"; 54 | while (!mydeque.empty()) 55 | { 56 | cout << ' ' << mydeque.front(); 57 | mydeque.pop_front(); 58 | } 59 | 60 | cout << "\nThe final size of mydeque is " << int(mydeque.size()) << '\n'; 61 | 62 | return 0; 63 | } 64 | -------------------------------------------------------------------------------- /VECTOR/mains/rend_main.cpp: -------------------------------------------------------------------------------- 1 | /* ************************************************************************** */ 2 | /* */ 3 | /* ::: :::::::: */ 4 | /* rend_main.cpp :+: :+: :+: */ 5 | /* +:+ +:+ +:+ */ 6 | /* By: hbaudet +#+ +:+ +#+ */ 7 | /* +#+#+#+#+#+ +#+ */ 8 | /* Created: 2020/12/02 13:07:06 by hbaudet #+# #+# */ 9 | /* Updated: 2021/01/18 16:07:07 by hbaudet ### ########.fr */ 10 | /* */ 11 | /* ************************************************************************** */ 12 | 13 | #include "test_utils.hpp" 14 | #include "VECTOR_UC.HPP" 15 | #include 16 | 17 | #ifndef STD 18 | # define NAMESPACE ft 19 | #else 20 | # define NAMESPACE std 21 | #endif 22 | 23 | using namespace NAMESPACE; 24 | 25 | template 26 | void print(vector >& lst) 27 | { 28 | for (typename vector >::iterator it = lst.begin(); it != lst.end(); it++) 29 | { 30 | for (typename vector::iterator it2 = it->begin(); it2 != it->end(); it2++) 31 | cout << *it2 << ' '; 32 | cout << '\n'; 33 | } 34 | } 35 | 36 | template 37 | void print(vector& lst) 38 | { 39 | for (typename vector::iterator it = lst.begin(); it != lst.end(); it++) 40 | cout << *it << ' '; 41 | cout << '\n'; 42 | } 43 | 44 | int main () 45 | { 46 | vector myvector (5); // 5 default-constructed ints 47 | 48 | vector::reverse_iterator rit = myvector.rbegin(); 49 | 50 | int i=0; 51 | for (rit = myvector.rbegin(); rit!= myvector.rend(); ++rit) 52 | *rit = ++i; 53 | 54 | cout << "myvector contains:"; 55 | for (vector::iterator it = myvector.begin(); it != myvector.end(); ++it) 56 | cout << ' ' << *it; 57 | cout << '\n'; 58 | 59 | return 0; 60 | } 61 | -------------------------------------------------------------------------------- /DEQUE/mains/rbegin_main.cpp: -------------------------------------------------------------------------------- 1 | /* ************************************************************************** */ 2 | /* */ 3 | /* ::: :::::::: */ 4 | /* rbegin_main.cpp :+: :+: :+: */ 5 | /* +:+ +:+ +:+ */ 6 | /* By: hbaudet +#+ +:+ +#+ */ 7 | /* +#+#+#+#+#+ +#+ */ 8 | /* Created: 2020/12/02 13:07:06 by hbaudet #+# #+# */ 9 | /* Updated: 2021/01/18 16:01:34 by hbaudet ### ########.fr */ 10 | /* */ 11 | /* ************************************************************************** */ 12 | 13 | #include "test_utils.hpp" 14 | #include "DEQUE_UC.HPP" 15 | #include 16 | #include 17 | 18 | #ifndef STD 19 | # define NAMESPACE ft 20 | #else 21 | # define NAMESPACE std 22 | #endif 23 | 24 | using namespace NAMESPACE; 25 | 26 | template 27 | void print(deque >& lst) 28 | { 29 | for (typename deque >::iterator it = lst.begin(); it != lst.end(); it++) 30 | { 31 | for (typename deque::iterator it2 = it->begin(); it2 != it->end(); it2++) 32 | cout << *it2 << ' '; 33 | cout << '\n'; 34 | } 35 | } 36 | 37 | template 38 | void print(deque& lst) 39 | { 40 | for (typename deque::iterator it = lst.begin(); it != lst.end(); it++) 41 | cout << *it << ' '; 42 | cout << '\n'; 43 | } 44 | 45 | int main () 46 | { 47 | deque mydeque (5); // 5 default-constructed ints 48 | 49 | deque::reverse_iterator rit = mydeque.rbegin(); 50 | 51 | int i=0; 52 | for (rit = mydeque.rbegin(); rit!= mydeque.rend(); ++rit) 53 | *rit = ++i; 54 | 55 | cout << "mydeque contains:"; 56 | for (deque::iterator it = mydeque.begin(); it != mydeque.end(); ++it) 57 | cout << ' ' << *it; 58 | cout << '\n'; 59 | 60 | return 0; 61 | } 62 | -------------------------------------------------------------------------------- /DEQUE/mains/rend_main.cpp: -------------------------------------------------------------------------------- 1 | /* ************************************************************************** */ 2 | /* */ 3 | /* ::: :::::::: */ 4 | /* rend_main.cpp :+: :+: :+: */ 5 | /* +:+ +:+ +:+ */ 6 | /* By: hbaudet +#+ +:+ +#+ */ 7 | /* +#+#+#+#+#+ +#+ */ 8 | /* Created: 2020/12/02 13:07:06 by hbaudet #+# #+# */ 9 | /* Updated: 2021/01/18 16:03:08 by hbaudet ### ########.fr */ 10 | /* */ 11 | /* ************************************************************************** */ 12 | 13 | #include "test_utils.hpp" 14 | #include "DEQUE_UC.HPP" 15 | #include 16 | #include 17 | 18 | #ifndef STD 19 | # define NAMESPACE ft 20 | #else 21 | # define NAMESPACE std 22 | #endif 23 | 24 | using namespace NAMESPACE; 25 | 26 | template 27 | void print(deque >& lst) 28 | { 29 | for (typename deque >::iterator it = lst.begin(); it != lst.end(); it++) 30 | { 31 | for (typename deque::iterator it2 = it->begin(); it2 != it->end(); it2++) 32 | cout << *it2 << ' '; 33 | cout << '\n'; 34 | } 35 | } 36 | 37 | template 38 | void print(deque& lst) 39 | { 40 | for (typename deque::iterator it = lst.begin(); it != lst.end(); it++) 41 | cout << *it << ' '; 42 | cout << '\n'; 43 | } 44 | 45 | int main () 46 | { 47 | deque mydeque (5); // 5 default-constructed ints 48 | 49 | deque::reverse_iterator rit = mydeque.rbegin(); 50 | 51 | int i=0; 52 | for (rit = mydeque.rbegin(); rit!= mydeque.rend(); ++rit) 53 | *rit = ++i; 54 | 55 | cout << "mydeque contains:"; 56 | for (deque::iterator it = mydeque.begin(); it != mydeque.end(); ++it) 57 | cout << ' ' << *it; 58 | cout << '\n'; 59 | 60 | return 0; 61 | } 62 | -------------------------------------------------------------------------------- /DEQUE/mains/resize_main.cpp: -------------------------------------------------------------------------------- 1 | /* ************************************************************************** */ 2 | /* */ 3 | /* ::: :::::::: */ 4 | /* resize_main.cpp :+: :+: :+: */ 5 | /* +:+ +:+ +:+ */ 6 | /* By: hbaudet +#+ +:+ +#+ */ 7 | /* +#+#+#+#+#+ +#+ */ 8 | /* Created: 2020/12/02 13:07:06 by hbaudet #+# #+# */ 9 | /* Updated: 2021/01/18 16:01:24 by hbaudet ### ########.fr */ 10 | /* */ 11 | /* ************************************************************************** */ 12 | 13 | #include "test_utils.hpp" 14 | #include "DEQUE_UC.HPP" 15 | #include 16 | #include 17 | 18 | #ifndef STD 19 | # define NAMESPACE ft 20 | #else 21 | # define NAMESPACE std 22 | #endif 23 | 24 | using namespace NAMESPACE; 25 | 26 | template 27 | void print(deque >& lst) 28 | { 29 | for (typename deque >::iterator it = lst.begin(); it != lst.end(); it++) 30 | { 31 | for (typename deque::iterator it2 = it->begin(); it2 != it->end(); it2++) 32 | cout << *it2 << ' '; 33 | cout << '\n'; 34 | } 35 | } 36 | 37 | template 38 | void print(deque& lst) 39 | { 40 | for (typename deque::iterator it = lst.begin(); it != lst.end(); it++) 41 | cout << *it << ' '; 42 | cout << '\n'; 43 | } 44 | 45 | int main () 46 | { 47 | deque mydeque; 48 | deque::iterator it; 49 | 50 | // set some initial content: 51 | for (int i=1; i<10; ++i) mydeque.push_back(i); 52 | 53 | mydeque.resize(5); 54 | mydeque.resize(8,100); 55 | mydeque.resize(12); 56 | 57 | cout << "mydeque contains:"; 58 | for (deque::iterator it = mydeque.begin(); it != mydeque.end(); ++it) 59 | cout << ' ' << *it; 60 | cout << '\n'; 61 | 62 | return 0; 63 | } 64 | -------------------------------------------------------------------------------- /VECTOR/mains/capacity_main.cpp: -------------------------------------------------------------------------------- 1 | /* ************************************************************************** */ 2 | /* */ 3 | /* ::: :::::::: */ 4 | /* capacity_main.cpp :+: :+: :+: */ 5 | /* +:+ +:+ +:+ */ 6 | /* By: hbaudet +#+ +:+ +#+ */ 7 | /* +#+#+#+#+#+ +#+ */ 8 | /* Created: 2020/12/02 13:07:06 by hbaudet #+# #+# */ 9 | /* Updated: 2021/01/18 16:07:34 by hbaudet ### ########.fr */ 10 | /* */ 11 | /* ************************************************************************** */ 12 | 13 | #include "test_utils.hpp" 14 | #include "VECTOR_UC.HPP" 15 | #include 16 | 17 | #ifndef STD 18 | # define NAMESPACE ft 19 | #else 20 | # define NAMESPACE std 21 | #endif 22 | 23 | using namespace NAMESPACE; 24 | 25 | template 26 | void print(vector >& lst) 27 | { 28 | for (typename vector >::iterator it = lst.begin(); it != lst.end(); it++) 29 | { 30 | for (typename vector::iterator it2 = it->begin(); it2 != it->end(); it2++) 31 | cout << *it2 << ' '; 32 | cout << '\n'; 33 | } 34 | } 35 | 36 | template 37 | void print(vector& lst) 38 | { 39 | for (typename vector::iterator it = lst.begin(); it != lst.end(); it++) 40 | cout << *it << ' '; 41 | cout << '\n'; 42 | } 43 | 44 | 45 | int main () 46 | { 47 | vector myvector; 48 | 49 | // set some content in the vector: 50 | for (int i=0; i<100; i++) myvector.push_back(i); 51 | 52 | cout << "size: " << (int) myvector.size() << '\n'; 53 | if (myvector.capacity() >= myvector.size()) 54 | cout << "capacity: is fine\n"; 55 | else 56 | cout << "capcity is not fine : " << myvector.capacity() << '\n'; 57 | if (myvector.max_size() > 10000) 58 | cout << "max_size is fine\n"; 59 | return 0; 60 | } 61 | -------------------------------------------------------------------------------- /DEQUE/mains/erase_main.cpp: -------------------------------------------------------------------------------- 1 | /* ************************************************************************** */ 2 | /* */ 3 | /* ::: :::::::: */ 4 | /* erase_main.cpp :+: :+: :+: */ 5 | /* +:+ +:+ +:+ */ 6 | /* By: hbaudet +#+ +:+ +#+ */ 7 | /* +#+#+#+#+#+ +#+ */ 8 | /* Created: 2020/12/02 13:07:06 by hbaudet #+# #+# */ 9 | /* Updated: 2021/01/18 16:02:05 by hbaudet ### ########.fr */ 10 | /* */ 11 | /* ************************************************************************** */ 12 | 13 | #include "test_utils.hpp" 14 | #include "DEQUE_UC.HPP" 15 | #include 16 | 17 | #ifndef STD 18 | # define NAMESPACE ft 19 | #else 20 | # define NAMESPACE std 21 | #endif 22 | 23 | using namespace NAMESPACE; 24 | 25 | template 26 | void print(deque >& lst) 27 | { 28 | for (typename deque >::iterator it = lst.begin(); it != lst.end(); it++) 29 | { 30 | for (typename deque::iterator it2 = it->begin(); it2 != it->end(); it2++) 31 | cout << *it2 << ' '; 32 | cout << '\n'; 33 | } 34 | } 35 | 36 | template 37 | void print(deque& lst) 38 | { 39 | for (typename deque::iterator it = lst.begin(); it != lst.end(); it++) 40 | cout << *it << ' '; 41 | cout << '\n'; 42 | } 43 | 44 | int main () 45 | { 46 | deque mydeque; 47 | 48 | // set some values (from 1 to 10) 49 | for (int i=1; i<=10; i++) mydeque.push_back(i); 50 | 51 | // erase the 6th element 52 | mydeque.erase (mydeque.begin()+5); 53 | 54 | // erase the first 3 elements: 55 | mydeque.erase (mydeque.begin(),mydeque.begin()+3); 56 | 57 | cout << "mydeque contains:"; 58 | for (deque::iterator it = mydeque.begin(); it!=mydeque.end(); ++it) 59 | cout << ' ' << *it; 60 | cout << '\n'; 61 | 62 | return 0; 63 | } 64 | --------------------------------------------------------------------------------