This project was code for MACOS. Here is the subject.
"C++ containers, easy mode"
Ft_containers is a project of the mandatory part of the cursus. It's only made in C++ and was about recoding some containers from the STL.
In order to succeed, a good comprehension of how templates, iterators, containers and algorithms work was necessary. Of course, STL is not allowed. That means you cannot use <iterator> or even <utility>.
Here are the specificities of the five containers:
- ➡️ Vector: a dynamic array that allows insertion at the end of the container. Elements can be easily access thanks with the corresponding index, but it's not the most optimal container if a lot of insertion / deletion are needed.
- ➡️ List: a circular linked list (with a neutral node linking beginning and end of the list). Better than vector for inserting or deleting elements.
- ➡️ Stack: a container adaptator (LIFO, last in first out).
- ➡️ Queue: a container adaptator (FIFO, first in first out).
- ➡️ Map: a sorted container using an AVL binary tree (auto-equilibrates itself to optimize the time to find a value in the tree), in order to store the datas like in a dictionnary (a key associated to its value).
All my containers use an allocator to manage properly their memory, iterators to access their datas, and handle the same constructors / methods than the containers from the STL in C++98.
I created a tester with Hélène Herin, doing several tests on each of the five mandatory containers. It handles over 10000 tests for some containers !
It will test all the constructors, methods and iterators, by comparating your containers with the STL containers, and making a diff if some errors occured. Also, you can choose which tests you want to execute, in the case you're checking specific containers / methods.
✅ If you want to see more, go check it at this repo : https://github.com/llefranc/42_Containator
- Best website for learning about C++ (including C++98)
- Difference of keywords 'typename' and 'class' in templates
- Lvalus and rvalues
- Dependant names in C++
- What's explicit keyword
- Explicit call to a constructor
- Implementing iterators
- Writing your own STL style container
- Writing operator++ for iterator
- Writing operator== for iterator
- When use typename keyword
- Cours sur les templates
- Understanding SFINAE (used in enable_if)
- How to use the allocator
- Difference between explicit and implicit copy constructor