{"id":35005003,"url":"https://github.com/martincapovcak/data-structures","last_synced_at":"2026-05-22T06:09:07.370Z","repository":{"id":60155415,"uuid":"540633332","full_name":"martincapovcak/data-structures","owner":"martincapovcak","description":"Data-structures demo plus mocha / chai tests","archived":false,"fork":false,"pushed_at":"2022-10-04T20:26:05.000Z","size":40,"stargazers_count":0,"open_issues_count":0,"forks_count":0,"subscribers_count":1,"default_branch":"main","last_synced_at":"2023-03-21T04:38:10.764Z","etag":null,"topics":["data-structures"],"latest_commit_sha":null,"homepage":"","language":"JavaScript","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/martincapovcak.png","metadata":{"files":{"readme":"README.md","changelog":null,"contributing":null,"funding":null,"license":"LICENSE","code_of_conduct":"CODE-OF-CONDUCT.md","threat_model":null,"audit":null,"citation":null,"codeowners":null,"security":null,"support":null}},"created_at":"2022-09-23T22:14:04.000Z","updated_at":"2022-10-04T20:55:15.000Z","dependencies_parsed_at":"2023-01-19T05:45:17.608Z","dependency_job_id":null,"html_url":"https://github.com/martincapovcak/data-structures","commit_stats":null,"previous_names":[],"tags_count":null,"template":null,"template_full_name":null,"purl":"pkg:github/martincapovcak/data-structures","repository_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/martincapovcak%2Fdata-structures","tags_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/martincapovcak%2Fdata-structures/tags","releases_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/martincapovcak%2Fdata-structures/releases","manifests_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/martincapovcak%2Fdata-structures/manifests","owner_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/owners/martincapovcak","download_url":"https://codeload.github.com/martincapovcak/data-structures/tar.gz/refs/heads/main","sbom_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/martincapovcak%2Fdata-structures/sbom","scorecard":null,"host":{"name":"GitHub","url":"https://github.com","kind":"github","repositories_count":286080680,"owners_count":28072322,"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","status":"online","status_checked_at":"2025-12-27T02:00:05.897Z","response_time":58,"last_error":null,"robots_txt_status":"success","robots_txt_updated_at":"2025-07-24T06:49:26.215Z","robots_txt_url":"https://github.com/robots.txt","online":true,"can_crawl_api":true,"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":["data-structures"],"created_at":"2025-12-27T04:34:43.271Z","updated_at":"2025-12-27T04:34:43.794Z","avatar_url":"https://github.com/martincapovcak.png","language":"JavaScript","funding_links":[],"categories":[],"sub_categories":[],"readme":"# Data-structures\n\nDatastructures demo plus mocha / chai tests\n\n1. Stack\n2. Queue\n3. Linked List\n4. Hash Table\n\n---\n\n## Stack\n\n_\"Last in first out\"_\n\n### Test\n\n```sh\n$ npm run test-stack\n```\n\n### Usage\n\n```js\nconst { Stack } = require('./lib/stack.js');\nconst stack = new Stack();\n```\n\n### # Properties\n\n- items\n\n#### \u003e items\n\nType: Array\u003c/br\u003e\nVisibility: Private\u003c/br\u003e\nInfo: Stores the stack\n\n### # Methods\n\n- push()\n- pop()\n- peek()\n- size()\n- isEmpty()\n- print()\n- purge()\n\n#### \u003e push(param)\n\n@param: element\u003c/br\u003e\n@Type: Any\n\nInfo: Adds element to the top of a stack\n\n#### \u003e pop()\n\nReturns: element\u003c/br\u003e\nInfo: Removes top element from stack and returns it\n\n#### \u003e peek()\n\nReturns: element\u003c/br\u003e\nInfo: Returns top element from the stack\n\n#### \u003e size()\n\nReturns: Number\u003c/br\u003e\nInfo: Returns the size of a stack\n\n#### \u003e isEmpty()\n\nReturns: Bool\u003c/br\u003e\nInfo: Returns true if the stack is empty, else returns false\n\n#### \u003e print()\n\nInfo: Prints Queue as a table to console\n\n#### \u003e purge()\n\nInfo: Removes all elements from the stack\n\n---\n\n## Queue\n\n_\"First in first out\"_\n\n### Test\n\n```sh\n$ npm run test-queue\n```\n\n### Usage\n\n```js\nconst { Queue } = require('./lib/queue.js');\nconst q = new Queue();\n```\n\n### # Properties\n\n- first\n- last\n- size\n\n#### \u003e first\n\nDefault: null\u003c/br\u003e\nInfo: Stores the first node in queue\n\n#### \u003e last\n\nDefault: null\u003c/br\u003e\nInfo: Stores the first node in queue\n\n#### \u003e size\n\nType: number\u003c/br\u003e\nDefault: 0\u003c/br\u003e\nVisibility: Private\u003c/br\u003e\n\n### # Methods\n\n- size\n- toArray()\n- enqueue()\n- dequeue()\n- print()\n- purge()\n\n#### \u003e size\n\nType: Getter\u003c/br\u003e\nInfo: Returns the length of a queue\n\n#### \u003e toArray(param)\n\n@param\u003c/br\u003e\n@Type: Any\n\nType: Static\u003c/br\u003e\nInfo: Converts Queue structure to an array\n\n#### \u003e enqueue(param)\n\n@param: value\u003c/br\u003e\n@Type: Any\n\nInfo: Creates new node and add it to a queue\n\n#### \u003e dequeue()\n\nInfo: Removes first node from queue and returns its value\n\n#### \u003e print()\n\nInfo: Prints Queue as a table to console\n\n#### \u003e purge()\n\nInfo: Purge all nodes and reset queue to default settings\n\n---\n\n## Linked List\n\n### Test\n\n```sh\n$ npm run test-linkedlist\n```\n\n### Usage\n\n```js\nconst { LinkedList } = require('./lib/linked-list.js');\nconst linkedList = new LinkedList();\n```\n\n### # Properties\n\n- head\n- tail\n\n#### \u003e head\n\nDefault: null\u003c/br\u003e\nInfo: Stores the first node of a Linked-list\n\n#### \u003e tail\n\nDefault: null\u003c/br\u003e\nInfo: Stores the last node of a Linked-list\n\n### # Methods\n\n- append()\n- prepend()\n- size()\n- toArray()\n- print()\n- indexOf()\n- elementAt()\n- addAt()\n- removeAt()\n- pop()\n- delete()\n- reverse()\n\n#### \u003e append(param)\n\n@param: value\u003c/br\u003e\n@Type: Any\n\nInfo: Creates a new node with given value as param at the end of a linked-list\n\n#### \u003e prepend(param)\n\n@param: value\u003c/br\u003e\n@Type: Any\n\nInfo: Creates a new node with given value as param at the very begining of i linked-list\n\n#### \u003e size()\n\nInfo: Returns the size of linked-list\n\n#### \u003e toArray(param)\n\n@param\u003c/br\u003e\n@type: Any\n\nType: Static\u003c/br\u003e\nInfo: Converts linked-list structure to an array\n\n#### \u003e print()\n\nInfo: Prints linked-list as a table to console\n\n#### \u003e indexOf(param)\n\n@param: value\u003c/br\u003e\n@Type: Any\n\nInfo: Searches for node with value of given param. Returns node index\n\n#### \u003e elementAt(param)\n\n@param: index\u003c/br\u003e\n@Type: Number\n\nInfo: Searches for node at given index as param. Returns node value\n\n#### \u003e addAt(param1, param2)\n\n@param1: index\u003c/br\u003e\n@Type: Number\n\n@param2: value\u003c/br\u003e\n@Type: Any\n\nInfo: Creates new node at certain index with given value\n\n#### \u003e removeAt(param)\n\n@param: index\u003c/br\u003e\n@Type: Number\n\nInfo: Removes node at certain index from linked-list\n\n#### \u003e pop()\n\nInfo: Removes last node from linked-list and returnes it\n\n#### \u003e delete(param)\n\n@param: value\u003c/br\u003e\n@Type: Any\n\nInfo: Removes every node from linked-list which value match the param\n\n#### \u003e reverse()\n\nInfo: Reverse nodes order in the linked-list\n\n---\n\n## Hash Table\n\n### Test\n\n```sh\n$ npm run test-hashtable\n```\n\n### Usage\n\n```js\nconst { HashTable } = require('./lib/hash-table.js');\nconst ht = new HashTable();\n```\n\n### # Properties\n\n- table\n- size\n\n#### \u003e table\n\nType: Array\u003c/br\u003e\nDefault: Array(127)\n\n#### \u003e size\n\nType: Number\u003c/br\u003e\nDefault: 0\n\n### # Methods\n\n- hash()\n- set()\n- get()\n- remove()\n- print()\n\n#### \u003e hash(param1, param2)\n\n@param1: key \u003c/br\u003e\n@Type: String\n\n@param2: value\u003c/br\u003e\n@Type: Any\n\nType: Static\nInfo: Returns hash for given key in tke max length of a scope param\n\n#### \u003e set(param1, param2)\n\n@param1: key \u003c/br\u003e\n@Type: String\n\n@param2: value\u003c/br\u003e\n@Type: Any\n\nInfo: Create a new record in the hash-table\n\n#### \u003e get(param)\n\n@param: key \u003c/br\u003e\n@Type: String\n\nInfo: Returns back value of a record with given key as a param\n\n#### \u003e remove(param)\n\n@param: key \u003c/br\u003e\n@Type: String\n\nInfo: Removes record from hash-table\n\n#### \u003e print()\n\nInfo: Prints hash-table as a table to the console\n","project_url":"https://awesome.ecosyste.ms/api/v1/projects/github.com%2Fmartincapovcak%2Fdata-structures","html_url":"https://awesome.ecosyste.ms/projects/github.com%2Fmartincapovcak%2Fdata-structures","lists_url":"https://awesome.ecosyste.ms/api/v1/projects/github.com%2Fmartincapovcak%2Fdata-structures/lists"}