re-organisation of files
This commit is contained in:
166
headers/map.hpp
Normal file
166
headers/map.hpp
Normal file
@@ -0,0 +1,166 @@
|
||||
|
||||
#ifndef MAP_HPP
|
||||
# define MAP_HPP
|
||||
|
||||
//# include "colors.h"
|
||||
//# include <iostream>
|
||||
//# include <string>
|
||||
//# include <memory> // std::allocator
|
||||
//# include <algorithm> // std::min, std::max
|
||||
//# include <stdexcept> // out_of_range, length_error, logic_error
|
||||
//# include <cstddef> // NULL, std::size_t, std::ptrdiff_t
|
||||
//
|
||||
//# include "enable_if.hpp"
|
||||
//# include "is_integral.hpp"
|
||||
//# include "reverse_iterator.hpp"
|
||||
//# include "equal.hpp"
|
||||
//# include "lexicographical_compare.hpp"
|
||||
|
||||
namespace ft {
|
||||
|
||||
//template <
|
||||
// class T,
|
||||
// class Allocator = std::allocator<T> >
|
||||
class map {
|
||||
|
||||
public:
|
||||
|
||||
// typedef T value_type;
|
||||
// typedef Allocator allocator_type;
|
||||
// typedef std::size_t size_type;
|
||||
// typedef std::ptrdiff_t difference_type;
|
||||
//
|
||||
// typedef T * iterator;
|
||||
// typedef T const * const_iterator;
|
||||
// typedef ft::reverse_iterator<iterator> reverse_iterator;
|
||||
// typedef ft::reverse_iterator<const_iterator> const_reverse_iterator;
|
||||
//
|
||||
// // dependent qualified name :
|
||||
// // https://en.cppreference.com/w/cpp/keyword/typename
|
||||
// typedef typename Allocator::reference reference;
|
||||
// typedef typename Allocator::const_reference const_reference;
|
||||
|
||||
|
||||
|
||||
/************
|
||||
* copliens :
|
||||
************/
|
||||
//// constructors ------------------------------
|
||||
// explicit map (const key_compare& comp = key_compare(),
|
||||
// const allocator_type& alloc = allocator_type());
|
||||
// template <class InputIterator>
|
||||
// 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<iterator,bool> insert (const value_type& val);
|
||||
// iterator insert (iterator position, const value_type& val);
|
||||
// template <class InputIterator>
|
||||
// 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<const_iterator,const_iterator> equal_range (const key_type& k) const;
|
||||
// pair<iterator,iterator> equal_range (const key_type& k);
|
||||
|
||||
|
||||
/*************
|
||||
* allocator :
|
||||
*************/
|
||||
//// get_allocator -----------------------------
|
||||
// allocator_type get_allocator() const;
|
||||
|
||||
private:
|
||||
|
||||
// size_type _size;
|
||||
// size_type _capacity;
|
||||
// value_type * _mem_ptr;
|
||||
// allocator_type _allocator;
|
||||
//
|
||||
// void _destroy(iterator first, iterator last);
|
||||
// void _increment_capacity(size_type n);
|
||||
|
||||
};
|
||||
|
||||
} // namespace ft
|
||||
|
||||
# include "map.tpp"
|
||||
|
||||
#endif
|
||||
|
||||
132
headers/tests.hpp
Normal file
132
headers/tests.hpp
Normal file
@@ -0,0 +1,132 @@
|
||||
#ifndef TESTS_HPP
|
||||
# define TESTS_HPP
|
||||
|
||||
#include "colors.h"
|
||||
#include <iostream>
|
||||
#include <string>
|
||||
#include <iomanip> // std::setw()
|
||||
#include <iterator> // std::reverse_iterator
|
||||
#include <utility> // std::make_pair
|
||||
#include <sstream> // std::stringstream
|
||||
|
||||
|
||||
|
||||
// toogle between test ft and stl
|
||||
// *************************
|
||||
#include <vector>
|
||||
#include <map>
|
||||
#ifdef STL
|
||||
namespace ft = std;
|
||||
#else
|
||||
#include "vector.hpp"
|
||||
#include "reverse_iterator.hpp"
|
||||
#endif
|
||||
|
||||
|
||||
// global variables
|
||||
// ***************************************
|
||||
std::vector< std::vector<A_test*> > test_list;
|
||||
std::vector<mystruct*> mem_list;
|
||||
|
||||
|
||||
|
||||
// global functions
|
||||
// ***************************************
|
||||
void add_to_list(std::string s, A_test* s1, A_test* s2, A_test* s3, A_test* s4);
|
||||
|
||||
|
||||
// struct for tests
|
||||
// ***************************************
|
||||
struct mystruct {
|
||||
public:
|
||||
mystruct(int data = 0);
|
||||
~mystruct();
|
||||
int * get_data() const;
|
||||
private:
|
||||
int * _val;
|
||||
};
|
||||
std::ostream & operator<<(std::ostream & o, mystruct const * rhs);
|
||||
|
||||
|
||||
// adding each test to the list
|
||||
// ***************************
|
||||
#define TEST(f_name) \
|
||||
template <class T> struct s_ ## f_name : public A_test\
|
||||
{ void func(); };\
|
||||
void f_name ()\
|
||||
{ add_to_list(\
|
||||
#f_name,\
|
||||
new(s_ ## f_name <int>),\
|
||||
new(s_ ## f_name <char>),\
|
||||
new(s_ ## f_name <std::string>),\
|
||||
new(s_ ## f_name <mystruct*>)\
|
||||
);}\
|
||||
template <class T>\
|
||||
void s_ ## f_name <T>::func()
|
||||
|
||||
|
||||
// defines
|
||||
// ****************************************
|
||||
# define TITLE(s) std::cout << "\n" B_PURPLE #s RESET "\n\n";
|
||||
# define VAL(n) val<T>(n)
|
||||
# define TOI(n) toi<T>(n)
|
||||
# define PRINT(n) print_vector<T>(n);
|
||||
# define DELETE delete_structs();
|
||||
|
||||
|
||||
// prototypes
|
||||
// *********************************************
|
||||
// vectors
|
||||
void tests_vector_constructor();
|
||||
void tests_vector_operator_assignation();
|
||||
void tests_vector_begin();
|
||||
void tests_vector_end();
|
||||
void tests_vector_rbegin();
|
||||
void tests_vector_rend();
|
||||
void tests_vector_size();
|
||||
void tests_vector_max_size();
|
||||
void tests_vector_resize();
|
||||
void tests_vector_capacity();
|
||||
void tests_vector_empty();
|
||||
void tests_vector_reserve();
|
||||
void tests_vector_operator_access();
|
||||
void tests_vector_at();
|
||||
void tests_vector_front();
|
||||
void tests_vector_back();
|
||||
void tests_vector_assign();
|
||||
void tests_vector_push_back();
|
||||
void tests_vector_pop_back();
|
||||
void tests_vector_insert();
|
||||
void tests_vector_erase();
|
||||
void tests_vector_swap();
|
||||
void tests_vector_clear();
|
||||
void tests_vector_get_allocator();
|
||||
void tests_vector_relational_operators();
|
||||
void tests_vector_swap_non_member();
|
||||
void tests_vector_reverse_iterators();
|
||||
// map
|
||||
void tests_map_simple();
|
||||
//void tests_map_constructor();
|
||||
//void tests_map_operator_assignation();
|
||||
//void tests_map_begin();
|
||||
//void tests_map_end();
|
||||
//void tests_map_rbegin();
|
||||
//void tests_map_rend();
|
||||
//void tests_map_empty();
|
||||
//void tests_map_size();
|
||||
//void tests_map_max_size();
|
||||
//void tests_map_operator_access();
|
||||
//void tests_map_insert();
|
||||
//void tests_map_erase();
|
||||
//void tests_map_swap();
|
||||
//void tests_map_clear();
|
||||
//void tests_map_key_comp();
|
||||
//void tests_map_value_comp();
|
||||
//void tests_map_find();
|
||||
//void tests_map_count();
|
||||
//void tests_map_lower_bound();
|
||||
//void tests_map_upper_bound();
|
||||
//void tests_map_equal_range();
|
||||
//void tests_map_get_allocator();
|
||||
#endif
|
||||
|
||||
@@ -27,8 +27,8 @@ void add_to_list(std::string s, A_test* s1, A_test* s2, A_test* s3, A_test* s4)
|
||||
}
|
||||
|
||||
|
||||
// *********************************************
|
||||
// prototypes
|
||||
// **************************************
|
||||
// prototypes vector
|
||||
void tests_vector_constructor();
|
||||
void tests_vector_operator_assignation();
|
||||
void tests_vector_begin();
|
||||
@@ -57,5 +57,33 @@ void tests_vector_relational_operators();
|
||||
void tests_vector_swap_non_member();
|
||||
void tests_vector_reverse_iterators();
|
||||
|
||||
|
||||
// *****************************************
|
||||
// prototypes map
|
||||
void tests_map_simple();
|
||||
//void tests_map_constructor();
|
||||
//void tests_map_operator_assignation();
|
||||
//void tests_map_begin();
|
||||
//void tests_map_end();
|
||||
//void tests_map_rbegin();
|
||||
//void tests_map_rend();
|
||||
//void tests_map_empty();
|
||||
//void tests_map_size();
|
||||
//void tests_map_max_size();
|
||||
//void tests_map_operator_access();
|
||||
//void tests_map_insert();
|
||||
//void tests_map_erase();
|
||||
//void tests_map_swap();
|
||||
//void tests_map_clear();
|
||||
//void tests_map_key_comp();
|
||||
//void tests_map_value_comp();
|
||||
//void tests_map_find();
|
||||
//void tests_map_count();
|
||||
//void tests_map_lower_bound();
|
||||
//void tests_map_upper_bound();
|
||||
//void tests_map_equal_range();
|
||||
//void tests_map_get_allocator();
|
||||
|
||||
|
||||
#endif
|
||||
|
||||
|
||||
@@ -5,12 +5,14 @@
|
||||
#include "A_test.hpp"
|
||||
#include <iostream>
|
||||
#include <string>
|
||||
#include <vector>
|
||||
#include <iomanip> // std::setw()
|
||||
#include <iterator> // std::reverse_iterator
|
||||
#include <utility> // std::make_pair
|
||||
#include <map> // std::map
|
||||
#include <sstream>
|
||||
#include <sstream> // std::stringstream
|
||||
|
||||
#include <vector>
|
||||
#include <map>
|
||||
|
||||
|
||||
// toogle between test ft and stl
|
||||
|
||||
Reference in New Issue
Block a user