{"id":18009627,"url":"https://github.com/mkostoevr/cvec","last_synced_at":"2025-10-24T19:31:00.555Z","repository":{"id":185591549,"uuid":"311110112","full_name":"mkostoevr/cvec","owner":"mkostoevr","description":"std::vector implementation in C","archived":false,"fork":false,"pushed_at":"2024-05-18T22:46:22.000Z","size":126,"stargazers_count":1,"open_issues_count":0,"forks_count":0,"subscribers_count":1,"default_branch":"master","last_synced_at":"2024-12-17T15:46:54.649Z","etag":null,"topics":["c","dependency-free","header-only","independent","no-dependencies","std","std-vector","vector"],"latest_commit_sha":null,"homepage":"","language":"C++","has_issues":true,"has_wiki":null,"has_pages":null,"mirror_url":null,"source_name":null,"license":"mit","status":null,"scm":"git","pull_requests_enabled":true,"icon_url":"https://github.com/mkostoevr.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,"roadmap":null,"authors":null,"dei":null,"publiccode":null,"codemeta":null}},"created_at":"2020-11-08T16:53:21.000Z","updated_at":"2024-05-18T22:46:25.000Z","dependencies_parsed_at":null,"dependency_job_id":"0e6dbccd-fd41-46d2-9092-0900d4f8be05","html_url":"https://github.com/mkostoevr/cvec","commit_stats":null,"previous_names":["mkostoevr/cvec"],"tags_count":0,"template":false,"template_full_name":null,"repository_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/mkostoevr%2Fcvec","tags_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/mkostoevr%2Fcvec/tags","releases_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/mkostoevr%2Fcvec/releases","manifests_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/mkostoevr%2Fcvec/manifests","owner_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/owners/mkostoevr","download_url":"https://codeload.github.com/mkostoevr/cvec/tar.gz/refs/heads/master","host":{"name":"GitHub","url":"https://github.com","kind":"github","repositories_count":238029818,"owners_count":19404856,"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":["c","dependency-free","header-only","independent","no-dependencies","std","std-vector","vector"],"created_at":"2024-10-30T02:09:56.080Z","updated_at":"2025-10-24T19:31:00.215Z","avatar_url":"https://github.com/mkostoevr.png","language":"C++","funding_links":[],"categories":[],"sub_categories":[],"readme":"# cvec - partial `std::vector` implementation in C.\n## Partial implementation of `std::vector`\n\nMember functions table:\n\n| Status | Name | Function or reason if not implemented |\n| :---: | --- | --- |\n| :heavy_check_mark: | `(constructor)` | `new` |\n| :heavy_check_mark: | `(destructor)` | `free` |\n| :heavy_check_mark: | `operator=` | `assign_other` |\n| :heavy_check_mark: | `assign` | `assign_fill`, `assign_range` |\n| :heavy_minus_sign: | `get_allocator` | No `allocator` objects in the language |\n| :heavy_check_mark: | `at` | `at` |\n| :heavy_check_mark: | `operator[]` | `[]` |\n| :heavy_check_mark: | `front` | `front`, `front_p` |\n| :heavy_check_mark: | `back` | `back`, `back_p` |\n| :heavy_check_mark: | `data` | `data` |\n| :heavy_check_mark: | `begin` | `begin` |\n| :heavy_check_mark: | `cbegin` | `cbegin` |\n| :heavy_check_mark: | `end` | `end` |\n| :heavy_check_mark: | `cend` | `cend` |\n| :heavy_minus_sign: | `rbegin` | No reverse iterators in the language |\n| :heavy_minus_sign: | `crbegin` | No reverse iterators in the language |\n| :heavy_minus_sign: | `rend` | No reverse iterators in the language |\n| :heavy_minus_sign: | `crend` | No reverse iterators in the language |\n| :heavy_check_mark: | `empty` | `empty` |\n| :heavy_check_mark: | `size` | `size` |\n| :heavy_check_mark: | `max_size` | `max_size` |\n| :heavy_check_mark: | `reserve` | `reserve` |\n| :heavy_check_mark: | `capacity` | `capacity` |\n| :heavy_check_mark: | `shrink_to_fit` | `shrink_to_fit` |\n| :heavy_check_mark: | `clear` | `clear` |\n| :heavy_check_mark: | `insert` | `insert`, `insert_it` |\n| :heavy_minus_sign: | `emplace` | I know no way to preserve the original signature |\n| :heavy_check_mark: | `erase` | `erase` |\n| :heavy_check_mark: | `push_back` | `push_back` |\n| :heavy_minus_sign: | `emplace_back` | I know no way to preserve the original signature |\n| :heavy_check_mark: | `pop_back` | `pop_back` |\n| :heavy_check_mark: | `resize` | `resize` |\n| :heavy_minus_sign: | `swap` | Would have n complexity in this implementation |\n\n## Easy to use\n\nTo use the std::vector implementation for specified type they should be declared as follows:\n\n```C\n#define CVEC_TYPE TypeOfVectorElement\n#include \"cvec.h\"\n\n// ...\n\n    TypeOfVectorElement *vec = cvec_TypeOfVectorElement_new(128);\n    \n    cvec_TypeOfVectorElement_push_back(\u0026vec, value);\n```\n\nAlso somewhere in the project the functinos should be instantiated as follows:\n\n```C\n#define CVEC_TYPE TypeOfVectorElement\n#define CVEC_INST\n#include \"cvec.h\"\n```\n\n## Allows using of custom allocators.\n\n```C\n#define CVEC_TYPE pchar\n#define CVEC_INST\n#define CVEC_MALLOC custom_malloc\n#define CVEC_REALLOC custom_realloc\n#define CVEC_FREE custom_free\n#include \"cvec.h\"\n```\n\n## Allows handling of exceptional cases.\n\n```C\n#define CVEC_TYPE pchar\n#define CVEC_INST\n// Set Out Of Bounds handler\n#define CVEC_OOBH(funcname, vec, index) printf(\"Out of bounds in %s (vec = %p, i = %d)\", funcname, vec, index); abort();\n#include \"cvec.h\"\n```\n\n## Has no fixed dependencies\n\nEvery function it uses may be overridden. More information about dependencies in [cvec.h](cvec.h).\n","project_url":"https://awesome.ecosyste.ms/api/v1/projects/github.com%2Fmkostoevr%2Fcvec","html_url":"https://awesome.ecosyste.ms/projects/github.com%2Fmkostoevr%2Fcvec","lists_url":"https://awesome.ecosyste.ms/api/v1/projects/github.com%2Fmkostoevr%2Fcvec/lists"}