{"id":20085512,"url":"https://github.com/Artifact-Works/LibC-STL","last_synced_at":"2025-05-06T01:33:03.679Z","repository":{"id":233787006,"uuid":"787812534","full_name":"Artifact-Works/LibC-STL","owner":"Artifact-Works","description":"A C++ STL implementation in C.","archived":false,"fork":false,"pushed_at":"2025-03-07T13:26:09.000Z","size":53,"stargazers_count":11,"open_issues_count":1,"forks_count":1,"subscribers_count":1,"default_branch":"main","last_synced_at":"2025-04-09T06:51:13.746Z","etag":null,"topics":["c","cpp","cpp17","dynamic-memory-allocation","library","stl-algorithms","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":"mit","status":null,"scm":"git","pull_requests_enabled":true,"icon_url":"https://github.com/Artifact-Works.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":"2024-04-17T08:25:25.000Z","updated_at":"2025-03-07T13:45:57.000Z","dependencies_parsed_at":"2024-04-17T11:01:35.558Z","dependency_job_id":"8712dd8c-9801-45b5-bd34-154d9cb8dc62","html_url":"https://github.com/Artifact-Works/LibC-STL","commit_stats":null,"previous_names":["sharoniv0x86/libc-stl","artifact-works/libc-stl"],"tags_count":0,"template":false,"template_full_name":null,"repository_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/Artifact-Works%2FLibC-STL","tags_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/Artifact-Works%2FLibC-STL/tags","releases_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/Artifact-Works%2FLibC-STL/releases","manifests_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/Artifact-Works%2FLibC-STL/manifests","owner_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/owners/Artifact-Works","download_url":"https://codeload.github.com/Artifact-Works/LibC-STL/tar.gz/refs/heads/main","host":{"name":"GitHub","url":"https://github.com","kind":"github","repositories_count":252604634,"owners_count":21775131,"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","cpp","cpp17","dynamic-memory-allocation","library","stl-algorithms","stl-containers"],"created_at":"2024-11-13T15:56:20.535Z","updated_at":"2025-05-06T01:33:03.671Z","avatar_url":"https://github.com/Artifact-Works.png","language":"C","funding_links":[],"categories":[],"sub_categories":[],"readme":"# LibC-STL: A C Implementation of Standard Template Library (STL)\n\n## Overview\n\nC-STL is a project aimed at implementing a subset of the functionality provided by the C++ Standard Template Library (STL) in pure C. The motivation behind this project stems from the efficiency and versatility of the C++ STL, which has been widely acclaimed as one of the most efficient code libraries in C++. This projects aims at implementing C++ STL in C as efficient and as easy to use as possible.\n\n## Motivation\nThe C++ STL is renowned for its rich collection of data structures, algorithms, and utilities, which simplify and streamline the process of software development in C++. Recognizing the value and efficiency of the STL, this project seeks to bridge this gap by bringing some of the essential features of the STL to the C programming language.\n\n## Project Goals\n- Implement core data structures such as vectors, linked lists, stacks, queues, maps, and sets in C.\n- Develop efficient algorithms for common operations like sorting, searching, and manipulation of data structures.\n- Provide a user-friendly interface and intuitive API for easy integration into C projects.\n- Ensure compatibility and portability across different platforms and compilers.\n- Foster a community of contributors and users to collaborate on further enhancements and improvements.\n\n## Key Features\n- **Vector**: Resizable arrays similar to vectors in C++. [Example](#example)\n- **Iterators**: C++ style iterators to iterate containers efficiently.\n- **Linked List**: Singly linked lists, doubly linked lists, and circular linked lists. [to be implemened]\n- **Stacks and Queues**: Implementations using arrays or linked lists. [to be implemened]\n- **Maps and Sets**: Hash maps or binary search trees for key-value pairs and unique elements. [to be implemened]\n- **String Manipulation**: Functions for manipulating strings, including concatenation, substring extraction, and searching. [to be implemened]\n- **Algorithms**: Common algorithms for sorting, searching, and manipulation of sequences. [to be implemened]\n- **Error Handling**: Mechanisms for error handling and exception management. [to be implemened]\n\n# Contributing\nContributors are welcomed add more functionalities or fixes..\n- Raise an issue about the about feature you want to add and wait for it to assigned to you.\n- Or check any existing issue if you want to work on them [Issues](https://github.com/SharonIV0x86/LibC-STL/issues)\n- Edit your code and open the PR, documentation will be taken care of. Feel free to share if you have anything extra to add in docs.\n- Make sure to add block comments above your added feature.\n\n## License\nThis project is licensed under the [MIT License](LICENSE). Feel free to use, modify, and distribute the code according to the terms of the license.\n\n### Note from maintainer\nThis project serves as a learning endeavor for me to explore dynamic memory management in C, gaining insights into the STL in C++, and honing skills in library design and DSA. I'm eager to see this project flourish and evolve further.\n\n## Example\n```c\n#include \u003cstdio.h\u003e\n#include \"./include/Vector.h\"\n\ntypedef struct mystruct\n{\n    int data;\n    char *name;\n} MyStruct;\n\nint main()\n{\n    Vector *int_vec = vector_create(sizeof(int));\n\n    int values[] = {10, 20, 30, 40, 50};\n    for (int i = 0; i \u003c 5; i++)\n    {\n        vector_push_back(int_vec, \u0026values[i]);\n    }\n\n    printf(\"Integer Vector:\\n\");\n    for (size_t i = 0; i \u003c vector_size(int_vec); i++)\n    {\n        printf(\"%d \", *(int *)vector_at(int_vec, i));\n    }\n    printf(\"\\n\");\n\n    vector_destroy(int_vec);\n\n    Vector *double_vec = vector_create(sizeof(double));\n\n    double dvalues[] = {1.1, 2.2, 3.3, 4.4};\n    for (int i = 0; i \u003c 4; i++)\n    {\n        vector_push_back(double_vec, \u0026dvalues[i]);\n    }\n\n    printf(\"Double Vector:\\n\");\n    for (size_t i = 0; i \u003c vector_size(double_vec); i++)\n    {\n        printf(\"%.1f \", *(double *)vector_at(double_vec, i));\n    }\n    printf(\"\\n\");\n\n    vector_destroy(double_vec);\n    MyStruct v1 = {10, \"Jasper\"};\n    MyStruct v2 = {20, \"Kasper\"};\n    MyStruct v3 = {30, \"Hasper\"};\n    MyStruct v4 = {40, \"Gasper\"};\n\n    Vector *custom_vec = vector_create(sizeof(MyStruct));\n    vector_push_back(custom_vec, \u0026v1);\n    vector_push_back(custom_vec, \u0026v2);\n    vector_push_back(custom_vec, \u0026v3);\n    vector_push_back(custom_vec, \u0026v4);\n     \n    for(size_t i = 0; i \u003c vector_size(custom_vec); i++){\n        MyStruct *item = (MyStruct*)vector_at(custom_vec, i);\n        printf(\"%d %s\\n\", item-\u003edata, item-\u003ename);\n    }\n\n    return 0;\n}\n\n\n```\n## Error Handling\n\nAll functions that modify vectors return predefined error codes.  \n\n| Error Code         | Description                          |\n|--------------------|----------------------------------|\n| `SUCCESS (1)`     | Operation successful              |\n| `FAILURE (0)`     | Generic failure                  |\n| `ERR_INVALID_TYPE (-1)` | Invalid data type for vector  |\n| `ERR_OUT_OF_MEMORY (-2)` | Memory allocation failed     |\n| `ERR_INDEX_OUT_OF_BOUNDS (-3)` | Index out of range     |\n| `ERR_NULL_POINTER (-4)` | Null pointer detected        |\n\n### Example Usage:\n```c\nVector *vec = create_vector(5, INT);\nif (!vec) {\n    printf(\"Error: Vector creation failed\\n\");\n}\n\nint status = push_back_int(vec, 10);\nif (status != SUCCESS) {\n    printf(\"Error: push_back_int failed with error code %d\\n\", status);\n}\nyaml\nCopy\nEdit\n\n## Feedback and Support\nIf you have any feedback, suggestions, or questions regarding the project, please feel free to open an issue.\n\n## Acknowledgements\nWe would like to express our gratitude to the creators and maintainers of the C++ STL, whose work has inspired this project. Additionally, we thank all contributors and users for their valuable feedback and contributions.\n","project_url":"https://awesome.ecosyste.ms/api/v1/projects/github.com%2FArtifact-Works%2FLibC-STL","html_url":"https://awesome.ecosyste.ms/projects/github.com%2FArtifact-Works%2FLibC-STL","lists_url":"https://awesome.ecosyste.ms/api/v1/projects/github.com%2FArtifact-Works%2FLibC-STL/lists"}