https://github.com/abderrsfa/ft_containers
Reimplementing C++98's STL containers. (std::vector, std::stack, std::map)
https://github.com/abderrsfa/ft_containers
1337 42born2code avl-tree cpp cpp98 iterator map stack stl stl-containers vector
Last synced: 5 months ago
JSON representation
Reimplementing C++98's STL containers. (std::vector, std::stack, std::map)
- Host: GitHub
- URL: https://github.com/abderrsfa/ft_containers
- Owner: AbderrSfa
- License: apache-2.0
- Created: 2021-12-02T12:30:19.000Z (over 4 years ago)
- Default Branch: main
- Last Pushed: 2022-03-28T14:39:18.000Z (about 4 years ago)
- Last Synced: 2025-09-01T01:43:09.287Z (10 months ago)
- Topics: 1337, 42born2code, avl-tree, cpp, cpp98, iterator, map, stack, stl, stl-containers, vector
- Language: C++
- Homepage:
- Size: 441 KB
- Stars: 1
- Watchers: 1
- Forks: 0
- Open Issues: 0
-
Metadata Files:
- Readme: README.md
- License: LICENSE
Awesome Lists containing this project
README
# ft_containers
## 🧐 Description
This project is a re-implementation of three container types from the C++ Standard Template Library (STL). `std::vector`, `std::stack`, and `std::map`.
I also implemented:
- `iterator` and `reverse_iterator` for vector and map.
- `enable_if`.
- `std::equal` and `std::lexicographical_compare`.
- `std::pair`.
### ➡️ vector
Vectors are sequence containers representing arrays that can change in size. Just like arrays, vectors use contiguous storage locations for their elements, which means that their elements can also be accessed using offsets on regular pointers to its elements, and just as efficiently as in arrays. But unlike arrays, their size can change dynamically, with their storage being handled automatically by the container.
These vector member functions are implemented:
```
- Constructors.
- Destructor.
- operator=.
Iterators:
- begin
- end
- rbegin
- rend
Capacity:
- size
- max_size
- resize
- capacity
- empty
- reserve
Element access:
- operator[]
- at
- front
- back
Modifiers:
- assign
- push_back
- pop_back
- insert
- erase
- swap
- clear
Allocator:
- get_allocator
Non-member function overloads:
- relational operators
- swap
```
### 📚 stack
Stacks are a type of container adaptor, specifically designed to operate in a LIFO context (last-in first-out), where elements are inserted and extracted only from one end of the container.
Stacks use an encapsulated object of a specific container class as its underlying container, providing a specific set of member functions to access its elements. Elements are pushed/popped from the "back" of the specific container, which is known as the top of the stack.
These vector member functions are implemented:
```
- Constructor
- empty
- size
- top
- push
- pop
Non-member function overloads:
- relational operators
```
### 🗺 map
Maps are associative containers that store elements formed by a combination of a key value and a mapped value, following a specific order.
In a map, the key values are generally used to sort and uniquely identify the elements, while the mapped values store the content associated to this key. The types of key and mapped value may differ.
These vector member functions are implemented:
```
- Constructors
- Destructor
- operator=
Iterators:
- begin
- end
- rbegin
- rend
Capacity:
- empty
- size
- max_size
Element access:
- operator[]
Modifiers:
- insert
- erase
- swap clear
Observers:
- key_comp
- value_comp
Operations:
- find
- count
- lower_bound
- upper_bound
- equal_range
Allocator:
- get_allocator
Non-member function overloads:
- relational operators
- swap
```