Skip to content

re-implementation of the standard C++ containers with all the specific usage.

Notifications You must be signed in to change notification settings

Gab-182/ft_containers

Folders and files

NameName
Last commit message
Last commit date

Latest commit

 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 

Repository files navigation

FT_Containers

GitHub repo file count GitHub repo file count GitHub repo file count

➤ Description

The designer of STL chose a wonderful yet simple common approach - "The separation of data and operation".

  • The data is held and managed by the Container classes.
  • The operations over the containers are defined and managed by the configurable algorithms.

In this project I'm re-implementation some of the standard C++ containers with the specific usage, such as vector, map, and stack, under the namespace "ft" instead of "std".

➤ Usage

To use these container classes in your project, simply include the appropriate header file and use the "ft" namespace. For example:

#include "vector.h"

int main() {
    ft::vector<int> v;
    v.push_back(1);
    v.push_back(2);
    v.push_back(3);

    for (int i : v) {
        std::cout << i << std::endl;
    }
}

re-implementation of:

➤ std::vector -> ft::vector:

➤➤ It is implemented using a dynamic array, which is a contiguous 
block of memory that can be accessed using pointers.
The vector class is a dynamic array that can grow and shrink in size.

➤ std::map -> ft::map :

➤➤ The best type of tree data structure to implement a map container 
in C++ would be a self-balancing binary search tree (BST), such as 
a [Red-Black tree] or [AVL tree].
These trees provide O(log n) time for search, insertion, and deletion operations, 
and have a well-balanced structure that ensures O(log n) time for most operations, 
even in the worst case scenario.

➤ std::stack -> ft::stack :

➤➤ The stack is implemented by using a LIFO (last-in first-out) data structure. 
Elements are pushed/popped from the "back" of the specific container, 
which is known as the top of the stack.

Resources that helped me in this project:


Useful Notes: Notes


About

re-implementation of the standard C++ containers with all the specific usage.

Topics

Resources

Stars

Watchers

Forks

Releases

No releases published

Packages

No packages published