C++ STL containers reimplementation developed as a practice project at School 21 (formerly 42.fr).
- Sequence containers:
vector,list,array - Container adapters:
stack,queue - Associative containers:
map,set,multiset - STL-compatible iterators supporting header functions
vector: 🤖📦 dynamic array with automatic reallocationlist: 🔗↔️ doubly-linked list with sentinel nodearray: 🔒📐 compile-time C-style array wrapperdeque: 🧩 chunked array as map of fixed-size blocksstack,queue: 🔌 adapters overdequemap/set/multiset: 🔴⚫🌳 self-balancing red-black tree
git clone https://github.com/makesnosense/s21_containers.gitCopy headers to your project:
cp s21_containers/src/*.h /path/to/your/project/cd s21_containers
make test # run tests
make coverage # generate coverage report
make valgrind # memory leak check// include all:
#include "s21_containers.h" // vector, list, map, set, stack, queue
#include "s21_containersplus.h" // array, multiset
// or include individual containers:
#include "s21_vector.h"
#include "s21_list.h"
#include "s21_map.h"
#include "s21_set.h"
#include "s21_multiset.h"
#include "s21_stack.h"
#include "s21_queue.h"
#include "s21_array.h"
#include "s21_deque.h"s21::vector<int> v = {1, 2, 3};
v.push_back(4);
v.insert(v.begin(), 0);s21::list<int> l = {1, 2, 3};
l.push_front(0);
l.sort();
l.unique();s21::array<int, 5> arr = {1, 2, 3, 4, 5};
arr.fill(42);s21::stack<int> s;
s.push(42);
int top = s.top();
s.pop();s21::queue<int> q;
q.push(1);
int front = q.front();
q.pop();s21::map<std::string, int> m;
m["key"] = 42;
m.insert({"another", 24});s21::set<int> s = {3, 1, 4, 1, 5}; // {1, 3, 4, 5}
s.insert(2);s21::multiset<int> ms = {1, 2, 2, 3};
size_t count = ms.count(2); // 2s21::vector<int> v;
v.insert_many_back(1, 2, 3, 4, 5);
s21::list<int> l;
l.insert_many_front(5, 4, 3, 2, 1);
s21::map<int, std::string> m;
m.insert_many({1, "one"}, {2, "two"});- C++17 compiler (tested with GCC on Linux, Clang on macOS)
- Google Test framework (for testing)
- GCOVR (for coverage reports)
- Valgrind (for memory leak checks)