Skip to content

My solution for ft_containers of the Common core of 42 school.

License

Notifications You must be signed in to change notification settings

tblaase/ft_containers

Folders and files

NameName
Last commit message
Last commit date

Latest commit

 

History

93 Commits
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 

Repository files navigation

ft_containers

My solution for ft_containers of the common-core of 42 school.

Basics

The goal of this project was to recode the STL-containers of c++98.
The mandatory containers where std::vector, std::stack and std::map.
They had to have the exact same structure as the original containers and support every function the standard-containers supported.
Almost all of the needed information can be found at cplusplus.com or directly from the source code of the different libraries.

Testing

In the end of the project you had to make sure the containers worked as intended and had a good performance.
For that I created a Makefile that compiles my main.cpp with make all into two different binaries:

  • once with the std:: namespace
  • once with the ft:: namespace

After that you can run them individually to see the output.
Or run my test.sh, which does not need the make all before, since it runs make re anyways to make sure everything is in perfect working order.
This testing is also included in the github-actions of this project and are running automated on each push or pull request on the main branch.
The .yml for the github actions can be found here.

My testing script will run the two binaries one after another, put their output into .log files and diff them in two different ways.
diff1
This diff shows differences in red and similarities in green.

diff2
This diff shows the ft::containers output on the left and the std::containers output on the right.

Conclusions

This project teached the very inner workings of the c++ STL-containers, which made working with them in later projects like webserv a lot easier.
It also shows that my red_black_tree is far from perfect, which made my ft::map be a lot slower than the std::map, which can be seen in the output of my main.cpp.