{"id":19463676,"url":"https://github.com/4s4v1n/stl-containers","last_synced_at":"2025-08-27T13:06:23.174Z","repository":{"id":143557746,"uuid":"484144956","full_name":"4s4v1n/STL-Containers","owner":"4s4v1n","description":"Realization of standart template library (STL)","archived":false,"fork":false,"pushed_at":"2022-04-22T06:02:24.000Z","size":168,"stargazers_count":0,"open_issues_count":0,"forks_count":0,"subscribers_count":1,"default_branch":"main","last_synced_at":"2025-01-08T03:10:59.653Z","etag":null,"topics":["container","cpp","data-structures","stl","stl-containers"],"latest_commit_sha":null,"homepage":"","language":"C++","has_issues":true,"has_wiki":null,"has_pages":null,"mirror_url":null,"source_name":null,"license":"gpl-3.0","status":null,"scm":"git","pull_requests_enabled":true,"icon_url":"https://github.com/4s4v1n.png","metadata":{"files":{"readme":"README.md","changelog":null,"contributing":null,"funding":null,"license":"LICENSE","code_of_conduct":null,"threat_model":null,"audit":null,"citation":null,"codeowners":null,"security":null,"support":null,"governance":null}},"created_at":"2022-04-21T17:29:31.000Z","updated_at":"2024-02-25T12:24:01.000Z","dependencies_parsed_at":"2023-10-21T16:21:35.251Z","dependency_job_id":null,"html_url":"https://github.com/4s4v1n/STL-Containers","commit_stats":null,"previous_names":["4s4v1n/stl-containers"],"tags_count":0,"template":false,"template_full_name":null,"repository_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/4s4v1n%2FSTL-Containers","tags_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/4s4v1n%2FSTL-Containers/tags","releases_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/4s4v1n%2FSTL-Containers/releases","manifests_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/4s4v1n%2FSTL-Containers/manifests","owner_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/owners/4s4v1n","download_url":"https://codeload.github.com/4s4v1n/STL-Containers/tar.gz/refs/heads/main","host":{"name":"GitHub","url":"https://github.com","kind":"github","repositories_count":240672824,"owners_count":19838930,"icon_url":"https://github.com/github.png","version":null,"created_at":"2022-05-30T11:31:42.601Z","updated_at":"2022-07-04T15:15:14.044Z","host_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub","repositories_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories","repository_names_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repository_names","owners_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/owners"}},"keywords":["container","cpp","data-structures","stl","stl-containers"],"created_at":"2024-11-10T18:11:47.067Z","updated_at":"2025-02-25T12:53:14.321Z","avatar_url":"https://github.com/4s4v1n.png","language":"C++","funding_links":[],"categories":[],"sub_categories":[],"readme":"# STL-Containers\n\n![containers](./images/containers.png)\n\n## Content\nThis project provides an implementation of the Standard Template Library (STL) containers and their main methods.\nAll containers are in the `s21` namespace.\nEach container has an iterator in the form of an internal class of the container. Standard operations are implemented on iterators:\n 1) `++iter`\n 2) `--iter`\n 3) `iter1 == iter2`\n 4) `iter1 != iter2`\n 5) `iter1 = iter2`\n 6) `*iter`\n\nThe project is divided into 2 parts, namely `my_containers.h` , `my_containers_plus.h`.\n\n`my_containets.h`: \n 1) `queue` (my_containerAdaptor.h)\n 2) `stack` (my_containerAdaptor.h)\n 3) `list` (my_list.h)\n 4) `map` (my_map.h)\n 5) `set` (my_set.h)\n 6) `vector` (my_vector.h)\n\n`my_containers_plus.h`:\n 1) `array` (my_array.h)\n 2) `multiset` (my_multiset)\n\nFor each of the container, the constructors and destructor are essentially the same:\n 1) `container()` is the base constructor.\n 2) `container(std::initializer_list\u003cvalue_type\u003e const\u0026 items)` - constructor with initialization list.\n 3) `container(const container\u0026 other)` - copy constructor.\n 4) `container(container\u0026\u0026 other)` - move constructor.\n 5) `operator=(container\u0026\u0026 other)` - move operator.\n 6) `~container()` - destructor.\n \n## Queue\n\n`queue` - a container, from one end of which elements can be added, and from the other - removed.\n\n### queue methods\n\n 1) `const_reference front()` - returns a reference to the first element.\n 2) `const_reference back()` - returns a reference to the last element.\n 3) `bool empty()` - checks for the presence of elements.\n 4) `size_type size()` - returns the number of elements.\n 5) `void push(const_reference value)` - adds an element to the end.\n 6) `void pop()` - removes the first element.\n 7) `void swap(queue\u0026 other)` - swaps two objects.\n\n## Stack\n\n`stack` is a container in which elements are added and removed from one end.\n\n### stack methods\n\n 1) `const_reference top()` - returns the reference of the element at the top of the element.\n 2) `bool empty()` - checks for the presence of elements.\n 3) `size_type size()` - returns the number of elements.\n 4) `void push(const_reference value)` - adds an element to the top.\n 5) `void pop()` - remove the element at the top.\n 6) `void swap(stack\u0026 other)` - swaps two objects.\n\n## List\n\n`list` is a doubly linked list whose elements are stored in arbitrary chunks of memory.\n\n### list methods\n\n 1) `const_reference front()` - returns a reference to the first element.\n 2) `const_reference back()` - returns a reference to the last element.\n 3) `iterator begin()` - returns an iterator to the beginning.\n 4) `iterator end()` - returns an iterator to the end.\n 5) `bool empty()` - checks for the presence of elements.\n 6) `size_type size()` - returns the number of elements.\n 7) `size_type max_size()` - returns the maximum number of possible elements.\n 8) `void clear()` - clearing.\n 9) `iterator insert(iterator pos, const_reference value)` - inserting an element by iterator, returns the position of the iterator where the element was inserted.\n 10) `void erase(iterator pos)` - delete element by iterator\n 11) `void push_back(const_reference value)` - adding an element to the end.\n 12) `void pop_back()` - delete the element at the end.\n 13) `void push_front(const_reference value)` - adding an element to the front.\n 14) `void pop_front()` - remove element at the beginning.\n 15) `void swap(list\u0026 other)` - swaps two objects.\n 16) `void merge(list\u0026 other)` - merges the passed object with the current one.\n 17) `void splice(const_iterator pos, list\u0026 other)` - transfers elements from another object starting from the position of the iterator.\n 18) `void reverse()` - reverses the order of accessing elements.\n 19) `void unique()` - removes consecutive duplicate elements.\n 20) `void sort()` - sorts all elements.\n\n## Map\n\n`map` is an ordered associative array of pairs of elements consisting of keys and their corresponding values. Keys must be unique.\n\n### map methods\n\n 1) `T\u0026 at(const Key\u0026 key)` - returns a reference to the element with bounds checking.\n 2) `T\u0026 operator[](const Key\u0026 key)` - returns a reference to the element.\n 3) `iterator begin()` - returns an iterator to the beginning.\n 4) `iterator end()` - returns an iterator to the end.\n 5) `bool empty()` - checks for the presence of elements.\n 6) `size_type size()` - returns the number of elements.\n 7) `size_type max_size()` - returns the maximum number of possible elements.\n 8) `void clear()` - clearing.\n 9) `std::pair\u003citerator, bool\u003e insert(const value_type\u0026 value)` - inserts an element by value and returns the pair, iterator position and whether the insert succeeded.\n 10) `std::pair\u003citerator, bool\u003e insert(const Key\u0026 key, const T\u0026 obj)` - inserts an element by key and returns the pair, iterator position and whether the insert succeeded.\n 11) `std::pair\u003citerator, bool\u003e insert_or_assign(const Key\u0026 key, const T\u0026 obj)` - inserts an element or assigns a value to an element by key, if such a key already exists.\n 12) `void erase(iterator pos)` - removes the element at the position of the iterator.\n 13) `void swap(map\u0026 other)` - swaps two objects.\n 14) `void merge(map\u0026 other)` - merges the passed object with the current one.\n 15) `bool contains(const Key\u0026 key)` - checks if an element exists with the given key.\n\n## Set\n\n`set` - an ordered set of unique elements.\n\n### set methods\n\n 1) `iterator begin()` - returns an iterator to the beginning.\n 2) `iterator end()` - returns an iterator to the end.\n 3) `bool empty()` - checks for the presence of elements.\n 4) `size_type size()` - returns the number of elements.\n 5) `size_type max_size()` - returns the maximum number of possible elements.\n 6) `void clear()` - clearing.\n 7) `std::pair\u003citerator, bool\u003e insert(const value_type\u0026 value)` - element insertion, returns a pair, the position of the iterator where the element was inserted and whether the insert succeeded.\n 8) `void erase(iterator pos)` - delete element by iterator position.\n 9) `void swap(set\u0026 other)` - swaps two objects.\n 10) `void merge(set\u0026 other)` - merges the passed object with the current one.\n 11) `iterator find(const Key\u0026 key)` - returns an iterator to the element with the specified key.\n 12) `bool contains(const Key\u0026 key)` - checks if there is an element with the specified key.\n\n## Vector\n\n`vetor` - C-like dynamic random access array with automatic resizing when element is added/removed.\n\n### vector methods\n\n 1) `reference at(size_type pos)` - returns a reference to the element with bounds checking.\n 2) `reference operator[](size_type pos)` - returns a reference to the element.\n 3) `const_reference front()` - returns a reference to the first element.\n 4) `const_reference back()` - returns a reference to the last element.\n 5) `iterator data()` - direct access to the underlying array.\n 6) `iterator begin()` - returns an iterator to the beginning.\n 7) `iterator end()` - returns an iterator to the end.\n 8) `bool empty()` - checks for the presence of elements.\n 9) `size_type size()` - returns the number of elements.\n 10) `size_type max_size()` - returns the maximum number of possible.11) `void reserve(size_type size)` - allocates additional memory for elements and copies existing elements into it.\n 12) `size_type capacity()` - returns the number of possible elements to store at the moment.\n 13) `void shrink_to_fit()` - releases unused memory.\n 14) `void clear()` - clearing.\n 15) `iterator insert(iterator pos, const_reference value)` - insert element at iterator position.\n 16) `void erase(iterator pos)` - delete an element about the iterator.\n 17) `void push_back(const_reference value)` - insert an element at the end.\n 18) `void pop_back()` - remove the last element.\n 19) `void swap(vector\u0026 other)` - swaps two objects.\n\n## Array\n\n`array` is a sequential container that encapsulates a static array.\n\n### array methods\n\n 1) `reference at(size_type pos)` - returns a reference to the element with bounds checking.\n 2) `reference operator[](size_type pos)` - returns a reference to the element.\n 3) `const_reference front()` - returns a reference to the first element.\n 4) `const_reference back()` - returns a reference to the last element.\n 5) `iterator data()` - direct access to the underlying array.\n 6) `iterator begin()` - returns an iterator to the beginning.\n 7) `iterator end()` - returns an iterator to the end.\n 8) `bool empty()` - checks for the presence of elements.\n 9) `size_type size()` - returns the number of elements.\n 10) `size_type max_size()` - returns the maximum number of possible elements.\n 11) `void swap(array\u0026 other)` - swaps two objects.\n 12) `void fill(const_reference value)` - assigns the specified value to all elements in the container.\n\n## Multiset\n\n`multiset` is the same as set but allows you to store duplicate elements.\n\n### multiset methods\n\n 1) `iterator begin()` - returns an iterator to the beginning.\n 2) `iterator end()` - returns an iterator to the end.\n 3) `bool empty()` - checks for the presence of elements.\n 4) `size_type size()` - returns the number of elements.\n 5) `size_type max_size()` - returns the maximum number of possible elements.\n 6) `void clear()` - clearing.\n 7) `iterator insert(const value_type\u0026 value)` - inserting an element, returns an iterator to the position where the element was inserted.\n 8) `void erase(iterator pos)` - delete element by iterator position.\n 9) `void swap(multiset\u0026 other)` - swaps two objects.\n 10) `void merge(multiset\u0026 other)` - merges the passed object with the current one.\n 11) `iterator find(const Key\u0026 key)` - returns an iterator to the element with the specified key.\n 12) `bool contains(const Key\u0026 key)` - checks if there is an element with the specified key.\n 13) `size_type count(const Key\u0026 key)` - returns the number of elements in the container equal to the given one.\n 14) `iterator find(const Key\u0026 key)` - returns an iterator to the element with the desired value.\n 15) `bool contains(const Key\u0026 key)` - check if the given element contains.\n 16) `std::pair\u003citerator,iterator\u003e equal_range(const Key\u0026 key)` - returns an iterator to the beginning and end of the set of elements that match the given value.\n 17) `iterator lower_bound(const Key\u0026 key)` - returns an iterator to the first element not less than the passed value.\n 18) `iterator upper_bound(const Key\u0026 key)` - returns an iterator to the first element greater than the passed value.\n\nThe project is built using g++ 9.4.0 and a makefile on Linux. The tests are written in google test.","project_url":"https://awesome.ecosyste.ms/api/v1/projects/github.com%2F4s4v1n%2Fstl-containers","html_url":"https://awesome.ecosyste.ms/projects/github.com%2F4s4v1n%2Fstl-containers","lists_url":"https://awesome.ecosyste.ms/api/v1/projects/github.com%2F4s4v1n%2Fstl-containers/lists"}