{"id":17724774,"url":"https://github.com/jibsen/scv","last_synced_at":"2025-05-07T13:05:23.305Z","repository":{"id":11069967,"uuid":"13413396","full_name":"jibsen/scv","owner":"jibsen","description":"ANSI C implementation of dynamic array, with interface similar to C++ std::vector","archived":false,"fork":false,"pushed_at":"2023-11-01T08:24:42.000Z","size":73,"stargazers_count":39,"open_issues_count":0,"forks_count":5,"subscribers_count":4,"default_branch":"master","last_synced_at":"2025-05-07T13:05:17.205Z","etag":null,"topics":["c","dynamic-array","vector"],"latest_commit_sha":null,"homepage":"","language":"C","has_issues":true,"has_wiki":null,"has_pages":null,"mirror_url":null,"source_name":null,"license":"apache-2.0","status":null,"scm":"git","pull_requests_enabled":true,"icon_url":"https://github.com/jibsen.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":"2013-10-08T12:57:59.000Z","updated_at":"2025-03-21T04:33:29.000Z","dependencies_parsed_at":"2024-10-25T20:08:24.399Z","dependency_job_id":"a85d88a5-85b1-4239-ba32-35d0350d6aa3","html_url":"https://github.com/jibsen/scv","commit_stats":null,"previous_names":[],"tags_count":0,"template":false,"template_full_name":null,"repository_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/jibsen%2Fscv","tags_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/jibsen%2Fscv/tags","releases_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/jibsen%2Fscv/releases","manifests_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/jibsen%2Fscv/manifests","owner_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/owners/jibsen","download_url":"https://codeload.github.com/jibsen/scv/tar.gz/refs/heads/master","host":{"name":"GitHub","url":"https://github.com","kind":"github","repositories_count":252883215,"owners_count":21819160,"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","dynamic-array","vector"],"created_at":"2024-10-25T15:48:44.054Z","updated_at":"2025-05-07T13:05:23.278Z","avatar_url":"https://github.com/jibsen.png","language":"C","funding_links":[],"categories":[],"sub_categories":[],"readme":"\nSimple C Vector\n===============\n\nCopyright 2003-2014 Joergen Ibsen\n\n\u003chttp://www.ibsensoftware.com/\u003e\n\n[![scv CI](https://github.com/jibsen/scv/actions/workflows/scv-ci-workflow.yaml/badge.svg)](https://github.com/jibsen/scv/actions) [![codecov](https://codecov.io/gh/jibsen/scv/branch/master/graph/badge.svg)](https://codecov.io/gh/jibsen/scv)\n\nAbout\n-----\n\nSimple C Vector (scv) is an ANSI C implementation of a [dynamic array][dyna],\nwith an interface similar to C++ [std::vector][vector].\n\nI wrote it for a project years ago, and decided to dust it off and make it\navailable under the [Apache License](LICENSE).\n\n[dyna]: http://en.wikipedia.org/wiki/Dynamic_array\n[vector]: http://en.cppreference.com/w/cpp/container/vector\n\n\nUsage\n-----\n\nThe include file `scv.h` contains documentation in the form of [doxygen][]\ncomments. A configuration file is included, run `doxygen` to generate\ndocumentation in HTML format.\n\nYou can add the source files `scv.c` and `scv.h` to your own projects.\n\nFor CI, scv uses [CMake][] to provide an easy way to build and test across\nvarious platforms and toolsets. To create a build system for the tools on\nyour platform, and build scv, use something along the lines of:\n\n~~~sh\nmkdir build\ncd build\ncmake ..\ncmake --build .\n~~~\n\n[doxygen]: http://www.doxygen.org/\n[CMake]: http://www.cmake.org/\n\n\nExample\n-------\n\nHere is an example that reads integer coordinates in the form `x,y`\ninto a `scv_vector` and prints them in lexicographical order:\n\n~~~c\n#include \u003cstdlib.h\u003e\n#include \u003cstdio.h\u003e\n\n#include \"scv.h\"\n\nstruct point {\n\tint x;\n\tint y;\n};\n\nint point_compare(const struct point *lhs, const struct point *rhs)\n{\n\tif (lhs-\u003ex == rhs-\u003ex) {\n\t\treturn lhs-\u003ey - rhs-\u003ey;\n\t}\n\n\treturn lhs-\u003ex - rhs-\u003ex;\n}\n\nint main(void)\n{\n\tstruct scv_vector *v;\n\tstruct point p;\n\tsize_t i;\n\n\t/* create a scv_vector of points, reserving space for 10 */\n\tv = scv_new(sizeof p, 10);\n\n\t/* read coordinates into p and append to v */\n\twhile (scanf(\"%d,%d\", \u0026p.x, \u0026p.y) == 2) {\n\t\tscv_push_back(v, \u0026p);\n\t}\n\n\t/* sort points in v */\n\tqsort(scv_data(v), scv_size(v), scv_objsize(v), point_compare);\n\n\t/* print points */\n\tfor (i = 0; i \u003c scv_size(v); ++i) {\n\t\tstruct point *pp = scv_at(v, i);\n\n\t\tprintf(\"%d,%d\\n\", pp-\u003ex, pp-\u003ey);\n\t}\n\n\tscv_delete(v);\n\n\treturn 0;\n}\n~~~\n\n\nDetails\n-------\n\nThe user is responsible for passing pointers to valid `scv_vector` structures.\nThe code contains assertions to help while debugging.\n\nTo enable the code to work in general, independent of the type of objects\nstored in a particular `scv_vector`, functions for inserting and accessing\nelements take and return `void` pointers.\n\nThis has the drawback that you cannot use a constant expression directly, but\nneed an actual object that you can pass a pointer to, when calling functions\nlike `scv_push_back()`.\n\nPointers into the memory used to hold the elements of a `scv_vector`, will be\nvalid until a function causes a reallocation. If you know the element type,\nand speed is important, you can use pointers to access the elements directly:\n\n~~~c\n\t/* v is a scv_vector of int, get a pointer to it's data */\n\tint *p = scv_data(v);\n\n\t/* we can access the elements of v using p */\n\tp[5] = 42;\n~~~\n\nscv uses `malloc()` for memory allocation, which works well in many cases,\nbut if needed, you could improve performance by using a custom allocator.\n","project_url":"https://awesome.ecosyste.ms/api/v1/projects/github.com%2Fjibsen%2Fscv","html_url":"https://awesome.ecosyste.ms/projects/github.com%2Fjibsen%2Fscv","lists_url":"https://awesome.ecosyste.ms/api/v1/projects/github.com%2Fjibsen%2Fscv/lists"}