🔧⚙️ In this project, I studied the documentation of containers from STL and tried to reproduce their work.
I had to implement the following containers: std::list, std::vector, std::map, std::set and the following adapters: std::stack, std::queue. I couldn't use STL and any algorithms and functions from C++11 and newer. I also had to create an automated testing system for my containers to demonstrate how they work!
In the implementation of a doubly-linked list, I created a separate ListNode class. I tried to implement all operations in a functional style to ensure the safety and speed of working with the list. I also created two iterator classes that could be combined using std::enable_if, which doesn't work in C++98 in the required context.
In this container we are working with continuous memory. A special feature of the container are random-access iterators that can quickly access any part of the array.
Both containers refer to a separate TreeNode class, which implements working with red-black trees. I relied on algorithms from a research paper from Princeton University that describes working effectively with Left-leaning Red-Black Trees. In this context, the binary tree must interact with iterators, so I added a link to the parent of each node to the implementation and provided for working with a special endNode that referred to the beginning, end, and top of the tree. The difference between ft::map and ft::set is only in the value stored in the TreeNode.
These adapters simply interact with internal containers to implement LIFO and FIFO principles.
I wrote unit-tests for all methods and parts of the container implementation using the handy googletest library. And I learned how to create classes to quickly initialize the testing environment.
In order to run tests and check the work of containers, you need to download the repository with the command:
git clone https://github.com/zkerriga/containers --recursive
After that, you need to build the project in Clion IDE and run the Google_Test_run configuration.