{"id":23168891,"url":"https://github.com/toreda/adt","last_synced_at":"2026-05-09T04:32:45.450Z","repository":{"id":51147117,"uuid":"258919438","full_name":"toreda/adt","owner":"toreda","description":"Suite of simple yet powerful data structures for TypeScript.","archived":false,"fork":false,"pushed_at":"2021-11-08T11:20:22.000Z","size":740,"stargazers_count":1,"open_issues_count":1,"forks_count":0,"subscribers_count":2,"default_branch":"master","last_synced_at":"2025-09-22T15:01:59.013Z","etag":null,"topics":["abstract-data-types","javascript","queue","stack","typed","types","typescript","typescript-generics","yarn"],"latest_commit_sha":null,"homepage":"","language":"TypeScript","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/toreda.png","metadata":{"files":{"readme":"README.md","changelog":"CHANGELOG.md","contributing":null,"funding":null,"license":"LICENSE","code_of_conduct":null,"threat_model":null,"audit":null,"citation":null,"codeowners":null,"security":null,"support":null}},"created_at":"2020-04-26T02:20:25.000Z","updated_at":"2022-04-28T15:27:43.000Z","dependencies_parsed_at":"2022-08-30T15:22:01.875Z","dependency_job_id":null,"html_url":"https://github.com/toreda/adt","commit_stats":null,"previous_names":[],"tags_count":1,"template":false,"template_full_name":null,"purl":"pkg:github/toreda/adt","repository_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/toreda%2Fadt","tags_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/toreda%2Fadt/tags","releases_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/toreda%2Fadt/releases","manifests_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/toreda%2Fadt/manifests","owner_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/owners/toreda","download_url":"https://codeload.github.com/toreda/adt/tar.gz/refs/heads/master","sbom_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/toreda%2Fadt/sbom","scorecard":{"id":894887,"data":{"date":"2025-08-11","repo":{"name":"github.com/toreda/adt","commit":"710657fbade01ddded6916b783bbcceab980c945"},"scorecard":{"version":"v5.2.1-40-gf6ed084d","commit":"f6ed084d17c9236477efd66e5b258b9d4cc7b389"},"score":3.4,"checks":[{"name":"Code-Review","score":6,"reason":"Found 3/5 approved changesets -- score normalized to 6","details":null,"documentation":{"short":"Determines if the project requires human code review before pull requests (aka merge requests) are merged.","url":"https://github.com/ossf/scorecard/blob/f6ed084d17c9236477efd66e5b258b9d4cc7b389/docs/checks.md#code-review"}},{"name":"Maintained","score":0,"reason":"0 commit(s) and 0 issue activity found in the last 90 days -- score normalized to 0","details":null,"documentation":{"short":"Determines if the project is \"actively maintained\".","url":"https://github.com/ossf/scorecard/blob/f6ed084d17c9236477efd66e5b258b9d4cc7b389/docs/checks.md#maintained"}},{"name":"Packaging","score":-1,"reason":"packaging workflow not detected","details":["Warn: no GitHub/GitLab publishing workflow detected."],"documentation":{"short":"Determines if the project is published as a package that others can easily download, install, easily update, and uninstall.","url":"https://github.com/ossf/scorecard/blob/f6ed084d17c9236477efd66e5b258b9d4cc7b389/docs/checks.md#packaging"}},{"name":"Token-Permissions","score":0,"reason":"detected GitHub workflow tokens with excessive permissions","details":["Warn: no topLevel permission defined: .github/workflows/main.yml:1","Info: no jobLevel write permissions found"],"documentation":{"short":"Determines if the project's workflows follow the principle of least privilege.","url":"https://github.com/ossf/scorecard/blob/f6ed084d17c9236477efd66e5b258b9d4cc7b389/docs/checks.md#token-permissions"}},{"name":"Dangerous-Workflow","score":10,"reason":"no dangerous workflow patterns detected","details":null,"documentation":{"short":"Determines if the project's GitHub Action workflows avoid dangerous patterns.","url":"https://github.com/ossf/scorecard/blob/f6ed084d17c9236477efd66e5b258b9d4cc7b389/docs/checks.md#dangerous-workflow"}},{"name":"Binary-Artifacts","score":10,"reason":"no binaries found in the repo","details":null,"documentation":{"short":"Determines if the project has generated executable (binary) artifacts in the source repository.","url":"https://github.com/ossf/scorecard/blob/f6ed084d17c9236477efd66e5b258b9d4cc7b389/docs/checks.md#binary-artifacts"}},{"name":"Pinned-Dependencies","score":0,"reason":"dependency not pinned by hash detected -- score normalized to 0","details":["Warn: GitHub-owned GitHubAction not pinned by hash: .github/workflows/main.yml:21: update your workflow using https://app.stepsecurity.io/secureworkflow/toreda/adt/main.yml/master?enable=pin","Warn: GitHub-owned GitHubAction not pinned by hash: .github/workflows/main.yml:23: update your workflow using https://app.stepsecurity.io/secureworkflow/toreda/adt/main.yml/master?enable=pin","Warn: GitHub-owned GitHubAction not pinned by hash: .github/workflows/main.yml:31: update your workflow using https://app.stepsecurity.io/secureworkflow/toreda/adt/main.yml/master?enable=pin","Warn: third-party GitHubAction not pinned by hash: .github/workflows/main.yml:47: update your workflow using https://app.stepsecurity.io/secureworkflow/toreda/adt/main.yml/master?enable=pin","Info:   0 out of   3 GitHub-owned GitHubAction dependencies pinned","Info:   0 out of   1 third-party GitHubAction dependencies pinned"],"documentation":{"short":"Determines if the project has declared and pinned the dependencies of its build process.","url":"https://github.com/ossf/scorecard/blob/f6ed084d17c9236477efd66e5b258b9d4cc7b389/docs/checks.md#pinned-dependencies"}},{"name":"CII-Best-Practices","score":0,"reason":"no effort to earn an OpenSSF best practices badge detected","details":null,"documentation":{"short":"Determines if the project has an OpenSSF (formerly CII) Best Practices Badge.","url":"https://github.com/ossf/scorecard/blob/f6ed084d17c9236477efd66e5b258b9d4cc7b389/docs/checks.md#cii-best-practices"}},{"name":"Security-Policy","score":0,"reason":"security policy file not detected","details":["Warn: no security policy file detected","Warn: no security file to analyze","Warn: no security file to analyze","Warn: no security file to analyze"],"documentation":{"short":"Determines if the project has published a security policy.","url":"https://github.com/ossf/scorecard/blob/f6ed084d17c9236477efd66e5b258b9d4cc7b389/docs/checks.md#security-policy"}},{"name":"Fuzzing","score":0,"reason":"project is not fuzzed","details":["Warn: no fuzzer integrations found"],"documentation":{"short":"Determines if the project uses fuzzing.","url":"https://github.com/ossf/scorecard/blob/f6ed084d17c9236477efd66e5b258b9d4cc7b389/docs/checks.md#fuzzing"}},{"name":"License","score":10,"reason":"license file detected","details":["Info: project has a license file: LICENSE:0","Info: FSF or OSI recognized license: MIT License: LICENSE:0"],"documentation":{"short":"Determines if the project has defined a license.","url":"https://github.com/ossf/scorecard/blob/f6ed084d17c9236477efd66e5b258b9d4cc7b389/docs/checks.md#license"}},{"name":"Signed-Releases","score":-1,"reason":"no releases found","details":null,"documentation":{"short":"Determines if the project cryptographically signs release artifacts.","url":"https://github.com/ossf/scorecard/blob/f6ed084d17c9236477efd66e5b258b9d4cc7b389/docs/checks.md#signed-releases"}},{"name":"Branch-Protection","score":-1,"reason":"internal error: error during branchesHandler.setup: internal error: githubv4.Query: Resource not accessible by integration","details":null,"documentation":{"short":"Determines if the default and release branches are protected with GitHub's branch protection settings.","url":"https://github.com/ossf/scorecard/blob/f6ed084d17c9236477efd66e5b258b9d4cc7b389/docs/checks.md#branch-protection"}},{"name":"SAST","score":0,"reason":"SAST tool is not run on all commits -- score normalized to 0","details":["Warn: 0 commits out of 30 are checked with a SAST tool"],"documentation":{"short":"Determines if the project uses static code analysis.","url":"https://github.com/ossf/scorecard/blob/f6ed084d17c9236477efd66e5b258b9d4cc7b389/docs/checks.md#sast"}},{"name":"Vulnerabilities","score":0,"reason":"54 existing vulnerabilities detected","details":["Warn: Project is vulnerable to: GHSA-968p-4wvh-cqc8","Warn: Project is vulnerable to: GHSA-67hx-6x53-jw92","Warn: Project is vulnerable to: GHSA-v88g-cgmw-v5xw","Warn: Project is vulnerable to: GHSA-93q8-gq69-wqmw","Warn: Project is vulnerable to: GHSA-v6h2-p8h4-qcjw","Warn: Project is vulnerable to: GHSA-grv7-fg5c-xmjg","Warn: Project is vulnerable to: GHSA-x9w5-v3q2-3rhw","Warn: Project is vulnerable to: GHSA-897m-rjf5-jp39","Warn: Project is vulnerable to: GHSA-3xgq-45jj-v275","Warn: Project is vulnerable to: GHSA-gxpj-cx7g-858c","Warn: Project is vulnerable to: GHSA-w573-4hg7-7wgq","Warn: Project is vulnerable to: GHSA-vh7m-p724-62c2","Warn: Project is vulnerable to: GHSA-r9p9-mrjm-926w","Warn: Project is vulnerable to: GHSA-434g-2637-qmqr","Warn: Project is vulnerable to: GHSA-49q7-c7j4-3p7m","Warn: Project is vulnerable to: GHSA-977x-g7h5-7qgw","Warn: Project is vulnerable to: GHSA-f7q4-pwc6-w24p","Warn: Project is vulnerable to: GHSA-fc9h-whq2-v747","Warn: Project is vulnerable to: GHSA-vjh7-7g9h-fjfh","Warn: Project is vulnerable to: GHSA-4gmj-3p3h-gm8h","Warn: Project is vulnerable to: GHSA-fjxv-7rqg-78g4","Warn: Project is vulnerable to: GHSA-ww39-953v-wcq6","Warn: Project is vulnerable to: GHSA-43f8-2h32-f4cj","Warn: Project is vulnerable to: GHSA-qqgx-2p2h-9c37","Warn: Project is vulnerable to: GHSA-896r-f27r-55mw","Warn: Project is vulnerable to: GHSA-9c47-m6qq-7p4h","Warn: Project is vulnerable to: GHSA-76p3-8jx3-jpfq","Warn: Project is vulnerable to: GHSA-3rfm-jhwj-7488","Warn: Project is vulnerable to: GHSA-hhq3-ff78-jv3g","Warn: Project is vulnerable to: GHSA-p6mc-m468-83gw","Warn: Project is vulnerable to: GHSA-29mw-wpgm-hmr9","Warn: Project is vulnerable to: GHSA-35jh-r3h4-6jhm","Warn: Project is vulnerable to: GHSA-952p-6rrq-rcjv","Warn: Project is vulnerable to: GHSA-f8q6-p94x-37v3","Warn: Project is vulnerable to: GHSA-xvch-5gv4-984h","Warn: Project is vulnerable to: GHSA-5fw9-fq32-wv5p","Warn: Project is vulnerable to: GHSA-x77j-w7wf-fjmw","Warn: Project is vulnerable to: GHSA-hj48-42vr-x3v9","Warn: Project is vulnerable to: GHSA-h7cp-r72f-jxh6","Warn: Project is vulnerable to: GHSA-v62p-rq8g-8h59","Warn: Project is vulnerable to: GHSA-hrpp-h998-j3pp","Warn: Project is vulnerable to: GHSA-p8p7-x288-28g6","Warn: Project is vulnerable to: GHSA-c2qf-rxjj-qqgw","Warn: Project is vulnerable to: GHSA-hxcc-f52p-wc94","Warn: Project is vulnerable to: GHSA-vx3p-948g-6vhq","Warn: Project is vulnerable to: GHSA-4wf5-vphf-c2xc","Warn: Project is vulnerable to: GHSA-52f5-9888-hmc6","Warn: Project is vulnerable to: GHSA-jgrx-mgxx-jf9v","Warn: Project is vulnerable to: GHSA-72xf-g2v4-qvf3","Warn: Project is vulnerable to: GHSA-j8xg-fqg3-53r7","Warn: Project is vulnerable to: GHSA-6fc8-4gx4-v693","Warn: Project is vulnerable to: GHSA-3h5v-q93c-6h6q","Warn: Project is vulnerable to: GHSA-c4w7-xm78-47vh","Warn: Project is vulnerable to: GHSA-p9pc-299p-vxgp"],"documentation":{"short":"Determines if the project has open, known unfixed vulnerabilities.","url":"https://github.com/ossf/scorecard/blob/f6ed084d17c9236477efd66e5b258b9d4cc7b389/docs/checks.md#vulnerabilities"}}]},"last_synced_at":"2025-08-24T13:19:17.070Z","repository_id":51147117,"created_at":"2025-08-24T13:19:17.070Z","updated_at":"2025-08-24T13:19:17.070Z"},"host":{"name":"GitHub","url":"https://github.com","kind":"github","repositories_count":286080680,"owners_count":32807211,"icon_url":"https://github.com/github.png","version":null,"created_at":"2022-05-30T11:31:42.601Z","updated_at":"2026-05-08T08:22:46.396Z","status":"online","status_checked_at":"2026-05-09T02:00:06.633Z","response_time":123,"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":["abstract-data-types","javascript","queue","stack","typed","types","typescript","typescript-generics","yarn"],"created_at":"2024-12-18T03:14:06.495Z","updated_at":"2026-05-09T04:32:45.431Z","avatar_url":"https://github.com/toreda.png","language":"TypeScript","funding_links":[],"categories":[],"sub_categories":[],"readme":"# `@toreda/adt` Abstract Data Types\n\n![CI](https://github.com/toreda/adt/workflows/CI/badge.svg?branch=master) [![Coverage](https://sonarcloud.io/api/project_badges/measure?project=toreda_adt\u0026metric=coverage)](https://sonarcloud.io/dashboard?id=toreda_adt) [![Quality Gate Status](https://sonarcloud.io/api/project_badges/measure?project=toreda_adt\u0026metric=alert_status)](https://sonarcloud.io/dashboard?id=toreda_adt)\n\nCollection of TypeScript generic data structures with consistent APIs for search, insertion, and deletion.\n\n# Contents\n* [**Basic Usage**](#basic-usage)\n*\t[**Data Structures**](#built-in-types)\n\n\t* [`ADTCircularQueue`](#ADTCircularQueue)\n\t* [`ADTLinkedList`](#ADTLinkedList)\n\t* [`ADTPriorityQueue`](#ADTPriorityQueue)\n\t* [`ADTObjectPool`](#ADTObjectPool)\n\t* [`ADTQueue`](#ADTQueue)\n\t* [`ADTStack`](#ADTStack)\n* \t[**Package**](#Package)\n\t-\t[Build](#Build)\n\t-\t[Testing](#testing)\n\t-   [License](#license)\n\n# **`ADTBase` Interface**\nEach ADT uses TypeScript generics of type\u003cT\u003e and implements `ADTBase` and `ADTBaseElement` interfaces.\n\n`ADTBase` requires these functions:\n* `clearElements(): void`\n* `reset(): void`\n* `stringify(): string | null`\n* `\tquery(\n\t\tquery: ADTQueryFilter\u003cT\u003e | ADTQueryFilter\u003cT\u003e[],\n\t\toptions?: ADTQueryOptions\n\t): ADTQueryResult\u003cT\u003e[] | ADTQueryResult\u003cADTBaseElement\u003cT\u003e\u003e[];`\n\n# Data Structures\n\n* [`ADTCircularQueue`](#ADTCircularQueue)\n* [`ADTLinkedList`](#ADTLinkedList)\n* [`ADTQueue`](#ADTQueue)\n* [`ADTStack`](#ADTStack)\n\n## **`ADTCircularQueue\u003cT\u003e`**\n\nTypescript\n\n```typescript\n// Import\nimport {ADTCircularQueue} from '@toreda/adt';\n\n// Instantiate\nconst circularQueueDefault = new ADTCircularQueue\u003cnumber\u003e();\nconst circularQueueWithOptions = new ADTCircularQueue\u003cnumber\u003e({\n\tmaxSize: 999,\n\tsize: 3,\n\telements[,,,1,2,3,],\n\tfront: 3,\n\trear: 5,\n\toverwrite: true\n});\n\n// Use as Queue\nconst circularQueue = new ADTCircularQueue\u003cnumber\u003e({\n\tmaxSize: 4,\n});\n\n// Add element to the queue\ncircularQueue.push(10) // returns true;\ncircularQueue.push(20) // returns true;\ncircularQueue.push(30) // returns true;\ncircularQueue.push(40) // returns true;\ncircularQueue.push(50) // returns false;\n\n// Get queue size\ncircularQueue.size(); // returns 4\n\n// Get first element added to queue\ncircularQueue.front(); // returns 10\n\n// Get last element added to queue\ncircularQueue.rear(); // returns 40\n\n// Get nth-after-first element added to queue\ncircularQueue.getIndex(1); // returns 20\ncircularQueue.getIndex(2); // returns 30\n\n// Get nth-to-last element added to queue\ncircularQueue.getIndex(-1); // returns 30\ncircularQueue.getIndex(-2); // returns 20\n\n// Remove element from the queue\ncircularQueue.pop(); // returns 10\ncircularQueue.pop(); // returns 20\ncircularQueue.size(); // returns 2\ncircularQueue.pop(); // returns 30\ncircularQueue.pop(); // returns 40\ncircularQueue.size(); // returns 0\ncircularQueue.pop(); // returns null\n\n// Use as Buffer\nconst circularBuffer = new ADTCircularQueue\u003cnumber\u003e({\n\tmaxSize: 4,\n\toverwrite: true\n});\n\n// Add element to the buffer\ncircularBuffer.push(10) // returns true;\ncircularBuffer.push(20) // returns true;\ncircularBuffer.push(30) // returns true;\ncircularBuffer.push(40) // returns true;\ncircularBuffer.push(50) // returns true;\n\n// Get queue size\ncircularBuffer.size(); // returns 4\n\n// Get first element added to buffer\ncircularBuffer.front(); // returns 20\n\n// Get last element added to buffer\ncircularBuffer.rear(); // returns 50\n\n// Get nth-after-first element added to buffer\ncircularBuffer.getIndex(1); // returns 30\ncircularBuffer.getIndex(2); // returns 40\n\n// Get nth-to-last element added to buffer\ncircularBuffer.getIndex(-1); // returns 40\ncircularBuffer.getIndex(-2); // returns 30\n\n// Remove element from the buffer\ncircularBuffer.pop(); // returns 20\ncircularBuffer.pop(); // returns 30\ncircularBuffer.size(); // returns 2\ncircularBuffer.pop(); // returns 40\ncircularBuffer.pop(); // returns 50\ncircularBuffer.size(); // returns 0\ncircularBuffer.pop(); // returns null\n\n// Remove all elements from buffer\ncircularQueue.clearElements();\n\n// Iterate through queue\ncircularQueue.push(10); // returns true\ncircularQueue.push(20); // returns true\ncircularQueue.push(30); // returns true\ncircularQueue.pop(); // returns 10\ncircularQueue.size() // returns 2\ncircularQueue.forEach((elem, index, arr) =\u003e {\n\tconsole.log(elem + ' is at index ' + index + ' in array ' + arr)\n}); // returns circularQueue\n// outputs '20 is at index 1 in array [10, 20, 30]'\n// outputs '30 is at index 2 in array [10, 20, 30]'\n\ncircularQueue.push(40); // returns true\ncircularQueue.push(50); // returns true\ncircularQueue.size() // returns 4\ncircularQueue.forEach((elem, index, arr) =\u003e {\n\tconsole.log(elem + ' is at index ' + index + ' in array ' + arr)\n}); // returns circularQueue\n// outputs '20 is at index 1 in array [50, 20, 30, 40]'\n// outputs '30 is at index 2 in array [50, 20, 30, 40]'\n// outputs '40 is at index 3 in array [50, 20, 30, 40]'\n// outputs '50 is at index 0 in array [50, 20, 30, 40]'\n\ncircularQueue.pop(); // returns 20\ncircularQueue.pop(); // returns 30\ncircularQueue.size() // returns 2\ncircularQueue.forEach((elem, index, arr) =\u003e {\n\tconsole.log(elem + ' is at index ' + index + ' in array ' + arr)\n}); // returns circularQueue\n// outputs '40 is at index 3 in array [50, 20, 30, 40]'\n// outputs '50 is at index 0 in array [50, 20, 30, 40]'\n\n// Returns the current state of priorityQueue as string\nconst serialized = circularQueue.stringify();\n\n// Instantiate a Priority Queue using serialized state\nconst circularQueueFromSerialized = new ADTCircularQueue({serializedState: serialized});\n```\n\n\n## `ADTQueue\u003cT\u003e`\n\nTypescript\n\n```typescript\n// Import\nimport {ADTQueue} from '@toreda/adt';\n// Instantiate\nconst myQueue = new ADTQueue\u003cstring\u003e();\nconst myQueueWithOption = new ADTQueue\u003cstring\u003e({\n\telements: ['a', 'b', 'c']\n});\n\n// Add elements to queue\nmyQueue.push(\"my string 1\"); // return myQueue\nmyQueue.push(\"my string 2\"); // return myQueue\n\n// Get queue size\nconst size = myQueue.size(); // returns 2\n\n// Iterate through elements\nmyQueue.forEach((elem, index, arr) =\u003e {\n\tconsole.log(elem + ' is at index ' + index + ' in array ' + arr)\n}); // returns myQueue\n// outputs 'my string 1 is at index 0 in array [\"my string 1\", \"my string 2\"]'\n// outputs 'my string 2 is at index 1 in array [\"my string 1\", \"my string 2\"]'\n\n// Remove first element from queue\nconst result1 = myQueue.pop(); // returns \"my string 1\"\nconst result2 = myQueue.pop(); // returns \"my string 2\"\nconst result3 = myQueue.pop(); // returns null because myQueue is already empty.\n\n// Reset queue and remove all elements.\nmyQueue.reset(); // returns myQueue\n\n// Queue 3 items via chained push calls.\nmyQueue.push(\"one\").push(\"two\").push(\"three\");\n\n// Reverse the order of queued elements.\n// \"one\", \"two\", \"three\" becomes \"three\", \"two\", \"one\"\nmyQueue.reverse();\n\n// Returns the current state of queue as string\nconst serialized = myQueue.stringify();\n\n// Instantiate a queue using serialized state\nconst serialQueue = new ADTQueue({serializedState: serialized});\n```\n\n## `ADTStack\u003cT\u003e`\n\nTypescript\n\n```typescript\n// Import\nimport {ADTStack} from '@toreda/adt';\n// Instantiate\nconst myStack = new ADTStack\u003cstring\u003e();\nconst myStackWithOption = new ADTStack\u003cstring\u003e({\n\telements: ['a', 'b', 'c']\n});\n\n// Add elements to stack\nmyStack.push(\"my string 1\"); // return myStack\nmyStack.push(\"my string 2\"); // return myStack\n\n// Get stack size\nconst size = myStack.size(); // returns 2\n\n// Iterate through elements\nmyStack.forEach((elem, index, arr) =\u003e {\n\tconsole.log(elem + ' is at index ' + index + ' in array ' + arr)\n}); // returns myStack\n// outputs 'my string 2 is at index 0 in array [\"my string 2\", \"my string 1\"]'\n// outputs 'my string 1 is at index 1 in array [\"my string 2\", \"my string 1\"]'\n\n// Remove first element from stack\nconst result1 = myStack.pop(); // returns \"my string 2\"\nconst result2 = myStack.pop(); // returns \"my string 1\"\nconst result3 = myStack.pop(); // returns null because myStack is already empty.\n\n// Reset stack and remove all elements.\nmyStack.reset(); // returns myStack\n\n// Queue 3 items via chained push calls.\nmyStack.push(\"one\").push(\"two\").push(\"three\");\n\n// Reverse the order of stack elements.\n// \"one\", \"two\", \"three\" becomes \"three\", \"two\", \"one\"\nmyStack.reverse();\n\n// Returns the current state of stack as string\nconst serialized = myStack.stringify();\n\n// Instantiate a queue using serialized state\nconst serialStack = new ADTStack({serializedState: serialized});\n```\n\n## `ADTLinkedList\u003cT\u003e`\n\nTypescript\n\n```typescript\n// Import\nimport {ADTLinkedList} from '@toreda/adt';\n// Instantiate\nconst myLinkedList = new ADTLinkedList\u003cstring\u003e();\nconst myStackWithOption = new ADTStack\u003cstring\u003e({\n\telements: ['a', 'b', 'c']\n});\n\n// Add elements to the tail of linked list\nmyLinkedList.insert(\"my string 1\"); // returns arg converted to ADTLinkedListElement\nmyLinkedList.insert(\"my string 2\"); // returns arg converted to ADTLinkedListElement\nmyLinkedList.insertAtTail(\"my string 3\"); // returns arg converted to ADTLinkedListElement\n\n// Add elements to the head of linked list\nmyLinkedList.insertAtHead(\"my string 0\"); // returns arg converted to ADTLinkedListElement\n\n// Get linked list size\nconst size = myLinkedList.size(); // returns 4\n\n// Get head of linked list\nlet head = myLinkedList.head();// returns object holding \"my string 0\" as value\n\n// Get tail of linked list\nlet tail = myLinkedList.tail();// returns object holding \"my string 3\" as value\n\n// Get value of linked list element\nlet headValue = head.value(); // returns \"my string 0\"\nlet tailValue = tail.value(); // returns \"my string 3\"\n\n// Set value of linked list element\nhead.value(\"MY STRING 0\"); // returns null\ntail.value(\"MY STRING 3\"); // returns null\n\n// Move to next linked node\nlet next = head.next() // returns object holding \"my string 1\" as value\nnext = next.next() // returns object holding \"my string 2\" as value\nnext = next.next() // returns object holding \"MY STRING 3\" as value\nnext = next.next() // returns null\n\n// Move to previous linked node\nlet prev = head.prev() // returns object holding \"my string 2\" as value\nprev = prev.prev() // returns object holding \"my string 1\" as value\nprev = prev.prev() // returns object holding \"MY STRING 0\" as value\nprev = prev.prev() // returns null\n\n// Iterate through elements\nmyLinkedList.forEach((elem, index, arr) =\u003e {\n\tconsole.log(elem + ' is at index ' + index + ' in array ' + arr)\n}); // returns myLinkedList\n// outputs 'MY STRING 0 is at index 0 in array [\"MY STRING 0\", \"my string 1\", \"my string 2\", \"MY STRING 3]'\n// outputs 'my string 1 is at index 1 in array [\"MY STRING 0\", \"my string 1\", \"my string 2\", \"MY STRING 3]'\n// outputs 'my string 2 is at index 2 in array [\"MY STRING 0\", \"my string 1\", \"my string 2\", \"MY STRING 3]'\n// outputs 'MY STRING 3 is at index 3 in array [\"MY STRING 0\", \"my string 1\", \"my string 2\", \"MY STRING 3]'\n\n// Remove node from linked list\nmyLinkedList.deleteNode(head); // returns \"MY STRING 0\"\nmyLinkedList.deleteNode(tail); // returns \"MY STRING 3\"\nmyLinkedList.head(); // returns \"my string 1\"\nmyLinkedList.tail(); // returns \"my string 2\"\n\n// Reset linked list and remove all elements.\nmyLinkedList.reset(); // returns myLinkedList\n\n// Reverse the order of queued elements.\n// \"one\", \"two\", \"three\" becomes \"three\", \"two\", \"one\"\nmyLinkedList.reverse();\n\n// Returns the current state of queue as string\nconst serialized = myLinkedList.stringify();\n\n// Instantiate a queue using serialized state\nconst serialLinkedList = new ADTLinkedList({serializedState: serialized});\n```\n\n\n## **`ADTPriorityQueue\u003cT\u003e`**\n\nTypescript\n\n```typescript\n// Import\nimport {ADTPriorityQueue, ADTPriorityQueueComparator} from '@toreda/adt';\n\n// Instantiate\nconst priorityQueueComparator: ADTPriorityQueueComparator\u003cnumber\u003e = function(a, b) =\u003e a \u003c b;\nconst priorityQueue = new ADTPriorityQueue\u003cnumber\u003e(priorityQueueComparator);\nconst priorityQueueWithOptions = new ADTPriorityQueue\u003cnumber\u003e(priorityQueueComparator, {\n\telements: [1,2,3,4,5,6,7]\n});\n\n// Add elements to the queue\npriorityQueue.push(20); // returns priorityQueue\npriorityQueue.push(10); // returns priorityQueue\n\n// Get number of elements in queue\nconst size = priorityQueue.size(); // returns 2\n\n// Get the root element of the queue\nconst result = priorityQueue.front(); // returns 10\n\n// Iterate through queue\npriorityQueue.forEach((elem, index, arr) =\u003e {\n\tconsole.log(elem + ' is at index ' + index + ' in array ' + arr)\n}); // returns priorityQueue\n// outputs '10 is at index 0 in array [10, 20]'\n// outputs '20 is at index 1 in array [10, 20]'\n\n// Get the root element of the queue and remove it\nconst result1 = priorityQueue.pop(); // returns 10\nconst result2 = priorityQueue.pop(); // returns 20\nconst result3 = priorityQueue.pop(); // returns null\n\n// Reset priority queue and remove all elements\npriorityQueue.reset(); // returns priorityQueue\n\n// Add 3 elements via chained push calls\npriorityQueue.push(30).push(10).push(20);\n\n// Returns the current state of priorityQueue as string\nconst serialized = priorityQueue.stringify();\n\n// Instantiate a Priority Queue using serialized state\nconst priorityQueueFromSerialized = new ADTPriorityQueue(priorityQueueComparator, {serializedState: serialized});\n```\n\n## **`ADTObjectPool\u003cT\u003e`**\n\nTypescript\n\n```typescript\n// Import\nimport {ADTObjectPool} from '@toreda/adt';\n\n// Instantiate\nclass objectClass {\n\tpublic name!: string;\n\tpublic amount!: number;\n\n\tconstructor() {\n\t\tobjectClass.cleanObj(this);\n\t}\n\n\tstatic cleanObj(obj: objectClass): void {\n\t\tobj.name = '';\n\t\tobj.amount = 0;\n\t}\n}\n\nconst objectPool = new ADTPriorityQueue\u003cobjectClass\u003e(objectClass);\nconst objectPoolWithOptions = new ADTPriorityQueue\u003cobjectClass\u003e(objectClass, {\n\tmaxSize: 10000,\n\tstartSize: 100,\n\tautoIncrease: true,\n\tincreaseBreakPoint: .9,\n\tincreaseFactor: 10\n});\n\n// Get 1 object from the pool\nconst obj1 = objectPool.allocate(); // returns object\u003cobjectClass\u003e\n\n// Get array of n objects from the pool;\nconst objs = objectPool.allocateMultiple(10); // returns array of 10 object\u003cobjectClass\u003e\n\n// Get % of pool being used\nconst usage = objectPool.utilization(); // returns .11\nconst usage = objectPool.utilization(39); // returns .5\n\n// Manually increase pool capacity\nobjectPool.increaseCapacity(100); // objectPool.state.size === 200;\nobjectPool.increaseCapacity(20000); // objectPool.state.size === 10000;\n\n// Release objects back into pool\nobjectPool.release(obj1);\nobjectPool.releaseMultiple(objs);\n\n// Remove all elements from pool\nobjectPool.clearElements();\n\n// Returns the current state of pool as string\nconst serialized = objectPool.stringify();\n\n// Instantiate an Object Pool using serialized state\nconst objectPoolFromSerialized = new ADTPriorityQueue\u003cobjectClass\u003e(objectClass, {serializedState: serialized});\n```\n\n# Query Selectors\n\nTypescript\n\n```typescript\nimport {ADTQueryFilter, ADTQueryResult, ADTQueryOptions} from '@toreda/adt';\nimport {ADTQueue, ADTStack, ADTLinkedList, ADTCircularQueue, ADTPriorityQueue} from '@toreda/adt';\n\nconst myQueue = new ADTQueue\u003cnumber\u003e();\nconst myStack = new ADTStack\u003cnumber\u003e();\nconst myLinkedList = new ADTLinkedList\u003cnumber\u003e();\nconst myCircularQueue = new ADTCircularQueue\u003cnumber\u003e();\nconst myPriorityQueue = new ADTPriorityQueue\u003cnumber\u003e((a, b) =\u003e a \u003c b);\n\n// Create a query filter function\nconst basicQueryFilter: ADTQueryFilter\u003cnumber\u003e = (value) =\u003e {\n\treturn value === 30\n}\n\n// Create a query filter function generator\nconst genQueryFilter = function (target: number, lessthan: boolean) = ADTQueryFilter\u003cnumber\u003e {\n\tconst filter: ADTQueryFilter\u003cnumber\u003e = (value) =\u003e {\n\t\tif (lessthan) {\n\t\t\treturn value \u003c target;\n\t\t} else {\n\t\t\treturn value \u003e target;\n\t\t}\n\t}\n}\n\n// Add elements to all ADTs\n[10, 20, 30, 40, 50].forEach((value) =\u003e {\n\tmyQueue.push(value);\n\tmyStack.push(value);\n\tmyLinkedList.insert(value);\n\tmyCircularQueue.push(value);\n\tmyPriorityQueue.push(value);\n});\n\n// Use a query filter to get a query result\nlet resultsQueue = myQueue.query(basicQueryFilter); // return array of query result objects\nlet resultsStack = myStack.query(basicQueryFilter); // return array of query result objects\nlet resultsLinkedList = myLinkedList.query(basicQueryFilter); // return array of query result objects\nlet resultsCircularQueue = myCircularQueue.query(basicQueryFilter); // return array of query result objects\nlet resultsPriorityQueue = myPriorityQueue.query(basicQueryFilter); // return array of query result objects\n\n// Get the element in query result\nresultQueue[0].element; // returns 30\nresultStack[0].element; // returns 30\nresultLinkedList[0].element; // returns linked list element with value 30\nresultCircularQueue[0].element; // returns 30\nresultPriorityQueue[0].element; // returns 30\n\n// Get the current index of the query result\nresultQueue[0].index(); // returns 2\nresultStack[0].index(); // returns 2\nresultLinkedList[0].index(); // returns null\nresultCircularQueue[0].index(); // returns 2\nresultPriorityQueue[0].index(); // returns 2\n\nmyQueue.pop(); // returns 10\nmyStack.pop(); // returns 50\nmyLinkedList.deleteNode(myLinkedList.head()); // returns 10\nmyCircularQueue.pop(); // returns 10\nmyPriorityQueue.pop(); // returns 10\n\nresultQueue[0].index(); // returns 1\nresultStack[0].index(); // returns 2\nresultLinkedList[0].index(); // returns null\nresultCircularQueue[0].index(); // returns 2\nresultPriorityQueue[0].index(); // returns 2\n\n// Delete query result from original ADT\nresultQueue[0].delete(); // returns 30\nresultStack[0].delete(); // returns 30\nresultLinkedList[0].delete(); // returns 30\nresultCircularQueue[0].delete(); // returns 30\nresultPriorityQueue[0].delete(); // returns 30\n\n// Use multiple query filters and query options\nmyQueue.reset();\nmyQueue.push(10).push(20).push(30).push(40).push(50)\n\nconst filters: ADTQueryFilter[] = [];\nfilters.push(genQueryFilter(10, false));\nfilters.push(genQueryFilter(50, true));\n\nqueryResults = myQueue.query(filters, {limit: 2}) // returns array of query result objects;\nqueryResults[0].element; // returns 20\nqueryResults[1].element; // returns 30\n```\n\n# Install\nInstall `@toreda/adt` directly from NPM or [clone the Github repo](https://github.com/toreda/adt).\n\n### Install using Yarn (preferred)\n 1. Open a shell (or console).\n 2. Navigate to the the adt project root folder.\n 3. Enter the following commands in order. Wait for each to complete before typing the next.\n```bash\nyarn\n```\n\n### Install using NPM\n 1. Open a shell (or console).\n 2. Navigate to the the `@toreda/adt` project root folder.\n 3. Enter the following commands in order. Wait for each to complete before typing the next.\n```bash\nnpm install\n```\n\n\n# Run Unit Tests\nInstall or clone `@toreda/adt` [(see above)](#install).\n\nADT unit tests use [Jest](https://jestjs.io/).\n\nInstalling jest is not required after project dependencies are installed ([see above](#install)).\n```bash\nyarn test\n```\n\n# Build from source\n\nThe next steps are the same whether you installed the package using NPM or cloned the repo from Github.\n\n### Build with Yarn\n Enter the following commands in order from the adt project root.\n```bash\nyarn build\n```\n\n### Build with NPM\n Enter the following commands in order from the adt project root.\n```bash\nnpm run-script build\n```\n\n# License\n\n[MIT](LICENSE) \u0026copy; Toreda, Inc.\n","project_url":"https://awesome.ecosyste.ms/api/v1/projects/github.com%2Ftoreda%2Fadt","html_url":"https://awesome.ecosyste.ms/projects/github.com%2Ftoreda%2Fadt","lists_url":"https://awesome.ecosyste.ms/api/v1/projects/github.com%2Ftoreda%2Fadt/lists"}