{"id":24617792,"url":"https://github.com/jacoblincool/universal-data-structures","last_synced_at":"2025-03-18T21:27:19.273Z","repository":{"id":38190136,"uuid":"472923627","full_name":"JacobLinCool/Universal-Data-Structures","owner":"JacobLinCool","description":"Lightweight implementation of generic and powerful data structures in C. Vector, Deque, ...","archived":false,"fork":false,"pushed_at":"2023-12-15T02:21:08.000Z","size":33,"stargazers_count":1,"open_issues_count":1,"forks_count":0,"subscribers_count":3,"default_branch":"main","last_synced_at":"2025-01-24T23:41:18.204Z","etag":null,"topics":[],"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/JacobLinCool.png","metadata":{"files":{"readme":"README.md","changelog":null,"contributing":"CONTRIBUTING.md","funding":null,"license":"LICENSE","code_of_conduct":"CODE_OF_CONDUCT.md","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":"2022-03-22T20:15:48.000Z","updated_at":"2022-04-15T17:48:56.000Z","dependencies_parsed_at":"2025-01-24T23:41:05.140Z","dependency_job_id":null,"html_url":"https://github.com/JacobLinCool/Universal-Data-Structures","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/JacobLinCool%2FUniversal-Data-Structures","tags_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/JacobLinCool%2FUniversal-Data-Structures/tags","releases_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/JacobLinCool%2FUniversal-Data-Structures/releases","manifests_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/JacobLinCool%2FUniversal-Data-Structures/manifests","owner_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/owners/JacobLinCool","download_url":"https://codeload.github.com/JacobLinCool/Universal-Data-Structures/tar.gz/refs/heads/main","host":{"name":"GitHub","url":"https://github.com","kind":"github","repositories_count":244308769,"owners_count":20432261,"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":[],"created_at":"2025-01-24T23:40:59.212Z","updated_at":"2025-03-18T21:27:19.255Z","avatar_url":"https://github.com/JacobLinCool.png","language":"C","funding_links":[],"categories":[],"sub_categories":[],"readme":"\u003cdiv align=\"center\"\u003e\n\n# Universal Data Structures\n\nLightweight implementation of generic and powerful data structures in C.\n\n[vector](#vectorh) ·\n[map](#maph) ·\n[set](#seth) ·\n[queue](#queueh) ·\n[stack](#stackh) ·\n[deque](#dequeh)\n\n[xor list](#xor-listh)\n\n\u003c/div\u003e\n\n## Usage\n\nThey are just header files.\n\nYou can directly include them in your project (or paste them in your code).\n\n## Features\n\n### [`vector.h`](./src/vector.h)\n\nAuto-managed dynamic array of any type.\n\n```c\n/** Construct a new vector struct */\nStructVector(_name, _type, _fallback);\n/** Example: */\nStructVector(MyVector, int, INT32_MIN);\n```\n\n#### constructor\n\nCreate an instance of a defined vector struct.\n\n```c\nMyVector* vec = create_MyVector();\n```\n\n#### properties\n\n- `vec-\u003esize`: the number of elements in the vector `vec`\n- `vec-\u003ecapacity`: the current capacity of the vector `vec`\n\n#### methods\n\n- `void vec-\u003epush(vec, elm)`: _**`O(1)`**_ add an element to the end of the vector `vec`\n- `_type vec-\u003epop(vec)`: _**`O(1)`**_ remove and return the last element of the vector `vec`\n- `_type vec-\u003eback(vec)`: _**`O(1)`**_ get the last element of the vector `vec`\n- `void vec-\u003eunshift(vec, elm)`: _**`O(n)`**_ add an element to the beginning of the vector `vec`\n- `_type vec-\u003eshift(vec)`: _**`O(n)`**_ remove and return the first element of the vector `vec`\n- `_type vec-\u003efront(vec)`: _**`O(1)`**_ get the first element of the vector `vec`\n- `void vec-\u003einsert(vec, idx, elm)`: _**`O(n)`**_ insert an element at `idx` of the vector `vec`\n- `_type vec-\u003eremove(vec, idx)`: _**`O(n)`**_ remove and return the element at `idx` of the vector `vec`\n- `void vec-\u003eset(vec, idx, elm)`: _**`O(1)`**_ set the element at `idx` of the vector `vec` to `elm`\n- `_type vec-\u003eget(vec, idx)`: _**`O(1)`**_ get the element at `idx` of the vector `vec`\n- `void vec-\u003eclear(vec)`: _**`O(1)`**_ remove all elements from the vector `vec`\n- `void vec-\u003efree(vec)`: _**`O(1)`**_ free the vector `vec`\n\n#### utilities\n\nYou can use `VectorInspect` to inspect a vector.\n\n```c\n/** Inspect the vector \"vec\" with print format \"%d\" */\nVectorInspect(vec, \"%d\");\n```\n\n#### example\n\nSee [vector.ex.c](./ex/vector.ex.c).\n\n### `map.h`\n\n_**Not Implemented Yet. [Any Contribution is Welcome!](./CONTRIBUTING.md)**_\n\n### `set.h`\n\n_**Not Implemented Yet. [Any Contribution is Welcome!](./CONTRIBUTING.md)**_\n\n### `queue.h`\n\n_**Not Implemented Yet. [Any Contribution is Welcome!](./CONTRIBUTING.md)**_\n\nYou can make `deque` to behave like a `queue` by using `unshift` and `shift`.\n\n### `stack.h`\n\n_**Not Implemented Yet. [Any Contribution is Welcome!](./CONTRIBUTING.md)**_\n\nYou can make `deque` to behave like a `stack` by using `push` and `pop`.\n\n### [`deque.h`](./src/deque.h)\n\nDouble-ended queue of any type, implemented with _`XOR List`_.\n\n```c\n/** Construct a new deque struct */\nStructDeque(_name, _type, _fallback);\n/** Example: */\nStructDeque(MyDeque, int, INT32_MIN);\n```\n\n#### constructor\n\nCreate an instance of a defined deque struct.\n\n```c\nMyDeque* deque = create_MyDeque();\n```\n\n#### properties\n\n- `deque-\u003ehead`: the head node of underlying xor-list\n- `deque-\u003etail`: the tail node of underlying xor-list\n- `deque-\u003esize`: the number of elements in the deque `deque`\n\n#### methods\n\n- `void deque-\u003epush(deque, elm)`: _**`O(1)`**_ add an element to the end of the deque `deque`\n- `void deque-\u003eunshift(deque, elm)`: _**`O(1)`**_ add an element to the beginning of the deque `deque`\n- `_type deque-\u003epop(deque)`: _**`O(1)`**_ remove and return the last element of the deque `deque`\n- `_type deque-\u003eshift(deque)`: _**`O(1)`**_ remove and return the first element of the deque `deque`\n- `_type deque-\u003eback(deque)`: _**`O(1)`**_ get the last element of the deque `deque`\n- `_type deque-\u003efront(deque)`: _**`O(1)`**_ get the first element of the deque `deque`\n- `void deque-\u003ereverse(deque)`: _**`O(1)`**_ reverse the order of the elements in the deque `deque`\n- `void deque-\u003econcat(deque, other)`: _**`O(1)`**_ concatenate the elements of the deque `other` to the end of the deque `deque`, this method will remove all elements in `other`, but not free `other`\n- `void deque-\u003eclear(deque)`: _**`O(n)`**_ remove all elements from the deque `deque`\n- `void deque-\u003efree(deque)`: _**`O(n)`**_ free the deque `deque`\n\n#### utilities\n\nYou can use `DequeInspect` to inspect a deque.\n\n```c\n/** Inspect the deque \"deque\" with print format \"%d\" */\nDequeInspect(deque, \"%d\");\n```\n\n#### example\n\nSee [deque.ex.c](./ex/deque.ex.c).\n\n### [`xor-list.h`](./src/xor-list.h)\n\nMemory efficient doubly linked list of any type.\n\n```c\n/** Construct a new XOR list node struct */\nStructXORListNode(_name, _type);\n/** Example: */\nStructXORListNode(MyNode, int);\n```\n\n#### constructor\n\nCreate a node of a defined XOR list node struct.\n\n```c\nMyNode* node = create_Node(123);\n```\n\n#### properties\n\n- `node-\u003eval`: the value of the node `node`\n- `node-\u003ebeacon`: the pointer \"beacon\" of the node `node`\n\n\u003e pointer beacon: the xor result of the previous and next node address\n\n#### methods\n\n- `_name* node-\u003exor(node_a, node_b)`: _**`O(1)`**_ get the xor of the node `node_a` and `node_b`\n- `_name* node-\u003eleft(node, right)`: _**`O(1)`**_ get the left node of the node `node`\n- `_name* node-\u003eright(node, left)`: _**`O(1)`**_ get the right node of the node `node`\n- `void node-\u003einsert(node, left, right)`: _**`O(1)`**_ insert the node `node` between `left` and `right`\n- `void node-\u003eremove(node, adjacent)`: _**`O(1)`**_ remove the node `node` by giving one of its adjacent nodes `adjacent`\n- `size_t node-\u003etraverse(node, next, func)`: _**`O(n)`**_ traverse the list from `node` and `next` is the direction. `func` is the callback function for each node\n- `void node-\u003efree(node)`: _**`O(1)`**_ free the node `node`\n\n#### utilities\n\nThere are no utilities for `xor-list`.\n\n#### example\n\nSee [xor-list.ex.c](./ex/xor-list.ex.c).\n","project_url":"https://awesome.ecosyste.ms/api/v1/projects/github.com%2Fjacoblincool%2Funiversal-data-structures","html_url":"https://awesome.ecosyste.ms/projects/github.com%2Fjacoblincool%2Funiversal-data-structures","lists_url":"https://awesome.ecosyste.ms/api/v1/projects/github.com%2Fjacoblincool%2Funiversal-data-structures/lists"}