diff --git a/builds_ft/main.d b/builds_ft/main.d deleted file mode 100644 index fc59dad..0000000 --- a/builds_ft/main.d +++ /dev/null @@ -1,8 +0,0 @@ -builds_ft/main.o: tests/main.cpp tests/includes/main.hpp headers/colors.h \ - tests/includes/tests_structs.hpp - -tests/includes/main.hpp: - -headers/colors.h: - -tests/includes/tests_structs.hpp: diff --git a/builds_ft/tests_definitions.d b/builds_ft/tests_definitions.d deleted file mode 100644 index a1e24c3..0000000 --- a/builds_ft/tests_definitions.d +++ /dev/null @@ -1,9 +0,0 @@ -builds_ft/tests_definitions.o: tests/tests_definitions.cpp \ - tests/includes/tests_utils.hpp headers/colors.h \ - tests/includes/tests_structs.hpp - -tests/includes/tests_utils.hpp: - -headers/colors.h: - -tests/includes/tests_structs.hpp: diff --git a/builds_ft/tests_map.d b/builds_ft/tests_map.d deleted file mode 100644 index 6d6cbc0..0000000 --- a/builds_ft/tests_map.d +++ /dev/null @@ -1,32 +0,0 @@ -builds_ft/tests_map.o: tests/tests_map.cpp tests/includes/tests_map.hpp \ - tests/includes/tests_utils.hpp headers/colors.h \ - tests/includes/tests_structs.hpp headers/map.hpp \ - headers/reverse_iterator.hpp headers/iterator_traits.hpp \ - headers/equal.hpp headers/lexicographical_compare.hpp headers/pair.hpp \ - headers/map_node.hpp headers/map_iterator.hpp templates/map.tpp - -tests/includes/tests_map.hpp: - -tests/includes/tests_utils.hpp: - -headers/colors.h: - -tests/includes/tests_structs.hpp: - -headers/map.hpp: - -headers/reverse_iterator.hpp: - -headers/iterator_traits.hpp: - -headers/equal.hpp: - -headers/lexicographical_compare.hpp: - -headers/pair.hpp: - -headers/map_node.hpp: - -headers/map_iterator.hpp: - -templates/map.tpp: diff --git a/builds_ft/tests_stack.d b/builds_ft/tests_stack.d deleted file mode 100644 index df53f05..0000000 --- a/builds_ft/tests_stack.d +++ /dev/null @@ -1,33 +0,0 @@ -builds_ft/tests_stack.o: tests/tests_stack.cpp \ - tests/includes/tests_stack.hpp tests/includes/tests_utils.hpp \ - headers/colors.h tests/includes/tests_structs.hpp headers/stack.hpp \ - headers/vector.hpp headers/enable_if.hpp headers/is_integral.hpp \ - headers/reverse_iterator.hpp headers/iterator_traits.hpp \ - headers/equal.hpp headers/lexicographical_compare.hpp \ - templates/vector.tpp - -tests/includes/tests_stack.hpp: - -tests/includes/tests_utils.hpp: - -headers/colors.h: - -tests/includes/tests_structs.hpp: - -headers/stack.hpp: - -headers/vector.hpp: - -headers/enable_if.hpp: - -headers/is_integral.hpp: - -headers/reverse_iterator.hpp: - -headers/iterator_traits.hpp: - -headers/equal.hpp: - -headers/lexicographical_compare.hpp: - -templates/vector.tpp: diff --git a/builds_ft/tests_vector.d b/builds_ft/tests_vector.d deleted file mode 100644 index b039a21..0000000 --- a/builds_ft/tests_vector.d +++ /dev/null @@ -1,31 +0,0 @@ -builds_ft/tests_vector.o: tests/tests_vector.cpp \ - tests/includes/tests_vector.hpp tests/includes/tests_utils.hpp \ - headers/colors.h tests/includes/tests_structs.hpp headers/vector.hpp \ - headers/enable_if.hpp headers/is_integral.hpp \ - headers/reverse_iterator.hpp headers/iterator_traits.hpp \ - headers/equal.hpp headers/lexicographical_compare.hpp \ - templates/vector.tpp - -tests/includes/tests_vector.hpp: - -tests/includes/tests_utils.hpp: - -headers/colors.h: - -tests/includes/tests_structs.hpp: - -headers/vector.hpp: - -headers/enable_if.hpp: - -headers/is_integral.hpp: - -headers/reverse_iterator.hpp: - -headers/iterator_traits.hpp: - -headers/equal.hpp: - -headers/lexicographical_compare.hpp: - -templates/vector.tpp: diff --git a/builds_stl/main.d b/builds_stl/main.d deleted file mode 100644 index 8ebc62c..0000000 --- a/builds_stl/main.d +++ /dev/null @@ -1,8 +0,0 @@ -builds_stl/main.o: tests/main.cpp tests/includes/main.hpp \ - headers/colors.h tests/includes/tests_structs.hpp - -tests/includes/main.hpp: - -headers/colors.h: - -tests/includes/tests_structs.hpp: diff --git a/builds_stl/tests_definitions.d b/builds_stl/tests_definitions.d deleted file mode 100644 index 14f3ebd..0000000 --- a/builds_stl/tests_definitions.d +++ /dev/null @@ -1,9 +0,0 @@ -builds_stl/tests_definitions.o: tests/tests_definitions.cpp \ - tests/includes/tests_utils.hpp headers/colors.h \ - tests/includes/tests_structs.hpp - -tests/includes/tests_utils.hpp: - -headers/colors.h: - -tests/includes/tests_structs.hpp: diff --git a/builds_stl/tests_map.d b/builds_stl/tests_map.d deleted file mode 100644 index 1c3d938..0000000 --- a/builds_stl/tests_map.d +++ /dev/null @@ -1,11 +0,0 @@ -builds_stl/tests_map.o: tests/tests_map.cpp tests/includes/tests_map.hpp \ - tests/includes/tests_utils.hpp headers/colors.h \ - tests/includes/tests_structs.hpp - -tests/includes/tests_map.hpp: - -tests/includes/tests_utils.hpp: - -headers/colors.h: - -tests/includes/tests_structs.hpp: diff --git a/builds_stl/tests_stack.d b/builds_stl/tests_stack.d deleted file mode 100644 index d245304..0000000 --- a/builds_stl/tests_stack.d +++ /dev/null @@ -1,11 +0,0 @@ -builds_stl/tests_stack.o: tests/tests_stack.cpp \ - tests/includes/tests_stack.hpp tests/includes/tests_utils.hpp \ - headers/colors.h tests/includes/tests_structs.hpp - -tests/includes/tests_stack.hpp: - -tests/includes/tests_utils.hpp: - -headers/colors.h: - -tests/includes/tests_structs.hpp: diff --git a/builds_stl/tests_vector.d b/builds_stl/tests_vector.d deleted file mode 100644 index 6997635..0000000 --- a/builds_stl/tests_vector.d +++ /dev/null @@ -1,11 +0,0 @@ -builds_stl/tests_vector.o: tests/tests_vector.cpp \ - tests/includes/tests_vector.hpp tests/includes/tests_utils.hpp \ - headers/colors.h tests/includes/tests_structs.hpp - -tests/includes/tests_vector.hpp: - -tests/includes/tests_utils.hpp: - -headers/colors.h: - -tests/includes/tests_structs.hpp: diff --git a/containers_ft b/containers_ft deleted file mode 100755 index a72348c..0000000 Binary files a/containers_ft and /dev/null differ diff --git a/containers_stl b/containers_stl deleted file mode 100755 index f814a0f..0000000 Binary files a/containers_stl and /dev/null differ diff --git a/headers/bak__bst.hpp b/headers/bak__bst.hpp deleted file mode 100644 index a79e8cb..0000000 --- a/headers/bak__bst.hpp +++ /dev/null @@ -1,187 +0,0 @@ -#ifndef BST_HPP -# define BST_HPP - -# include // std::allocator -# include // NULL, size_t, ptrdiff_t -# include // max() -# include // std::less() - -# include "reverse_iterator.hpp" -# include "equal.hpp" -# include "lexicographical_compare.hpp" - -# include "pair.hpp" -# include "bst_node.hpp" -# include "bst_iterator.hpp" - -namespace ft { - -template < - typename Key, - typename T, - typename Compare = std::less, - typename Allocator = std::allocator< ft::pair > -> class Bst { - -public: - typedef Key key_type; - typedef T mapped_type; - typedef pair value_type; - typedef Compare key_compare; - typedef Allocator allocator_type; - typedef std::size_t size_type; - typedef std::ptrdiff_t difference_type; - - typedef Bst_iterator iterator; - typedef Bst_const_iterator const_iterator; - typedef ft::reverse_iterator reverse_iterator; - typedef ft::reverse_iterator const_reverse_iterator; - - - /************ - * copliens : - ************/ -// constructors ------------------------------ - explicit Bst( - const key_compare& comp = Compare(), - const Allocator& alloc = Allocator() - ); - template < typename InputIt > - Bst( - InputIt first, InputIt last, - const key_compare& comp = Compare(), - const allocator_type& alloc = Allocator() - ); - Bst(const Bst& src); -// destructor -------------------------------- - ~Bst(); -// operator= --------------------------------- - Bst& operator=(const Bst& rhs); - - - /************* - * iterators : - *************/ -// begin ------------------------------------- - iterator begin(); - const_iterator begin() const; -// end --------------------------------------- - iterator end(); - const_iterator end() const; -// rbegin ------------------------------------ - reverse_iterator rbegin(); - const_reverse_iterator rbegin() const; -// rend -------------------------------------- - reverse_iterator rend(); - const_reverse_iterator rend() const; - - - /************ - * capacity : - ************/ -// empty ------------------------------------- - bool empty() const; -// size -------------------------------------- - size_type size() const; -// max_size ---------------------------------- - size_type max_size() const; - - - /****************** - * element access : - ******************/ -// operator[] -------------------------------- - mapped_type& operator[](const key_type& key); - - - /************* - * modifiers : - *************/ -// insert ------------------------------------ - pair insert(const value_type& value); - iterator insert(iterator hint, const value_type& value); - template < typename InputIt > - void insert(InputIt first, InputIt last); -// erase ------------------------------------- - void erase(iterator pos); - size_type erase(const key_type& key); - void erase(iterator first, iterator last); -// swap -------------------------------------- - void swap(Bst& other); -// clear ------------------------------------- - void clear(); - - /************** - * operations : - **************/ -// find -------------------------------------- - iterator find(const key_type& key); - const_iterator find(const key_type& key) const; -// count ------------------------------------- - size_type count(const key_type& key) const; - -private: - size_type _size; - node* _root; - node_sentinel* _sentinel; - Compare _comp; - Allocator _allocator; - - // https://stackoverflow.com/questions/14148756/what-does-template-rebind-do - typename Allocator::template - rebind< node >::other _allocator_node; - typename Allocator::template - rebind< node_sentinel >::other _allocator_node_sentinel; - - void _init_sentinel(); - pair _insert(const value_type& value); - node* _erase(iterator pos); - node* _subtree_shift( - node* st_old, - node* st_new - ); - - // BBST - // https://www.youtube.com/watch?v=vRwi_UcZGjU - void _insert_rebalancing(node* n); - void _erase_rebalancing(node* n); - - short _compute_height(node* n); - short _balance_factor(node* n); - node* _rotate_left(node* n); - node* _rotate_right(node* n); - }; - - // Non-member functions - template < typename Key, typename T, typename Compare, typename Alloc > - bool operator==(const Bst& lhs, const Bst& rhs); - template < typename Key, typename T, typename Compare, typename Alloc > - bool operator!=(const Bst& lhs, const Bst& rhs); - template < typename Key, typename T, typename Compare, typename Alloc > - bool operator<(const Bst& lhs, const Bst& rhs); - template < typename Key, typename T, typename Compare, typename Alloc > - bool operator>(const Bst& lhs, const Bst& rhs); - template < typename Key, typename T, typename Compare, typename Alloc > - bool operator<=(const Bst& lhs, const Bst& rhs); - template < typename Key, typename T, typename Compare, typename Alloc > - bool operator>=(const Bst& lhs, const Bst& rhs); - - template < typename Key, typename T, typename Compare, typename Alloc > - void swap(Bst& lhs, Bst& rhs); - -} // namespace ft - -# include "bst.tpp" - -// https://en.wikipedia.org/wiki/Binary_search_tree -// https://en.wikipedia.org/wiki/AVL_tree - -// https://fr.wikipedia.org/wiki/Arbre_binaire_de_recherche -// https://fr.wikipedia.org/wiki/Arbre_AVL - -// https://visualgo.net/en/bst -// https://visualgo.net/en/bst?slide=14-8 // --> to 14-13 - - -#endif - diff --git a/headers/bak__bst_iterator.hpp b/headers/bak__bst_iterator.hpp deleted file mode 100644 index 077f601..0000000 --- a/headers/bak__bst_iterator.hpp +++ /dev/null @@ -1,207 +0,0 @@ -#ifndef BST_ITERATOR_HPP -# define BST_ITERATOR_HPP - -# include // NULL, ptrdiff_t -# include // iterator_tag - -# include "pair.hpp" -# include "bst_node.hpp" - -namespace ft { - -template < - typename Key, - typename T, - typename Compare, - typename Allocator -> class Bst_iterator -{ - private: - typedef Bst_iterator Self; - - public: - typedef std::bidirectional_iterator_tag iterator_category; - typedef pair value_type; - typedef std::ptrdiff_t difference_type; - typedef value_type* pointer; - typedef value_type& reference; - - Bst_iterator() : _node(), _sentinel() {} - Bst_iterator(node* n, node_sentinel* sentinel) : _node(n), _sentinel(sentinel) {} - //Bst_iterator(const Bst_iterator& src) : _node(src._node), _sentinel(src._sentinel) {} //implicit - - reference operator*() const - { return _node->value; } - pointer operator->() const - { return &_node->value; } - - Self& operator++() - { - if (_node == NULL) - _node = _sentinel->child->min(); - else if (_node->right) - _node = _node->right->min(); - else - { - node* up = _node->up; - while (up != NULL && _node == up->right) - { - _node = up; - up = up->up; - } - _node = up; - } - return *this; - } - - Self& operator--() - { - if (_node == NULL) - _node = _sentinel->child->max(); - else if (_node->left) - _node = _node->left->max(); - else - { - node* up = _node->up; - while (up != NULL && _node == up->left) - { - _node = up; - up = up->up; - } - _node = up; - } - return *this; - } - - Self operator++(int) - { - //Self old(*this); - Self old = *this; - ++(*this); - return old; - } - - Self operator--(int) - { - //Self old(*this); - Self old = *this; - --(*this); - return old; - } - - node* getNode() - { return _node; } - const node* getNode() const - { return _node; } - const node_sentinel* getSentinel() const - { return _sentinel; } - - // TODO : friend Non-member functions syntaxe pas clair. - friend bool operator==(const Self &lhs, const Self &rhs) - { return lhs._node == rhs._node; } - friend bool operator!=(const Self &lhs, const Self &rhs) - { return !(lhs._node == rhs._node); } - - private: - node* _node; - node_sentinel* _sentinel; -}; - -template < - typename Key, - typename T, - typename Compare, - typename Allocator -> class Bst_const_iterator -{ - private: - typedef Bst_const_iterator Self; - - public: - typedef std::bidirectional_iterator_tag iterator_category; - typedef pair value_type; - typedef std::ptrdiff_t difference_type; - typedef const value_type* pointer; - typedef const value_type& reference; - - Bst_const_iterator() : _node(), _sentinel() {} - Bst_const_iterator(const node* node, const node_sentinel* sentinel) : _node(node), _sentinel(sentinel) {} - //Bst_const_iterator(const Bst_const_iterator& src) : _node(src._node), _sentinel(src._sentinel) {} //implicit - Bst_const_iterator(const Bst_iterator& src) : _node(src.getNode()), _sentinel(src.getSentinel()) {} - - reference operator*() const - { return _node->value; } - pointer operator->() const - { return &_node->value; } - - Self& operator++() - { - if (_node == NULL) - _node = _sentinel->child->min(); - else if (_node->right) - _node = _node->right->min(); - else - { - node* up = _node->up; - while (up != NULL && _node == up->right) - { - _node = up; - up = up->up; - } - _node = up; - } - return *this; - } - - Self& operator--() - { - if (_node == NULL) - _node = _sentinel->child->max(); - else if (_node->left) - _node = _node->left->max(); - else - { - node* up = _node->up; - while (up != NULL && _node == up->left) - { - _node = up; - up = up->up; - } - _node = up; - } - return *this; - } - - Self operator++(int) - { - //Self old(*this); - Self old = *this; - ++(*this); - return old; - } - - Self operator--(int) - { - //Self old(*this); - Self old = *this; - --(*this); - return old; - } - - node* getNode() const - { return _node; } - - friend bool operator==(const Self &lhs, const Self &rhs) - { return lhs._node == rhs._node; } - friend bool operator!=(const Self &lhs, const Self &rhs) - { return !(lhs._node == rhs._node); } - - private: - const node* _node; - const node_sentinel* _sentinel; -}; - -} // namespace ft - -#endif - diff --git a/headers/bak__bst_node.hpp b/headers/bak__bst_node.hpp deleted file mode 100644 index 2fa8ca1..0000000 --- a/headers/bak__bst_node.hpp +++ /dev/null @@ -1,50 +0,0 @@ - -#ifndef BST_NODE_HPP -# define BST_NODE_HPP - -# include // NULL - -namespace ft { - -template < typename ValueType > -struct node -{ - ValueType value; - node *up; - node *left; - node *right; - short height; - - node(const ValueType& val) : value(val), up(NULL), left(NULL), right(NULL), height(1) {} - - node* min() - { - node* n = this; - - while (n->left) - n = n->left; - return n; - } - - node* max() - { - node* n = this; - - while (n->right) - n = n->right; - return n; - } -}; - -template < typename ValueType > -struct node_sentinel -{ - node *child; - - node_sentinel() : child(NULL) {} -}; - -} // namespace ft - -#endif - diff --git a/headers/bak__map.hpp b/headers/bak__map.hpp deleted file mode 100644 index 137c4fd..0000000 --- a/headers/bak__map.hpp +++ /dev/null @@ -1,207 +0,0 @@ - -#ifndef MAP_HPP -# define MAP_HPP - -# include // std::allocator -# include // NULL, std::size_t, std::ptrdiff_t -# include // std::less, std::binary_function - -# include "pair.hpp" -# include "bst.hpp" - -namespace ft { - -template < - class Key, // map::key_type - class T, // map::mapped_type - class Compare = std::less, // map::key_compare - class Alloc = std::allocator< ft::pair > // map::allocator_type -> class map { - -public: - - typedef Key key_type; - typedef T mapped_type; - typedef pair value_type; - typedef std::size_t size_type; - typedef std::ptrdiff_t difference_type; - typedef Compare key_compare; - typedef Alloc allocator_type; - - typedef Bst bst_map; - - typedef typename bst_map::iterator iterator; - typedef typename bst_map::const_iterator const_iterator; - typedef typename bst_map::reverse_iterator reverse_iterator; - typedef typename bst_map::const_reverse_iterator const_reverse_iterator; - - - /**************** - * member class : - ****************/ - // https://en.cppreference.com/w/cpp/container/map/value_compare - // https://stackoverflow.com/questions/4571355/why-would-one-use-nested-classes-in-c - class value_compare : public std::binary_function { - - friend class map; - protected: - Compare comp; - value_compare(Compare c) : comp(c) {} - public: - bool operator() (const value_type& x, const value_type& y) const - { return comp(x.first, y.first); } - }; - - - /************ - * copliens : - ************/ -// constructors ------------------------------ - explicit map (const key_compare& comp = key_compare(), - const allocator_type& alloc = allocator_type()); - template - map (InputIterator first, InputIterator last, - const key_compare& comp = key_compare(), - const allocator_type& alloc = allocator_type()); - map (const map& x); -// destructor -------------------------------- - ~map(); -// operator= --------------------------------- - map& operator= (const map& x); - - - /************* - * iterators : - *************/ -// begin ------------------------------------- - iterator begin(); - const_iterator begin() const; -// end --------------------------------------- - iterator end(); - const_iterator end() const; -// rbegin ------------------------------------ - reverse_iterator rbegin(); - const_reverse_iterator rbegin() const; -// rend -------------------------------------- - reverse_iterator rend(); - const_reverse_iterator rend() const; - - - /************ - * capacity : - ************/ -// empty ------------------------------------- - bool empty() const; -// size -------------------------------------- - size_type size() const; -// max_size ---------------------------------- - size_type max_size() const; - - - /****************** - * element access : - ******************/ -// operator[] -------------------------------- - mapped_type & operator[] (const key_type& k); - - - /************* - * modifiers : - *************/ -// insert ------------------------------------ - pair insert (const value_type& val); - iterator insert (iterator position, const value_type& val); - template - void insert (InputIterator first, InputIterator last); -// erase ------------------------------------- - void erase (iterator position); - size_type erase (const key_type& k); - void erase (iterator first, iterator last); -// swap -------------------------------------- - void swap (map& x); -// clear ------------------------------------- - void clear(); - - - /************* - * observers : - *************/ -// key_comp ---------------------------------- - key_compare key_comp() const; -// value_comp -------------------------------- - value_compare value_comp() const; - - - /************** - * operations : - **************/ -// find -------------------------------------- - iterator find (const key_type& k); - const_iterator find (const key_type& k) const; -// count ------------------------------------- - size_type count (const key_type& k) const; -// lower_bound ------------------------------- - iterator lower_bound (const key_type& k); - const_iterator lower_bound (const key_type& k) const; -// upper_bound ------------------------------- - iterator upper_bound (const key_type& k); - const_iterator upper_bound (const key_type& k) const; -// equal_range ------------------------------- - pair equal_range (const key_type& k) const; - pair equal_range (const key_type& k); - - - /************* - * allocator : - *************/ -// get_allocator ----------------------------- - allocator_type get_allocator() const; - - // TMP non privat - bst_map _bst; -private: - - allocator_type _allocator; - key_compare _comp; - -}; - - - /************************ - * non-member functions : - ************************/ -// operator == ------------------------------- -template< class K, class T, class Comp, class Alloc > bool operator== - ( const std::map& lhs, const std::map& rhs ); -// operator != ------------------------------- -template< class K, class T, class Comp, class Alloc > bool operator!= - ( const std::map& lhs, const std::map& rhs ); -// operator < -------------------------------- -template< class K, class T, class Comp, class Alloc > bool operator< - ( const std::map& lhs, const std::map& rhs ); -// operator <= ------------------------------- -template< class K, class T, class Comp, class Alloc > bool operator<= - ( const std::map& lhs, const std::map& rhs ); -// operator > -------------------------------- -template< class K, class T, class Comp, class Alloc > bool operator> - ( const std::map& lhs, const std::map& rhs ); -// operator >= ------------------------------- -template< class K, class T, class Comp, class Alloc > bool operator>= - ( const std::map& lhs, const std::map& rhs ); -// swap (map) ----------------------------- -template< class Key, class T, class Compare, class Alloc > void swap - ( std::map& lhs, std::map& rhs ); - - -} // namespace ft - -# include "map.tpp" - -// banlanced binary search tree : -// https://www.youtube.com/watch?v=vRwi_UcZGjU - -// entinel node : -// https://en.wikipedia.org/wiki/Sentinel_node - -#endif - diff --git a/tests/includes/tests_mutant_stack.hpp b/tests/includes/tests_mutant_stack.hpp deleted file mode 100644 index 53461ca..0000000 --- a/tests/includes/tests_mutant_stack.hpp +++ /dev/null @@ -1,22 +0,0 @@ - -#ifndef TESTS_MUTANT_STACK_HPP -# define TESTS_MUTANT_STACK_HPP - -#include - -template -class MutantStack : public std::stack { - -public: - - typedef typename std::stack::container_type::iterator iterator; - typedef typename std::stack::container_type::const_iterator const_iterator; - - iterator begin() {return this->c.begin();} - iterator end() {return this->c.end();} - const_iterator begin() const {return this->c.begin();} - const_iterator end() const {return this->c.end();} -}; - -#endif -