You can not select more than 25 topics Topics must start with a letter or number, can include dashes ('-') and can be up to 35 characters long.
 
 

81 lines
3.4 KiB

/* ************************************************************************** */
/* */
/* ::: :::::::: */
/* main.cpp :+: :+: :+: */
/* +:+ +:+ +:+ */
/* By: pohl <pohl@student.42.fr> +#+ +:+ +#+ */
/* +#+#+#+#+#+ +#+ */
/* Created: 2021/11/26 11:21:08 by pohl #+# #+# */
/* Updated: 2022/01/19 15:09:32 by pohl ### ########.fr */
/* */
/* ************************************************************************** */
#include <stdio.h>
#include <list>
#include <iostream>
/* #include <map> */
#include "map.hpp"
int main( void )
{
std::list<ft::pair<int, char> > douze;
ft::map<int, char> hi;
ft::pair<ft::map<int, char>::iterator, bool> pair;
for (int i = 0; i < 12; i++)
douze.insert(douze.begin(), ft::make_pair(i, 'a' + i));
hi.insert(douze.begin(), douze.end());
ft::map<int, char> hello(douze.begin(), douze.end());
for (int i = 0; i < 13; i++)
std::cout << "hi[" << i << "] = " << hi[i] << std::endl;
std::cout << "Size: " << hi.size() << std::endl;
pair = hi.insert(ft::make_pair(1, 'a'));
std::cout << pair.second << ": " << pair.first->second << std::endl;
std::cout << "Size: " << hi.size() << std::endl;
pair = hi.insert(ft::make_pair(2, 'b'));
std::cout << pair.second << ": " << pair.first->second << std::endl;
std::cout << "Size: " << hi.size() << std::endl;
pair = hi.insert(ft::make_pair(1, 'c'));
std::cout << pair.second << ": " << pair.first->second << std::endl;
std::cout << "Size: " << hi.size() << std::endl;
hi[1] = 'c';
std::cout << hi[1] << std::endl;
std::cout << "Size: " << hi.size() << std::endl;
std::cout << hi[14] << std::endl;
std::cout << "Size: " << hi.size() << std::endl;
printf(">> %d\n", hi[13]);
std::cout << "Size: " << hi.size() << std::endl;
ft::map<int, char>::iterator asdf = hi.end();
std::cout << "Before end: " << (--hi.end())->first << std::endl;
std::cout << "Before end: " << (--asdf)->first << std::endl;
std::cout << "Before before end: " << (--asdf)->first << std::endl;
std::cout << "Before before end: " << (--(--hi.end()))->first << std::endl;
std::cout << "Before before before end: " << (--(--(--hi.end())))->first << std::endl;
}
/* int main( void ) */
/* { */
/* ft::map<int, char> the_map; */
/* the_map[0] = 'a'; */
/* the_map[1] = 'b'; */
/* the_map[2] = 'c'; */
/* the_map[3] = 'd'; */
/* std::cout << the_map[0] << std::endl; */
/* std::cout << the_map[1] << std::endl; */
/* std::cout << the_map[2] << std::endl; */
/* std::cout << the_map[3] << std::endl; */
/* std::cout << "=============================" << std::endl; */
/* the_map[7] = 's'; */
/* the_map[9] = 'd'; */
/* the_map[6] = 'g'; */
/* the_map[3] = 'm'; */
/* std::cout << the_map[0] << std::endl; */
/* std::cout << the_map[1] << std::endl; */
/* std::cout << the_map[2] << std::endl; */
/* std::cout << the_map[3] << std::endl; */
/* std::cout << the_map[6] << std::endl; */
/* std::cout << the_map[7] << std::endl; */
/* std::cout << the_map[9] << std::endl; */
/* return 0; */
/* } */