diff --git a/README.md b/README.md index 424f141..c09e780 100644 --- a/README.md +++ b/README.md @@ -51,11 +51,7 @@ I considered adding parallel factory patterns instead of instance-based structur - [LinkedList](#user-content-linkedlist-docs-src) - [SizedLinkedList](#user-content-sizedlinkedlist-docs-src) - [LinkedSet](#user-content-linkedset-docs-src) -- [SortedSet](#user-content-sortedset-docs-src) - [LinkedCollection](#user-content-linkedcollection-docs-src) -- [Queue](#user-content-queue-docs-src) -- [UniQueue](#user-content-uniqueue-docs-src) -- [PriorityQueue](#user-content-priorityqueue-docs-src) - [ObjectPool](#user-content-priorityqueue-docs-src) ### Inheritance Tree @@ -64,18 +60,18 @@ I considered adding parallel factory patterns instead of instance-based structur LinkedList ┃ ┣━ SizedLinkedList - ┃ ┻━ Queue + ┃ ┻━ Queue [Future] ┃ ┣━ LinkedSet ┃ ┃ - ┃ ╋━ UniQueue + ┃ ╋━ UniQueue [Future] ┃ ┃ - ┃ ╋━ SortedSet - ┃ ╹ ┻━ PriorityQueue + ┃ ╋━ SortedSet [Future] + ┃ ╹ ┻━ PriorityQueue [Future] ┃ ┣━ LinkedCollection ┃ ┃ - ╹ ┻━ SortedCollection [Coming soon] + ╹ ┻━ SortedCollection [Future] ObjectPool < LinkedList ``` @@ -149,7 +145,7 @@ const five = set.pop(); // -> 'five' set.size; // -> 4 ``` -### SortedSet ([docs](docs/classes/SortedSet.md)) ([src](src/SortedSet.ts)) + -### Queue ([docs](docs/classes/Queue.md)) ([src](src/Queue.ts)) + -### UniQueue ([docs](docs/classes/UniQueue.md)) ([src](src/UniQueue.ts)) + -### PriorityQueue ([docs](docs/classes/PriorityQueue.md)) ([src](src/PriorityQueue.ts)) + ### LinkedCollection ([docs](docs/classes/LinkedCollection.md)) ([src](src/LinkedCollection.ts)) @@ -277,7 +273,7 @@ const four = collection.pop(); // -> Item('four') collection.size; // -> 4 // Introduces expected Map method and changes signatures to be key lookups instead of item lookups -collection.get('two'); // -> Item('two') +collection.select('two'); // -> Item('two') collection.has('one'); // -> true collection.delete('three'); // -> true @@ -299,9 +295,10 @@ new LinkedCollection('id', [ new LinkedCollection('id', [new Item('one'), new Item('two')]).groupBy('id'); // -> { one: Item('one'), two: Item('two') } ``` + ### ObjectPool ([docs](docs/classes/ObjectPool.md)) ([src](src/ObjectPool.ts)) diff --git a/coverage/badge-branches.svg b/coverage/badge-branches.svg index 2e03adf..e9dbd7c 100644 --- a/coverage/badge-branches.svg +++ b/coverage/badge-branches.svg @@ -1 +1 @@ -Coverage:branches: 44.21%Coverage:branches44.21% \ No newline at end of file +Coverage:branches: 100%Coverage:branches100% \ No newline at end of file diff --git a/coverage/badge-functions.svg b/coverage/badge-functions.svg index 8b8de07..330a44e 100644 --- a/coverage/badge-functions.svg +++ b/coverage/badge-functions.svg @@ -1 +1 @@ -Coverage:functions: 62.83%Coverage:functions62.83% \ No newline at end of file +Coverage:functions: 100%Coverage:functions100% \ No newline at end of file diff --git a/coverage/badge-lines.svg b/coverage/badge-lines.svg index 7a59235..cbb01ce 100644 --- a/coverage/badge-lines.svg +++ b/coverage/badge-lines.svg @@ -1 +1 @@ -Coverage:lines: 66.79%Coverage:lines66.79% \ No newline at end of file +Coverage:lines: 100%Coverage:lines100% \ No newline at end of file diff --git a/coverage/badge-statements.svg b/coverage/badge-statements.svg index bf76f23..3f8ebb1 100644 --- a/coverage/badge-statements.svg +++ b/coverage/badge-statements.svg @@ -1 +1 @@ -Coverage:statements: 66.39%Coverage:statements66.39% \ No newline at end of file +Coverage:statements: 100%Coverage:statements100% \ No newline at end of file diff --git a/coverage/coverage-summary.json b/coverage/coverage-summary.json index aefd4c9..93b1934 100644 --- a/coverage/coverage-summary.json +++ b/coverage/coverage-summary.json @@ -1,13 +1,9 @@ -{"total": {"lines":{"total":539,"covered":360,"skipped":0,"pct":66.79},"statements":{"total":610,"covered":405,"skipped":0,"pct":66.39},"functions":{"total":148,"covered":93,"skipped":0,"pct":62.83},"branches":{"total":242,"covered":107,"skipped":0,"pct":44.21},"branchesTrue":{"total":0,"covered":0,"skipped":0,"pct":"Unknown"}} -,"/Users/zimmed/Projects/prefab/src/LinkedCollection.ts": {"lines":{"total":62,"covered":62,"skipped":0,"pct":100},"functions":{"total":19,"covered":19,"skipped":0,"pct":100},"statements":{"total":67,"covered":67,"skipped":0,"pct":100},"branches":{"total":13,"covered":13,"skipped":0,"pct":100}} -,"/Users/zimmed/Projects/prefab/src/LinkedList.ts": {"lines":{"total":130,"covered":130,"skipped":0,"pct":100},"functions":{"total":36,"covered":36,"skipped":0,"pct":100},"statements":{"total":154,"covered":154,"skipped":0,"pct":100},"branches":{"total":56,"covered":56,"skipped":0,"pct":100}} +{"total": {"lines":{"total":394,"covered":394,"skipped":0,"pct":100},"statements":{"total":445,"covered":445,"skipped":0,"pct":100},"functions":{"total":112,"covered":112,"skipped":0,"pct":100},"branches":{"total":149,"covered":149,"skipped":0,"pct":100},"branchesTrue":{"total":0,"covered":0,"skipped":0,"pct":"Unknown"}} +,"/Users/zimmed/Projects/prefab/src/LinkedCollection.ts": {"lines":{"total":63,"covered":63,"skipped":0,"pct":100},"functions":{"total":20,"covered":20,"skipped":0,"pct":100},"statements":{"total":68,"covered":68,"skipped":0,"pct":100},"branches":{"total":17,"covered":17,"skipped":0,"pct":100}} +,"/Users/zimmed/Projects/prefab/src/LinkedList.ts": {"lines":{"total":129,"covered":129,"skipped":0,"pct":100},"functions":{"total":34,"covered":34,"skipped":0,"pct":100},"statements":{"total":154,"covered":154,"skipped":0,"pct":100},"branches":{"total":57,"covered":57,"skipped":0,"pct":100}} ,"/Users/zimmed/Projects/prefab/src/LinkedSet.ts": {"lines":{"total":35,"covered":35,"skipped":0,"pct":100},"functions":{"total":13,"covered":13,"skipped":0,"pct":100},"statements":{"total":38,"covered":38,"skipped":0,"pct":100},"branches":{"total":9,"covered":9,"skipped":0,"pct":100}} -,"/Users/zimmed/Projects/prefab/src/ObjectPool.ts": {"lines":{"total":71,"covered":10,"skipped":0,"pct":14.08},"functions":{"total":17,"covered":0,"skipped":0,"pct":0},"statements":{"total":77,"covered":10,"skipped":0,"pct":12.98},"branches":{"total":51,"covered":0,"skipped":0,"pct":0}} -,"/Users/zimmed/Projects/prefab/src/PriorityQueue.ts": {"lines":{"total":34,"covered":8,"skipped":0,"pct":23.52},"functions":{"total":12,"covered":0,"skipped":0,"pct":0},"statements":{"total":38,"covered":8,"skipped":0,"pct":21.05},"branches":{"total":13,"covered":0,"skipped":0,"pct":0}} -,"/Users/zimmed/Projects/prefab/src/Queue.ts": {"lines":{"total":15,"covered":9,"skipped":0,"pct":60},"functions":{"total":6,"covered":1,"skipped":0,"pct":16.66},"statements":{"total":15,"covered":9,"skipped":0,"pct":60},"branches":{"total":5,"covered":2,"skipped":0,"pct":40}} +,"/Users/zimmed/Projects/prefab/src/ObjectPool.ts": {"lines":{"total":83,"covered":83,"skipped":0,"pct":100},"functions":{"total":20,"covered":20,"skipped":0,"pct":100},"statements":{"total":90,"covered":90,"skipped":0,"pct":100},"branches":{"total":38,"covered":38,"skipped":0,"pct":100}} ,"/Users/zimmed/Projects/prefab/src/SizedLinkedList.ts": {"lines":{"total":55,"covered":55,"skipped":0,"pct":100},"functions":{"total":12,"covered":12,"skipped":0,"pct":100},"statements":{"total":56,"covered":56,"skipped":0,"pct":100},"branches":{"total":8,"covered":8,"skipped":0,"pct":100}} -,"/Users/zimmed/Projects/prefab/src/SortedSet.ts": {"lines":{"total":89,"covered":9,"skipped":0,"pct":10.11},"functions":{"total":11,"covered":0,"skipped":0,"pct":0},"statements":{"total":105,"covered":9,"skipped":0,"pct":8.57},"branches":{"total":61,"covered":0,"skipped":0,"pct":0}} -,"/Users/zimmed/Projects/prefab/src/UniQueue.ts": {"lines":{"total":15,"covered":9,"skipped":0,"pct":60},"functions":{"total":6,"covered":1,"skipped":0,"pct":16.66},"statements":{"total":15,"covered":9,"skipped":0,"pct":60},"branches":{"total":5,"covered":2,"skipped":0,"pct":40}} -,"/Users/zimmed/Projects/prefab/src/decorators.ts": {"lines":{"total":23,"covered":23,"skipped":0,"pct":100},"functions":{"total":7,"covered":7,"skipped":0,"pct":100},"statements":{"total":26,"covered":26,"skipped":0,"pct":100},"branches":{"total":21,"covered":17,"skipped":0,"pct":80.95}} -,"/Users/zimmed/Projects/prefab/src/index.ts": {"lines":{"total":10,"covered":10,"skipped":0,"pct":100},"functions":{"total":9,"covered":4,"skipped":0,"pct":44.44},"statements":{"total":19,"covered":19,"skipped":0,"pct":100},"branches":{"total":0,"covered":0,"skipped":0,"pct":100}} +,"/Users/zimmed/Projects/prefab/src/decorators.ts": {"lines":{"total":23,"covered":23,"skipped":0,"pct":100},"functions":{"total":7,"covered":7,"skipped":0,"pct":100},"statements":{"total":27,"covered":27,"skipped":0,"pct":100},"branches":{"total":20,"covered":20,"skipped":0,"pct":100}} +,"/Users/zimmed/Projects/prefab/src/index.ts": {"lines":{"total":6,"covered":6,"skipped":0,"pct":100},"functions":{"total":6,"covered":6,"skipped":0,"pct":100},"statements":{"total":12,"covered":12,"skipped":0,"pct":100},"branches":{"total":0,"covered":0,"skipped":0,"pct":100}} } diff --git a/docs/README.md b/docs/README.md index 5d65e3b..4b0ebda 100644 --- a/docs/README.md +++ b/docs/README.md @@ -53,11 +53,7 @@ I considered adding parallel factory patterns instead of instance-based structur - [LinkedList](#user-content-linkedlist-docs-src) - [SizedLinkedList](#user-content-sizedlinkedlist-docs-src) - [LinkedSet](#user-content-linkedset-docs-src) -- [SortedSet](#user-content-sortedset-docs-src) - [LinkedCollection](#user-content-linkedcollection-docs-src) -- [Queue](#user-content-queue-docs-src) -- [UniQueue](#user-content-uniqueue-docs-src) -- [PriorityQueue](#user-content-priorityqueue-docs-src) - [ObjectPool](#user-content-priorityqueue-docs-src) ### Inheritance Tree @@ -66,18 +62,18 @@ I considered adding parallel factory patterns instead of instance-based structur LinkedList ┃ ┣━ SizedLinkedList - ┃ ┻━ Queue + ┃ ┻━ Queue [Future] ┃ ┣━ LinkedSet ┃ ┃ - ┃ ╋━ UniQueue + ┃ ╋━ UniQueue [Future] ┃ ┃ - ┃ ╋━ SortedSet - ┃ ╹ ┻━ PriorityQueue + ┃ ╋━ SortedSet [Future] + ┃ ╹ ┻━ PriorityQueue [Future] ┃ ┣━ LinkedCollection ┃ ┃ - ╹ ┻━ SortedCollection [Coming soon] + ╹ ┻━ SortedCollection [Future] ObjectPool < LinkedList ``` @@ -151,7 +147,7 @@ const five = set.pop(); // -> 'five' set.size; // -> 4 ``` -### SortedSet ([docs](docs/classes/SortedSet.md)) ([src](src/SortedSet.ts)) + -### Queue ([docs](docs/classes/Queue.md)) ([src](src/Queue.ts)) + -### UniQueue ([docs](docs/classes/UniQueue.md)) ([src](src/UniQueue.ts)) + -### PriorityQueue ([docs](docs/classes/PriorityQueue.md)) ([src](src/PriorityQueue.ts)) + ### LinkedCollection ([docs](docs/classes/LinkedCollection.md)) ([src](src/LinkedCollection.ts)) @@ -279,7 +275,7 @@ const four = collection.pop(); // -> Item('four') collection.size; // -> 4 // Introduces expected Map method and changes signatures to be key lookups instead of item lookups -collection.get('two'); // -> Item('two') +collection.select('two'); // -> Item('two') collection.has('one'); // -> true collection.delete('three'); // -> true @@ -301,9 +297,10 @@ new LinkedCollection('id', [ new LinkedCollection('id', [new Item('one'), new Item('two')]).groupBy('id'); // -> { one: Item('one'), two: Item('two') } ``` + ### ObjectPool ([docs](docs/classes/ObjectPool.md)) ([src](src/ObjectPool.ts)) diff --git a/docs/classes/LinkedCollection.md b/docs/classes/LinkedCollection.md index aa77032..f490870 100644 --- a/docs/classes/LinkedCollection.md +++ b/docs/classes/LinkedCollection.md @@ -64,6 +64,7 @@ - [reduceRight](LinkedCollection.md#reduceright) - [reverse](LinkedCollection.md#reverse) - [reverseMap](LinkedCollection.md#reversemap) +- [select](LinkedCollection.md#select) - [shift](LinkedCollection.md#shift) - [tailNode](LinkedCollection.md#tailnode) - [toArray](LinkedCollection.md#toarray) @@ -72,8 +73,6 @@ - [uppend](LinkedCollection.md#uppend) - [upsert](LinkedCollection.md#upsert) - [values](LinkedCollection.md#values) -- [create](LinkedCollection.md#create) -- [from](LinkedCollection.md#from) ## Constructors @@ -102,7 +101,7 @@ #### Defined in -[src/LinkedCollection.ts:19](https://github.com/zimmed/prefab/blob/a5ffdd1/src/LinkedCollection.ts#L19) +[src/LinkedCollection.ts:19](https://github.com/zimmed/prefab/blob/83cd828/src/LinkedCollection.ts#L19) ## Properties @@ -116,7 +115,7 @@ #### Defined in -[src/LinkedList.ts:30](https://github.com/zimmed/prefab/blob/a5ffdd1/src/LinkedList.ts#L30) +[src/LinkedList.ts:20](https://github.com/zimmed/prefab/blob/83cd828/src/LinkedList.ts#L20) ___ @@ -126,7 +125,7 @@ ___ #### Defined in -[src/LinkedCollection.ts:11](https://github.com/zimmed/prefab/blob/a5ffdd1/src/LinkedCollection.ts#L11) +[src/LinkedCollection.ts:11](https://github.com/zimmed/prefab/blob/83cd828/src/LinkedCollection.ts#L11) ___ @@ -140,7 +139,7 @@ ___ #### Defined in -[src/LinkedList.ts:33](https://github.com/zimmed/prefab/blob/a5ffdd1/src/LinkedList.ts#L33) +[src/LinkedList.ts:23](https://github.com/zimmed/prefab/blob/83cd828/src/LinkedList.ts#L23) ___ @@ -150,7 +149,7 @@ ___ #### Defined in -[src/LinkedCollection.ts:12](https://github.com/zimmed/prefab/blob/a5ffdd1/src/LinkedCollection.ts#L12) +[src/LinkedCollection.ts:12](https://github.com/zimmed/prefab/blob/83cd828/src/LinkedCollection.ts#L12) ## Accessors @@ -170,7 +169,7 @@ LinkedList.head #### Defined in -[src/LinkedList.ts:36](https://github.com/zimmed/prefab/blob/a5ffdd1/src/LinkedList.ts#L36) +[src/LinkedList.ts:26](https://github.com/zimmed/prefab/blob/83cd828/src/LinkedList.ts#L26) ___ @@ -186,7 +185,7 @@ Current size of collection #### Defined in -[src/LinkedCollection.ts:15](https://github.com/zimmed/prefab/blob/a5ffdd1/src/LinkedCollection.ts#L15) +[src/LinkedCollection.ts:15](https://github.com/zimmed/prefab/blob/83cd828/src/LinkedCollection.ts#L15) ___ @@ -206,7 +205,7 @@ LinkedList.tail #### Defined in -[src/LinkedList.ts:40](https://github.com/zimmed/prefab/blob/a5ffdd1/src/LinkedList.ts#L40) +[src/LinkedList.ts:30](https://github.com/zimmed/prefab/blob/83cd828/src/LinkedList.ts#L30) ## Methods @@ -224,7 +223,7 @@ LinkedList.tail #### Defined in -[src/LinkedList.ts:391](https://github.com/zimmed/prefab/blob/a5ffdd1/src/LinkedList.ts#L391) +[src/LinkedList.ts:382](https://github.com/zimmed/prefab/blob/83cd828/src/LinkedList.ts#L382) ___ @@ -250,7 +249,7 @@ Appends unique item to end of the collection #### Defined in -[src/LinkedCollection.ts:101](https://github.com/zimmed/prefab/blob/a5ffdd1/src/LinkedCollection.ts#L101) +[src/LinkedCollection.ts:101](https://github.com/zimmed/prefab/blob/83cd828/src/LinkedCollection.ts#L101) ___ @@ -277,7 +276,7 @@ Adds node to the end of the list #### Defined in -[src/LinkedList.ts:367](https://github.com/zimmed/prefab/blob/a5ffdd1/src/LinkedList.ts#L367) +[src/LinkedList.ts:358](https://github.com/zimmed/prefab/blob/83cd828/src/LinkedList.ts#L358) ___ @@ -303,7 +302,7 @@ Adds item to end of the list #### Defined in -[src/LinkedList.ts:107](https://github.com/zimmed/prefab/blob/a5ffdd1/src/LinkedList.ts#L107) +[src/LinkedList.ts:97](https://github.com/zimmed/prefab/blob/83cd828/src/LinkedList.ts#L97) ___ @@ -323,7 +322,7 @@ Clears collection #### Defined in -[src/LinkedCollection.ts:130](https://github.com/zimmed/prefab/blob/a5ffdd1/src/LinkedCollection.ts#L130) +[src/LinkedCollection.ts:130](https://github.com/zimmed/prefab/blob/83cd828/src/LinkedCollection.ts#L130) ___ @@ -343,7 +342,7 @@ Moves element from end of list to the front #### Defined in -[src/LinkedList.ts:127](https://github.com/zimmed/prefab/blob/a5ffdd1/src/LinkedList.ts#L127) +[src/LinkedList.ts:117](https://github.com/zimmed/prefab/blob/83cd828/src/LinkedList.ts#L117) ___ @@ -369,7 +368,7 @@ Removes specified item by key from the collection #### Defined in -[src/LinkedCollection.ts:121](https://github.com/zimmed/prefab/blob/a5ffdd1/src/LinkedCollection.ts#L121) +[src/LinkedCollection.ts:121](https://github.com/zimmed/prefab/blob/83cd828/src/LinkedCollection.ts#L121) ___ @@ -395,7 +394,7 @@ Removes specified node from the list #### Defined in -[src/LinkedList.ts:376](https://github.com/zimmed/prefab/blob/a5ffdd1/src/LinkedList.ts#L376) +[src/LinkedList.ts:367](https://github.com/zimmed/prefab/blob/83cd828/src/LinkedList.ts#L367) ___ @@ -415,7 +414,7 @@ Iterates through collection key-value pairs #### Defined in -[src/LinkedCollection.ts:54](https://github.com/zimmed/prefab/blob/a5ffdd1/src/LinkedCollection.ts#L54) +[src/LinkedCollection.ts:54](https://github.com/zimmed/prefab/blob/83cd828/src/LinkedCollection.ts#L54) ___ @@ -441,7 +440,7 @@ Uses predicate to return a new array of all matching items (same signature is Ar #### Defined in -[src/LinkedList.ts:295](https://github.com/zimmed/prefab/blob/a5ffdd1/src/LinkedList.ts#L295) +[src/LinkedList.ts:286](https://github.com/zimmed/prefab/blob/83cd828/src/LinkedList.ts#L286) ▸ **filter**<`This`\>(`predicate`, `thisArg`): `T`[] @@ -468,7 +467,7 @@ Uses predicate to return a new array of all matching items (same signature is Ar #### Defined in -[src/LinkedList.ts:296](https://github.com/zimmed/prefab/blob/a5ffdd1/src/LinkedList.ts#L296) +[src/LinkedList.ts:287](https://github.com/zimmed/prefab/blob/83cd828/src/LinkedList.ts#L287) ___ @@ -494,7 +493,7 @@ Uses predicate to return first matching item or undefined if no matches (same si #### Defined in -[src/LinkedList.ts:269](https://github.com/zimmed/prefab/blob/a5ffdd1/src/LinkedList.ts#L269) +[src/LinkedList.ts:260](https://github.com/zimmed/prefab/blob/83cd828/src/LinkedList.ts#L260) ▸ **find**<`This`\>(`predicate`, `thisArg`): `undefined` \| `T` @@ -521,7 +520,7 @@ Uses predicate to return first matching item or undefined if no matches (same si #### Defined in -[src/LinkedList.ts:270](https://github.com/zimmed/prefab/blob/a5ffdd1/src/LinkedList.ts#L270) +[src/LinkedList.ts:261](https://github.com/zimmed/prefab/blob/83cd828/src/LinkedList.ts#L261) ___ @@ -543,7 +542,7 @@ Finds predicate-matching item, with iteration beginning at the end of the collec #### Defined in -[src/LinkedCollection.ts:152](https://github.com/zimmed/prefab/blob/a5ffdd1/src/LinkedCollection.ts#L152) +[src/LinkedCollection.ts:152](https://github.com/zimmed/prefab/blob/83cd828/src/LinkedCollection.ts#L152) ▸ **findRight**<`This`\>(`predicate`, `thisArg`): `undefined` \| `T` @@ -566,7 +565,7 @@ Finds predicate-matching item, with iteration beginning at the end of the collec #### Defined in -[src/LinkedCollection.ts:153](https://github.com/zimmed/prefab/blob/a5ffdd1/src/LinkedCollection.ts#L153) +[src/LinkedCollection.ts:153](https://github.com/zimmed/prefab/blob/83cd828/src/LinkedCollection.ts#L153) ___ @@ -592,7 +591,7 @@ Operates on each element of the list in a callback method (same signature as Arr #### Defined in -[src/LinkedList.ts:227](https://github.com/zimmed/prefab/blob/a5ffdd1/src/LinkedList.ts#L227) +[src/LinkedList.ts:218](https://github.com/zimmed/prefab/blob/83cd828/src/LinkedList.ts#L218) ▸ **forEach**<`ThisArg`\>(`cb`, `thisArg?`): `void` @@ -619,7 +618,7 @@ Operates on each element of the list in a callback method (same signature as Arr #### Defined in -[src/LinkedList.ts:228](https://github.com/zimmed/prefab/blob/a5ffdd1/src/LinkedList.ts#L228) +[src/LinkedList.ts:219](https://github.com/zimmed/prefab/blob/83cd828/src/LinkedList.ts#L219) ___ @@ -641,7 +640,7 @@ Group collection by specified key #### Defined in -[src/LinkedCollection.ts:182](https://github.com/zimmed/prefab/blob/a5ffdd1/src/LinkedCollection.ts#L182) +[src/LinkedCollection.ts:182](https://github.com/zimmed/prefab/blob/83cd828/src/LinkedCollection.ts#L182) ▸ **groupBy**<`X`\>(`key`): `Record`<`X`, `T`[]\> @@ -663,7 +662,7 @@ Group collection by specified key #### Defined in -[src/LinkedCollection.ts:183](https://github.com/zimmed/prefab/blob/a5ffdd1/src/LinkedCollection.ts#L183) +[src/LinkedCollection.ts:183](https://github.com/zimmed/prefab/blob/83cd828/src/LinkedCollection.ts#L183) ___ @@ -689,7 +688,7 @@ Determines if collection contains specified key #### Defined in -[src/LinkedCollection.ts:65](https://github.com/zimmed/prefab/blob/a5ffdd1/src/LinkedCollection.ts#L65) +[src/LinkedCollection.ts:65](https://github.com/zimmed/prefab/blob/83cd828/src/LinkedCollection.ts#L65) ___ @@ -716,7 +715,7 @@ Moves node to the front of the list #### Defined in -[src/LinkedList.ts:140](https://github.com/zimmed/prefab/blob/a5ffdd1/src/LinkedList.ts#L140) +[src/LinkedList.ts:130](https://github.com/zimmed/prefab/blob/83cd828/src/LinkedList.ts#L130) ___ @@ -742,7 +741,7 @@ Inserts unique item into the front of the collection #### Defined in -[src/LinkedCollection.ts:111](https://github.com/zimmed/prefab/blob/a5ffdd1/src/LinkedCollection.ts#L111) +[src/LinkedCollection.ts:111](https://github.com/zimmed/prefab/blob/83cd828/src/LinkedCollection.ts#L111) ___ @@ -769,7 +768,7 @@ Adds node to the front of the list #### Defined in -[src/LinkedList.ts:355](https://github.com/zimmed/prefab/blob/a5ffdd1/src/LinkedList.ts#L355) +[src/LinkedList.ts:346](https://github.com/zimmed/prefab/blob/83cd828/src/LinkedList.ts#L346) ___ @@ -795,7 +794,7 @@ Joins list elements into one string (same signature as Array.prototype.join) #### Defined in -[src/LinkedList.ts:347](https://github.com/zimmed/prefab/blob/a5ffdd1/src/LinkedList.ts#L347) +[src/LinkedList.ts:338](https://github.com/zimmed/prefab/blob/83cd828/src/LinkedList.ts#L338) ___ @@ -815,7 +814,7 @@ Iterates through collection keys #### Defined in -[src/LinkedCollection.ts:49](https://github.com/zimmed/prefab/blob/a5ffdd1/src/LinkedCollection.ts#L49) +[src/LinkedCollection.ts:49](https://github.com/zimmed/prefab/blob/83cd828/src/LinkedCollection.ts#L49) ___ @@ -847,7 +846,7 @@ Maps collection items into a new array #### Defined in -[src/LinkedCollection.ts:163](https://github.com/zimmed/prefab/blob/a5ffdd1/src/LinkedCollection.ts#L163) +[src/LinkedCollection.ts:163](https://github.com/zimmed/prefab/blob/83cd828/src/LinkedCollection.ts#L163) ▸ **map**<`RT`, `This`\>(`cb`, `thisArg`): `RT`[] @@ -875,7 +874,7 @@ Maps collection items into a new array #### Defined in -[src/LinkedCollection.ts:164](https://github.com/zimmed/prefab/blob/a5ffdd1/src/LinkedCollection.ts#L164) +[src/LinkedCollection.ts:164](https://github.com/zimmed/prefab/blob/83cd828/src/LinkedCollection.ts#L164) ___ @@ -895,7 +894,7 @@ Pops item from the end of the collection #### Defined in -[src/LinkedCollection.ts:28](https://github.com/zimmed/prefab/blob/a5ffdd1/src/LinkedCollection.ts#L28) +[src/LinkedCollection.ts:28](https://github.com/zimmed/prefab/blob/83cd828/src/LinkedCollection.ts#L28) ___ @@ -915,7 +914,7 @@ Moves element from front of list to the end #### Defined in -[src/LinkedList.ts:132](https://github.com/zimmed/prefab/blob/a5ffdd1/src/LinkedList.ts#L132) +[src/LinkedList.ts:122](https://github.com/zimmed/prefab/blob/83cd828/src/LinkedList.ts#L122) ___ @@ -948,7 +947,7 @@ Reduces list into specified value (same signature as Array.prototype.reduce) #### Defined in -[src/LinkedList.ts:248](https://github.com/zimmed/prefab/blob/a5ffdd1/src/LinkedList.ts#L248) +[src/LinkedList.ts:239](https://github.com/zimmed/prefab/blob/83cd828/src/LinkedList.ts#L239) ▸ **reduce**<`RT`, `This`\>(`cb`, `initialValue`, `thisArg?`): `RT` @@ -977,7 +976,7 @@ Reduces list into specified value (same signature as Array.prototype.reduce) #### Defined in -[src/LinkedList.ts:249](https://github.com/zimmed/prefab/blob/a5ffdd1/src/LinkedList.ts#L249) +[src/LinkedList.ts:240](https://github.com/zimmed/prefab/blob/83cd828/src/LinkedList.ts#L240) ___ @@ -1006,7 +1005,7 @@ Reduces items from the end of the collection to the front #### Defined in -[src/LinkedCollection.ts:136](https://github.com/zimmed/prefab/blob/a5ffdd1/src/LinkedCollection.ts#L136) +[src/LinkedCollection.ts:136](https://github.com/zimmed/prefab/blob/83cd828/src/LinkedCollection.ts#L136) ▸ **reduceRight**<`RT`, `This`\>(`cb`, `initialValue`, `thisArg?`): `RT` @@ -1031,7 +1030,7 @@ Reduces items from the end of the collection to the front #### Defined in -[src/LinkedCollection.ts:137](https://github.com/zimmed/prefab/blob/a5ffdd1/src/LinkedCollection.ts#L137) +[src/LinkedCollection.ts:137](https://github.com/zimmed/prefab/blob/83cd828/src/LinkedCollection.ts#L137) ___ @@ -1051,7 +1050,7 @@ Iterates through list items in reverse #### Defined in -[src/LinkedList.ts:217](https://github.com/zimmed/prefab/blob/a5ffdd1/src/LinkedList.ts#L217) +[src/LinkedList.ts:208](https://github.com/zimmed/prefab/blob/83cd828/src/LinkedList.ts#L208) ___ @@ -1079,7 +1078,7 @@ Maps collection items from the end of the collection to the front into a new arr #### Defined in -[src/LinkedCollection.ts:171](https://github.com/zimmed/prefab/blob/a5ffdd1/src/LinkedCollection.ts#L171) +[src/LinkedCollection.ts:171](https://github.com/zimmed/prefab/blob/83cd828/src/LinkedCollection.ts#L171) ▸ **reverseMap**<`RT`, `This`\>(`cb`, `thisArg`): `RT`[] @@ -1103,7 +1102,29 @@ Maps collection items from the end of the collection to the front into a new arr #### Defined in -[src/LinkedCollection.ts:172](https://github.com/zimmed/prefab/blob/a5ffdd1/src/LinkedCollection.ts#L172) +[src/LinkedCollection.ts:172](https://github.com/zimmed/prefab/blob/83cd828/src/LinkedCollection.ts#L172) + +___ + +### select + +▸ **select**(`key`): `undefined` \| `T` + +Get an item in the collection by its key + +#### Parameters + +| Name | Type | +| :------ | :------ | +| `key` | `T`[`K`] | + +#### Returns + +`undefined` \| `T` + +#### Defined in + +[src/LinkedCollection.ts:70](https://github.com/zimmed/prefab/blob/83cd828/src/LinkedCollection.ts#L70) ___ @@ -1123,7 +1144,7 @@ Shifts item off of the front of the collection #### Defined in -[src/LinkedCollection.ts:39](https://github.com/zimmed/prefab/blob/a5ffdd1/src/LinkedCollection.ts#L39) +[src/LinkedCollection.ts:39](https://github.com/zimmed/prefab/blob/83cd828/src/LinkedCollection.ts#L39) ___ @@ -1150,7 +1171,7 @@ Moves node to the end of the list #### Defined in -[src/LinkedList.ts:155](https://github.com/zimmed/prefab/blob/a5ffdd1/src/LinkedList.ts#L155) +[src/LinkedList.ts:146](https://github.com/zimmed/prefab/blob/83cd828/src/LinkedList.ts#L146) ___ @@ -1170,7 +1191,7 @@ Converts list to native Array #### Defined in -[src/LinkedList.ts:179](https://github.com/zimmed/prefab/blob/a5ffdd1/src/LinkedList.ts#L179) +[src/LinkedList.ts:170](https://github.com/zimmed/prefab/blob/83cd828/src/LinkedList.ts#L170) ___ @@ -1188,7 +1209,7 @@ ___ #### Defined in -[src/LinkedList.ts:387](https://github.com/zimmed/prefab/blob/a5ffdd1/src/LinkedList.ts#L387) +[src/LinkedList.ts:378](https://github.com/zimmed/prefab/blob/83cd828/src/LinkedList.ts#L378) ___ @@ -1214,7 +1235,7 @@ Alias for insert #### Defined in -[src/LinkedList.ts:117](https://github.com/zimmed/prefab/blob/a5ffdd1/src/LinkedList.ts#L117) +[src/LinkedList.ts:107](https://github.com/zimmed/prefab/blob/83cd828/src/LinkedList.ts#L107) ___ @@ -1236,7 +1257,7 @@ Append unique item to the end of the collection or update exiting item #### Defined in -[src/LinkedCollection.ts:75](https://github.com/zimmed/prefab/blob/a5ffdd1/src/LinkedCollection.ts#L75) +[src/LinkedCollection.ts:75](https://github.com/zimmed/prefab/blob/83cd828/src/LinkedCollection.ts#L75) ___ @@ -1258,7 +1279,7 @@ Insert unique item to the front of the collection or update exiting item #### Defined in -[src/LinkedCollection.ts:88](https://github.com/zimmed/prefab/blob/a5ffdd1/src/LinkedCollection.ts#L88) +[src/LinkedCollection.ts:88](https://github.com/zimmed/prefab/blob/83cd828/src/LinkedCollection.ts#L88) ___ @@ -1278,68 +1299,4 @@ Iterates through list items #### Defined in -[src/LinkedList.ts:207](https://github.com/zimmed/prefab/blob/a5ffdd1/src/LinkedList.ts#L207) - -___ - -### create - -▸ `Static` **create**<`T`\>(`iterable?`): [`LinkedList`](LinkedList.md)<`T`, `LNode`<`T`\>\> - -Static factory method as alias for class constructor - -#### Type parameters - -| Name | -| :------ | -| `T` | - -#### Parameters - -| Name | Type | -| :------ | :------ | -| `iterable?` | `IterableIterator`<`T`\> \| `T`[] \| `Generator`<`T`, `void`, `unknown`\> | - -#### Returns - -[`LinkedList`](LinkedList.md)<`T`, `LNode`<`T`\>\> - -#### Inherited from - -[LinkedList](LinkedList.md).[create](LinkedList.md#create) - -#### Defined in - -[src/LinkedList.ts:20](https://github.com/zimmed/prefab/blob/a5ffdd1/src/LinkedList.ts#L20) - -___ - -### from - -▸ `Static` **from**<`T`\>(`iterable`): [`LinkedList`](LinkedList.md)<`T`, `LNode`<`T`\>\> - -Same as LinkedList.create() but requires constructor arg - -#### Type parameters - -| Name | -| :------ | -| `T` | - -#### Parameters - -| Name | Type | -| :------ | :------ | -| `iterable` | `IterableIterator`<`T`\> \| `T`[] \| `Generator`<`T`, `void`, `unknown`\> | - -#### Returns - -[`LinkedList`](LinkedList.md)<`T`, `LNode`<`T`\>\> - -#### Inherited from - -[LinkedList](LinkedList.md).[from](LinkedList.md#from) - -#### Defined in - -[src/LinkedList.ts:25](https://github.com/zimmed/prefab/blob/a5ffdd1/src/LinkedList.ts#L25) +[src/LinkedList.ts:198](https://github.com/zimmed/prefab/blob/83cd828/src/LinkedList.ts#L198) diff --git a/docs/classes/LinkedList.md b/docs/classes/LinkedList.md index c8667ed..c2ccc37 100644 --- a/docs/classes/LinkedList.md +++ b/docs/classes/LinkedList.md @@ -67,8 +67,6 @@ - [toJSON](LinkedList.md#tojson) - [unshift](LinkedList.md#unshift) - [values](LinkedList.md#values) -- [create](LinkedList.md#create) -- [from](LinkedList.md#from) ## Constructors @@ -92,7 +90,7 @@ #### Defined in -[src/LinkedList.ts:59](https://github.com/zimmed/prefab/blob/a5ffdd1/src/LinkedList.ts#L59) +[src/LinkedList.ts:49](https://github.com/zimmed/prefab/blob/83cd828/src/LinkedList.ts#L49) ## Properties @@ -102,7 +100,7 @@ #### Defined in -[src/LinkedList.ts:30](https://github.com/zimmed/prefab/blob/a5ffdd1/src/LinkedList.ts#L30) +[src/LinkedList.ts:20](https://github.com/zimmed/prefab/blob/83cd828/src/LinkedList.ts#L20) ___ @@ -112,7 +110,7 @@ ___ #### Defined in -[src/LinkedList.ts:33](https://github.com/zimmed/prefab/blob/a5ffdd1/src/LinkedList.ts#L33) +[src/LinkedList.ts:23](https://github.com/zimmed/prefab/blob/83cd828/src/LinkedList.ts#L23) ## Accessors @@ -128,7 +126,7 @@ Item at head of the list #### Defined in -[src/LinkedList.ts:36](https://github.com/zimmed/prefab/blob/a5ffdd1/src/LinkedList.ts#L36) +[src/LinkedList.ts:26](https://github.com/zimmed/prefab/blob/83cd828/src/LinkedList.ts#L26) ___ @@ -144,7 +142,7 @@ Item at tail of the list #### Defined in -[src/LinkedList.ts:40](https://github.com/zimmed/prefab/blob/a5ffdd1/src/LinkedList.ts#L40) +[src/LinkedList.ts:30](https://github.com/zimmed/prefab/blob/83cd828/src/LinkedList.ts#L30) ## Methods @@ -158,7 +156,7 @@ Item at tail of the list #### Defined in -[src/LinkedList.ts:391](https://github.com/zimmed/prefab/blob/a5ffdd1/src/LinkedList.ts#L391) +[src/LinkedList.ts:382](https://github.com/zimmed/prefab/blob/83cd828/src/LinkedList.ts#L382) ___ @@ -178,7 +176,7 @@ ___ #### Defined in -[src/LinkedList.ts:395](https://github.com/zimmed/prefab/blob/a5ffdd1/src/LinkedList.ts#L395) +[src/LinkedList.ts:386](https://github.com/zimmed/prefab/blob/83cd828/src/LinkedList.ts#L386) ___ @@ -200,7 +198,7 @@ Adds item to end of the list #### Defined in -[src/LinkedList.ts:122](https://github.com/zimmed/prefab/blob/a5ffdd1/src/LinkedList.ts#L122) +[src/LinkedList.ts:112](https://github.com/zimmed/prefab/blob/83cd828/src/LinkedList.ts#L112) ___ @@ -223,7 +221,7 @@ Adds node to the end of the list #### Defined in -[src/LinkedList.ts:367](https://github.com/zimmed/prefab/blob/a5ffdd1/src/LinkedList.ts#L367) +[src/LinkedList.ts:358](https://github.com/zimmed/prefab/blob/83cd828/src/LinkedList.ts#L358) ___ @@ -245,7 +243,7 @@ Adds item to end of the list #### Defined in -[src/LinkedList.ts:107](https://github.com/zimmed/prefab/blob/a5ffdd1/src/LinkedList.ts#L107) +[src/LinkedList.ts:97](https://github.com/zimmed/prefab/blob/83cd828/src/LinkedList.ts#L97) ___ @@ -261,7 +259,7 @@ Clears the list #### Defined in -[src/LinkedList.ts:168](https://github.com/zimmed/prefab/blob/a5ffdd1/src/LinkedList.ts#L168) +[src/LinkedList.ts:159](https://github.com/zimmed/prefab/blob/83cd828/src/LinkedList.ts#L159) ___ @@ -277,7 +275,7 @@ Moves element from end of list to the front #### Defined in -[src/LinkedList.ts:127](https://github.com/zimmed/prefab/blob/a5ffdd1/src/LinkedList.ts#L127) +[src/LinkedList.ts:117](https://github.com/zimmed/prefab/blob/83cd828/src/LinkedList.ts#L117) ___ @@ -299,7 +297,7 @@ Removes item from the list #### Defined in -[src/LinkedList.ts:174](https://github.com/zimmed/prefab/blob/a5ffdd1/src/LinkedList.ts#L174) +[src/LinkedList.ts:165](https://github.com/zimmed/prefab/blob/83cd828/src/LinkedList.ts#L165) ___ @@ -321,7 +319,7 @@ Removes specified node from the list #### Defined in -[src/LinkedList.ts:376](https://github.com/zimmed/prefab/blob/a5ffdd1/src/LinkedList.ts#L376) +[src/LinkedList.ts:367](https://github.com/zimmed/prefab/blob/83cd828/src/LinkedList.ts#L367) ___ @@ -337,7 +335,7 @@ Kind of pointless, but needed for parity with builtin Set object #### Defined in -[src/LinkedList.ts:196](https://github.com/zimmed/prefab/blob/a5ffdd1/src/LinkedList.ts#L196) +[src/LinkedList.ts:187](https://github.com/zimmed/prefab/blob/83cd828/src/LinkedList.ts#L187) ___ @@ -359,7 +357,7 @@ Uses predicate to return a new array of all matching items (same signature is Ar #### Defined in -[src/LinkedList.ts:295](https://github.com/zimmed/prefab/blob/a5ffdd1/src/LinkedList.ts#L295) +[src/LinkedList.ts:286](https://github.com/zimmed/prefab/blob/83cd828/src/LinkedList.ts#L286) ▸ **filter**<`This`\>(`predicate`, `thisArg`): `T`[] @@ -382,7 +380,7 @@ Uses predicate to return a new array of all matching items (same signature is Ar #### Defined in -[src/LinkedList.ts:296](https://github.com/zimmed/prefab/blob/a5ffdd1/src/LinkedList.ts#L296) +[src/LinkedList.ts:287](https://github.com/zimmed/prefab/blob/83cd828/src/LinkedList.ts#L287) ___ @@ -404,7 +402,7 @@ Uses predicate to return first matching item or undefined if no matches (same si #### Defined in -[src/LinkedList.ts:269](https://github.com/zimmed/prefab/blob/a5ffdd1/src/LinkedList.ts#L269) +[src/LinkedList.ts:260](https://github.com/zimmed/prefab/blob/83cd828/src/LinkedList.ts#L260) ▸ **find**<`This`\>(`predicate`, `thisArg`): `undefined` \| `T` @@ -427,7 +425,7 @@ Uses predicate to return first matching item or undefined if no matches (same si #### Defined in -[src/LinkedList.ts:270](https://github.com/zimmed/prefab/blob/a5ffdd1/src/LinkedList.ts#L270) +[src/LinkedList.ts:261](https://github.com/zimmed/prefab/blob/83cd828/src/LinkedList.ts#L261) ___ @@ -449,7 +447,7 @@ Operates on each element of the list in a callback method (same signature as Arr #### Defined in -[src/LinkedList.ts:227](https://github.com/zimmed/prefab/blob/a5ffdd1/src/LinkedList.ts#L227) +[src/LinkedList.ts:218](https://github.com/zimmed/prefab/blob/83cd828/src/LinkedList.ts#L218) ▸ **forEach**<`ThisArg`\>(`cb`, `thisArg?`): `void` @@ -472,7 +470,7 @@ Operates on each element of the list in a callback method (same signature as Arr #### Defined in -[src/LinkedList.ts:228](https://github.com/zimmed/prefab/blob/a5ffdd1/src/LinkedList.ts#L228) +[src/LinkedList.ts:219](https://github.com/zimmed/prefab/blob/83cd828/src/LinkedList.ts#L219) ___ @@ -495,7 +493,7 @@ Checks to see if item exists in list #### Defined in -[src/LinkedList.ts:102](https://github.com/zimmed/prefab/blob/a5ffdd1/src/LinkedList.ts#L102) +[src/LinkedList.ts:92](https://github.com/zimmed/prefab/blob/83cd828/src/LinkedList.ts#L92) ___ @@ -518,7 +516,7 @@ Moves node to the front of the list #### Defined in -[src/LinkedList.ts:140](https://github.com/zimmed/prefab/blob/a5ffdd1/src/LinkedList.ts#L140) +[src/LinkedList.ts:130](https://github.com/zimmed/prefab/blob/83cd828/src/LinkedList.ts#L130) ___ @@ -540,7 +538,7 @@ Adds item to front of the list #### Defined in -[src/LinkedList.ts:112](https://github.com/zimmed/prefab/blob/a5ffdd1/src/LinkedList.ts#L112) +[src/LinkedList.ts:102](https://github.com/zimmed/prefab/blob/83cd828/src/LinkedList.ts#L102) ___ @@ -563,7 +561,7 @@ Adds node to the front of the list #### Defined in -[src/LinkedList.ts:355](https://github.com/zimmed/prefab/blob/a5ffdd1/src/LinkedList.ts#L355) +[src/LinkedList.ts:346](https://github.com/zimmed/prefab/blob/83cd828/src/LinkedList.ts#L346) ___ @@ -585,7 +583,7 @@ Joins list elements into one string (same signature as Array.prototype.join) #### Defined in -[src/LinkedList.ts:347](https://github.com/zimmed/prefab/blob/a5ffdd1/src/LinkedList.ts#L347) +[src/LinkedList.ts:338](https://github.com/zimmed/prefab/blob/83cd828/src/LinkedList.ts#L338) ___ @@ -601,7 +599,7 @@ Alias for values() method #### Defined in -[src/LinkedList.ts:191](https://github.com/zimmed/prefab/blob/a5ffdd1/src/LinkedList.ts#L191) +[src/LinkedList.ts:182](https://github.com/zimmed/prefab/blob/83cd828/src/LinkedList.ts#L182) ___ @@ -629,7 +627,7 @@ Maps list items into new array (same signature as Array.prototype.map) #### Defined in -[src/LinkedList.ts:322](https://github.com/zimmed/prefab/blob/a5ffdd1/src/LinkedList.ts#L322) +[src/LinkedList.ts:313](https://github.com/zimmed/prefab/blob/83cd828/src/LinkedList.ts#L313) ▸ **map**<`RT`, `This`\>(`cb`, `thisArg`): `RT`[] @@ -653,7 +651,7 @@ Maps list items into new array (same signature as Array.prototype.map) #### Defined in -[src/LinkedList.ts:323](https://github.com/zimmed/prefab/blob/a5ffdd1/src/LinkedList.ts#L323) +[src/LinkedList.ts:314](https://github.com/zimmed/prefab/blob/83cd828/src/LinkedList.ts#L314) ___ @@ -669,7 +667,7 @@ Removes and returns the last element of the list (or undefined if list is empty) #### Defined in -[src/LinkedList.ts:67](https://github.com/zimmed/prefab/blob/a5ffdd1/src/LinkedList.ts#L67) +[src/LinkedList.ts:57](https://github.com/zimmed/prefab/blob/83cd828/src/LinkedList.ts#L57) ___ @@ -685,7 +683,7 @@ Moves element from front of list to the end #### Defined in -[src/LinkedList.ts:132](https://github.com/zimmed/prefab/blob/a5ffdd1/src/LinkedList.ts#L132) +[src/LinkedList.ts:122](https://github.com/zimmed/prefab/blob/83cd828/src/LinkedList.ts#L122) ___ @@ -714,7 +712,7 @@ Reduces list into specified value (same signature as Array.prototype.reduce) #### Defined in -[src/LinkedList.ts:248](https://github.com/zimmed/prefab/blob/a5ffdd1/src/LinkedList.ts#L248) +[src/LinkedList.ts:239](https://github.com/zimmed/prefab/blob/83cd828/src/LinkedList.ts#L239) ▸ **reduce**<`RT`, `This`\>(`cb`, `initialValue`, `thisArg?`): `RT` @@ -739,7 +737,7 @@ Reduces list into specified value (same signature as Array.prototype.reduce) #### Defined in -[src/LinkedList.ts:249](https://github.com/zimmed/prefab/blob/a5ffdd1/src/LinkedList.ts#L249) +[src/LinkedList.ts:240](https://github.com/zimmed/prefab/blob/83cd828/src/LinkedList.ts#L240) ___ @@ -755,7 +753,7 @@ Iterates through list items in reverse #### Defined in -[src/LinkedList.ts:217](https://github.com/zimmed/prefab/blob/a5ffdd1/src/LinkedList.ts#L217) +[src/LinkedList.ts:208](https://github.com/zimmed/prefab/blob/83cd828/src/LinkedList.ts#L208) ___ @@ -771,7 +769,7 @@ Removes and returns the first element of the list (or undefined if list is empty #### Defined in -[src/LinkedList.ts:83](https://github.com/zimmed/prefab/blob/a5ffdd1/src/LinkedList.ts#L83) +[src/LinkedList.ts:73](https://github.com/zimmed/prefab/blob/83cd828/src/LinkedList.ts#L73) ___ @@ -794,7 +792,7 @@ Moves node to the end of the list #### Defined in -[src/LinkedList.ts:155](https://github.com/zimmed/prefab/blob/a5ffdd1/src/LinkedList.ts#L155) +[src/LinkedList.ts:146](https://github.com/zimmed/prefab/blob/83cd828/src/LinkedList.ts#L146) ___ @@ -810,7 +808,7 @@ Converts list to native Array #### Defined in -[src/LinkedList.ts:179](https://github.com/zimmed/prefab/blob/a5ffdd1/src/LinkedList.ts#L179) +[src/LinkedList.ts:170](https://github.com/zimmed/prefab/blob/83cd828/src/LinkedList.ts#L170) ___ @@ -824,7 +822,7 @@ ___ #### Defined in -[src/LinkedList.ts:387](https://github.com/zimmed/prefab/blob/a5ffdd1/src/LinkedList.ts#L387) +[src/LinkedList.ts:378](https://github.com/zimmed/prefab/blob/83cd828/src/LinkedList.ts#L378) ___ @@ -846,7 +844,7 @@ Alias for insert #### Defined in -[src/LinkedList.ts:117](https://github.com/zimmed/prefab/blob/a5ffdd1/src/LinkedList.ts#L117) +[src/LinkedList.ts:107](https://github.com/zimmed/prefab/blob/83cd828/src/LinkedList.ts#L107) ___ @@ -862,60 +860,4 @@ Iterates through list items #### Defined in -[src/LinkedList.ts:207](https://github.com/zimmed/prefab/blob/a5ffdd1/src/LinkedList.ts#L207) - -___ - -### create - -▸ `Static` **create**<`T`\>(`iterable?`): [`LinkedList`](LinkedList.md)<`T`, `LNode`<`T`\>\> - -Static factory method as alias for class constructor - -#### Type parameters - -| Name | -| :------ | -| `T` | - -#### Parameters - -| Name | Type | -| :------ | :------ | -| `iterable?` | `IterableIterator`<`T`\> \| `T`[] \| `Generator`<`T`, `void`, `unknown`\> | - -#### Returns - -[`LinkedList`](LinkedList.md)<`T`, `LNode`<`T`\>\> - -#### Defined in - -[src/LinkedList.ts:20](https://github.com/zimmed/prefab/blob/a5ffdd1/src/LinkedList.ts#L20) - -___ - -### from - -▸ `Static` **from**<`T`\>(`iterable`): [`LinkedList`](LinkedList.md)<`T`, `LNode`<`T`\>\> - -Same as LinkedList.create() but requires constructor arg - -#### Type parameters - -| Name | -| :------ | -| `T` | - -#### Parameters - -| Name | Type | -| :------ | :------ | -| `iterable` | `IterableIterator`<`T`\> \| `T`[] \| `Generator`<`T`, `void`, `unknown`\> | - -#### Returns - -[`LinkedList`](LinkedList.md)<`T`, `LNode`<`T`\>\> - -#### Defined in - -[src/LinkedList.ts:25](https://github.com/zimmed/prefab/blob/a5ffdd1/src/LinkedList.ts#L25) +[src/LinkedList.ts:198](https://github.com/zimmed/prefab/blob/83cd828/src/LinkedList.ts#L198) diff --git a/docs/classes/LinkedSet.md b/docs/classes/LinkedSet.md index cb0a701..f47e67d 100644 --- a/docs/classes/LinkedSet.md +++ b/docs/classes/LinkedSet.md @@ -15,10 +15,6 @@ ↳ **`LinkedSet`** - ↳↳ [`UniQueue`](UniQueue.md) - - ↳↳ [`SortedSet`](SortedSet.md) - ## Table of contents ### Constructors @@ -71,8 +67,6 @@ - [toJSON](LinkedSet.md#tojson) - [unshift](LinkedSet.md#unshift) - [values](LinkedSet.md#values) -- [create](LinkedSet.md#create) -- [from](LinkedSet.md#from) ## Constructors @@ -100,7 +94,7 @@ #### Defined in -[src/LinkedList.ts:59](https://github.com/zimmed/prefab/blob/a5ffdd1/src/LinkedList.ts#L59) +[src/LinkedList.ts:49](https://github.com/zimmed/prefab/blob/83cd828/src/LinkedList.ts#L49) ## Properties @@ -114,7 +108,7 @@ #### Defined in -[src/LinkedList.ts:30](https://github.com/zimmed/prefab/blob/a5ffdd1/src/LinkedList.ts#L30) +[src/LinkedList.ts:20](https://github.com/zimmed/prefab/blob/83cd828/src/LinkedList.ts#L20) ___ @@ -124,7 +118,7 @@ ___ #### Defined in -[src/LinkedSet.ts:7](https://github.com/zimmed/prefab/blob/a5ffdd1/src/LinkedSet.ts#L7) +[src/LinkedSet.ts:7](https://github.com/zimmed/prefab/blob/83cd828/src/LinkedSet.ts#L7) ___ @@ -138,7 +132,7 @@ ___ #### Defined in -[src/LinkedList.ts:33](https://github.com/zimmed/prefab/blob/a5ffdd1/src/LinkedList.ts#L33) +[src/LinkedList.ts:23](https://github.com/zimmed/prefab/blob/83cd828/src/LinkedList.ts#L23) ## Accessors @@ -158,7 +152,7 @@ LinkedList.head #### Defined in -[src/LinkedList.ts:36](https://github.com/zimmed/prefab/blob/a5ffdd1/src/LinkedList.ts#L36) +[src/LinkedList.ts:26](https://github.com/zimmed/prefab/blob/83cd828/src/LinkedList.ts#L26) ___ @@ -174,7 +168,7 @@ Current size of set #### Defined in -[src/LinkedSet.ts:10](https://github.com/zimmed/prefab/blob/a5ffdd1/src/LinkedSet.ts#L10) +[src/LinkedSet.ts:10](https://github.com/zimmed/prefab/blob/83cd828/src/LinkedSet.ts#L10) ___ @@ -194,7 +188,7 @@ LinkedList.tail #### Defined in -[src/LinkedList.ts:40](https://github.com/zimmed/prefab/blob/a5ffdd1/src/LinkedList.ts#L40) +[src/LinkedList.ts:30](https://github.com/zimmed/prefab/blob/83cd828/src/LinkedList.ts#L30) ## Methods @@ -212,7 +206,7 @@ LinkedList.tail #### Defined in -[src/LinkedList.ts:391](https://github.com/zimmed/prefab/blob/a5ffdd1/src/LinkedList.ts#L391) +[src/LinkedList.ts:382](https://github.com/zimmed/prefab/blob/83cd828/src/LinkedList.ts#L382) ___ @@ -238,7 +232,7 @@ Appends unique item to end of the collection #### Defined in -[src/LinkedSet.ts:41](https://github.com/zimmed/prefab/blob/a5ffdd1/src/LinkedSet.ts#L41) +[src/LinkedSet.ts:41](https://github.com/zimmed/prefab/blob/83cd828/src/LinkedSet.ts#L41) ___ @@ -265,7 +259,7 @@ Adds node to the end of the list #### Defined in -[src/LinkedList.ts:367](https://github.com/zimmed/prefab/blob/a5ffdd1/src/LinkedList.ts#L367) +[src/LinkedList.ts:358](https://github.com/zimmed/prefab/blob/83cd828/src/LinkedList.ts#L358) ___ @@ -291,7 +285,7 @@ Adds item to end of the list #### Defined in -[src/LinkedList.ts:107](https://github.com/zimmed/prefab/blob/a5ffdd1/src/LinkedList.ts#L107) +[src/LinkedList.ts:97](https://github.com/zimmed/prefab/blob/83cd828/src/LinkedList.ts#L97) ___ @@ -311,7 +305,7 @@ Clears set #### Defined in -[src/LinkedSet.ts:70](https://github.com/zimmed/prefab/blob/a5ffdd1/src/LinkedSet.ts#L70) +[src/LinkedSet.ts:70](https://github.com/zimmed/prefab/blob/83cd828/src/LinkedSet.ts#L70) ___ @@ -331,7 +325,7 @@ Moves element from end of list to the front #### Defined in -[src/LinkedList.ts:127](https://github.com/zimmed/prefab/blob/a5ffdd1/src/LinkedList.ts#L127) +[src/LinkedList.ts:117](https://github.com/zimmed/prefab/blob/83cd828/src/LinkedList.ts#L117) ___ @@ -357,7 +351,7 @@ Removes specified item from the set #### Defined in -[src/LinkedSet.ts:61](https://github.com/zimmed/prefab/blob/a5ffdd1/src/LinkedSet.ts#L61) +[src/LinkedSet.ts:61](https://github.com/zimmed/prefab/blob/83cd828/src/LinkedSet.ts#L61) ___ @@ -383,7 +377,7 @@ Removes specified node from the list #### Defined in -[src/LinkedList.ts:376](https://github.com/zimmed/prefab/blob/a5ffdd1/src/LinkedList.ts#L376) +[src/LinkedList.ts:367](https://github.com/zimmed/prefab/blob/83cd828/src/LinkedList.ts#L367) ___ @@ -403,7 +397,7 @@ Kind of pointless, but needed for parity with builtin Set object #### Defined in -[src/LinkedList.ts:196](https://github.com/zimmed/prefab/blob/a5ffdd1/src/LinkedList.ts#L196) +[src/LinkedList.ts:187](https://github.com/zimmed/prefab/blob/83cd828/src/LinkedList.ts#L187) ___ @@ -429,7 +423,7 @@ Uses predicate to return a new array of all matching items (same signature is Ar #### Defined in -[src/LinkedList.ts:295](https://github.com/zimmed/prefab/blob/a5ffdd1/src/LinkedList.ts#L295) +[src/LinkedList.ts:286](https://github.com/zimmed/prefab/blob/83cd828/src/LinkedList.ts#L286) ▸ **filter**<`This`\>(`predicate`, `thisArg`): `T`[] @@ -456,7 +450,7 @@ Uses predicate to return a new array of all matching items (same signature is Ar #### Defined in -[src/LinkedList.ts:296](https://github.com/zimmed/prefab/blob/a5ffdd1/src/LinkedList.ts#L296) +[src/LinkedList.ts:287](https://github.com/zimmed/prefab/blob/83cd828/src/LinkedList.ts#L287) ___ @@ -482,7 +476,7 @@ Uses predicate to return first matching item or undefined if no matches (same si #### Defined in -[src/LinkedList.ts:269](https://github.com/zimmed/prefab/blob/a5ffdd1/src/LinkedList.ts#L269) +[src/LinkedList.ts:260](https://github.com/zimmed/prefab/blob/83cd828/src/LinkedList.ts#L260) ▸ **find**<`This`\>(`predicate`, `thisArg`): `undefined` \| `T` @@ -509,7 +503,7 @@ Uses predicate to return first matching item or undefined if no matches (same si #### Defined in -[src/LinkedList.ts:270](https://github.com/zimmed/prefab/blob/a5ffdd1/src/LinkedList.ts#L270) +[src/LinkedList.ts:261](https://github.com/zimmed/prefab/blob/83cd828/src/LinkedList.ts#L261) ___ @@ -531,7 +525,7 @@ Finds predicate-matching item, with iteration beginning at the end of the set #### Defined in -[src/LinkedSet.ts:92](https://github.com/zimmed/prefab/blob/a5ffdd1/src/LinkedSet.ts#L92) +[src/LinkedSet.ts:92](https://github.com/zimmed/prefab/blob/83cd828/src/LinkedSet.ts#L92) ▸ **findRight**<`This`\>(`predicate`, `thisArg`): `undefined` \| `T` @@ -554,7 +548,7 @@ Finds predicate-matching item, with iteration beginning at the end of the set #### Defined in -[src/LinkedSet.ts:93](https://github.com/zimmed/prefab/blob/a5ffdd1/src/LinkedSet.ts#L93) +[src/LinkedSet.ts:93](https://github.com/zimmed/prefab/blob/83cd828/src/LinkedSet.ts#L93) ___ @@ -580,7 +574,7 @@ Operates on each element of the list in a callback method (same signature as Arr #### Defined in -[src/LinkedList.ts:227](https://github.com/zimmed/prefab/blob/a5ffdd1/src/LinkedList.ts#L227) +[src/LinkedList.ts:218](https://github.com/zimmed/prefab/blob/83cd828/src/LinkedList.ts#L218) ▸ **forEach**<`ThisArg`\>(`cb`, `thisArg?`): `void` @@ -607,7 +601,7 @@ Operates on each element of the list in a callback method (same signature as Arr #### Defined in -[src/LinkedList.ts:228](https://github.com/zimmed/prefab/blob/a5ffdd1/src/LinkedList.ts#L228) +[src/LinkedList.ts:219](https://github.com/zimmed/prefab/blob/83cd828/src/LinkedList.ts#L219) ___ @@ -633,7 +627,7 @@ Determines if set contains specified item #### Defined in -[src/LinkedSet.ts:36](https://github.com/zimmed/prefab/blob/a5ffdd1/src/LinkedSet.ts#L36) +[src/LinkedSet.ts:36](https://github.com/zimmed/prefab/blob/83cd828/src/LinkedSet.ts#L36) ___ @@ -660,7 +654,7 @@ Moves node to the front of the list #### Defined in -[src/LinkedList.ts:140](https://github.com/zimmed/prefab/blob/a5ffdd1/src/LinkedList.ts#L140) +[src/LinkedList.ts:130](https://github.com/zimmed/prefab/blob/83cd828/src/LinkedList.ts#L130) ___ @@ -686,7 +680,7 @@ Inserts unique item into the front of the collection #### Defined in -[src/LinkedSet.ts:51](https://github.com/zimmed/prefab/blob/a5ffdd1/src/LinkedSet.ts#L51) +[src/LinkedSet.ts:51](https://github.com/zimmed/prefab/blob/83cd828/src/LinkedSet.ts#L51) ___ @@ -713,7 +707,7 @@ Adds node to the front of the list #### Defined in -[src/LinkedList.ts:355](https://github.com/zimmed/prefab/blob/a5ffdd1/src/LinkedList.ts#L355) +[src/LinkedList.ts:346](https://github.com/zimmed/prefab/blob/83cd828/src/LinkedList.ts#L346) ___ @@ -739,7 +733,7 @@ Joins list elements into one string (same signature as Array.prototype.join) #### Defined in -[src/LinkedList.ts:347](https://github.com/zimmed/prefab/blob/a5ffdd1/src/LinkedList.ts#L347) +[src/LinkedList.ts:338](https://github.com/zimmed/prefab/blob/83cd828/src/LinkedList.ts#L338) ___ @@ -759,7 +753,7 @@ Alias for values() method #### Defined in -[src/LinkedList.ts:191](https://github.com/zimmed/prefab/blob/a5ffdd1/src/LinkedList.ts#L191) +[src/LinkedList.ts:182](https://github.com/zimmed/prefab/blob/83cd828/src/LinkedList.ts#L182) ___ @@ -791,7 +785,7 @@ Maps set items into a new array #### Defined in -[src/LinkedSet.ts:103](https://github.com/zimmed/prefab/blob/a5ffdd1/src/LinkedSet.ts#L103) +[src/LinkedSet.ts:103](https://github.com/zimmed/prefab/blob/83cd828/src/LinkedSet.ts#L103) ▸ **map**<`RT`, `This`\>(`cb`, `thisArg`): `RT`[] @@ -819,7 +813,7 @@ Maps set items into a new array #### Defined in -[src/LinkedSet.ts:104](https://github.com/zimmed/prefab/blob/a5ffdd1/src/LinkedSet.ts#L104) +[src/LinkedSet.ts:104](https://github.com/zimmed/prefab/blob/83cd828/src/LinkedSet.ts#L104) ___ @@ -839,7 +833,7 @@ Pops item from the end of the set #### Defined in -[src/LinkedSet.ts:15](https://github.com/zimmed/prefab/blob/a5ffdd1/src/LinkedSet.ts#L15) +[src/LinkedSet.ts:15](https://github.com/zimmed/prefab/blob/83cd828/src/LinkedSet.ts#L15) ___ @@ -859,7 +853,7 @@ Moves element from front of list to the end #### Defined in -[src/LinkedList.ts:132](https://github.com/zimmed/prefab/blob/a5ffdd1/src/LinkedList.ts#L132) +[src/LinkedList.ts:122](https://github.com/zimmed/prefab/blob/83cd828/src/LinkedList.ts#L122) ___ @@ -892,7 +886,7 @@ Reduces list into specified value (same signature as Array.prototype.reduce) #### Defined in -[src/LinkedList.ts:248](https://github.com/zimmed/prefab/blob/a5ffdd1/src/LinkedList.ts#L248) +[src/LinkedList.ts:239](https://github.com/zimmed/prefab/blob/83cd828/src/LinkedList.ts#L239) ▸ **reduce**<`RT`, `This`\>(`cb`, `initialValue`, `thisArg?`): `RT` @@ -921,7 +915,7 @@ Reduces list into specified value (same signature as Array.prototype.reduce) #### Defined in -[src/LinkedList.ts:249](https://github.com/zimmed/prefab/blob/a5ffdd1/src/LinkedList.ts#L249) +[src/LinkedList.ts:240](https://github.com/zimmed/prefab/blob/83cd828/src/LinkedList.ts#L240) ___ @@ -950,7 +944,7 @@ Reduces items from the end of the set to the front #### Defined in -[src/LinkedSet.ts:76](https://github.com/zimmed/prefab/blob/a5ffdd1/src/LinkedSet.ts#L76) +[src/LinkedSet.ts:76](https://github.com/zimmed/prefab/blob/83cd828/src/LinkedSet.ts#L76) ▸ **reduceRight**<`RT`, `This`\>(`cb`, `initialValue`, `thisArg?`): `RT` @@ -975,7 +969,7 @@ Reduces items from the end of the set to the front #### Defined in -[src/LinkedSet.ts:77](https://github.com/zimmed/prefab/blob/a5ffdd1/src/LinkedSet.ts#L77) +[src/LinkedSet.ts:77](https://github.com/zimmed/prefab/blob/83cd828/src/LinkedSet.ts#L77) ___ @@ -995,7 +989,7 @@ Iterates through list items in reverse #### Defined in -[src/LinkedList.ts:217](https://github.com/zimmed/prefab/blob/a5ffdd1/src/LinkedList.ts#L217) +[src/LinkedList.ts:208](https://github.com/zimmed/prefab/blob/83cd828/src/LinkedList.ts#L208) ___ @@ -1023,7 +1017,7 @@ Maps set items from the end of the set to the front into a new array #### Defined in -[src/LinkedSet.ts:111](https://github.com/zimmed/prefab/blob/a5ffdd1/src/LinkedSet.ts#L111) +[src/LinkedSet.ts:111](https://github.com/zimmed/prefab/blob/83cd828/src/LinkedSet.ts#L111) ▸ **reverseMap**<`RT`, `This`\>(`cb`, `thisArg`): `RT`[] @@ -1047,7 +1041,7 @@ Maps set items from the end of the set to the front into a new array #### Defined in -[src/LinkedSet.ts:112](https://github.com/zimmed/prefab/blob/a5ffdd1/src/LinkedSet.ts#L112) +[src/LinkedSet.ts:112](https://github.com/zimmed/prefab/blob/83cd828/src/LinkedSet.ts#L112) ___ @@ -1067,7 +1061,7 @@ Shifts item off of the front of the set #### Defined in -[src/LinkedSet.ts:26](https://github.com/zimmed/prefab/blob/a5ffdd1/src/LinkedSet.ts#L26) +[src/LinkedSet.ts:26](https://github.com/zimmed/prefab/blob/83cd828/src/LinkedSet.ts#L26) ___ @@ -1094,7 +1088,7 @@ Moves node to the end of the list #### Defined in -[src/LinkedList.ts:155](https://github.com/zimmed/prefab/blob/a5ffdd1/src/LinkedList.ts#L155) +[src/LinkedList.ts:146](https://github.com/zimmed/prefab/blob/83cd828/src/LinkedList.ts#L146) ___ @@ -1114,7 +1108,7 @@ Converts list to native Array #### Defined in -[src/LinkedList.ts:179](https://github.com/zimmed/prefab/blob/a5ffdd1/src/LinkedList.ts#L179) +[src/LinkedList.ts:170](https://github.com/zimmed/prefab/blob/83cd828/src/LinkedList.ts#L170) ___ @@ -1132,7 +1126,7 @@ ___ #### Defined in -[src/LinkedList.ts:387](https://github.com/zimmed/prefab/blob/a5ffdd1/src/LinkedList.ts#L387) +[src/LinkedList.ts:378](https://github.com/zimmed/prefab/blob/83cd828/src/LinkedList.ts#L378) ___ @@ -1158,7 +1152,7 @@ Alias for insert #### Defined in -[src/LinkedList.ts:117](https://github.com/zimmed/prefab/blob/a5ffdd1/src/LinkedList.ts#L117) +[src/LinkedList.ts:107](https://github.com/zimmed/prefab/blob/83cd828/src/LinkedList.ts#L107) ___ @@ -1178,68 +1172,4 @@ Iterates through list items #### Defined in -[src/LinkedList.ts:207](https://github.com/zimmed/prefab/blob/a5ffdd1/src/LinkedList.ts#L207) - -___ - -### create - -▸ `Static` **create**<`T`\>(`iterable?`): [`LinkedList`](LinkedList.md)<`T`, `LNode`<`T`\>\> - -Static factory method as alias for class constructor - -#### Type parameters - -| Name | -| :------ | -| `T` | - -#### Parameters - -| Name | Type | -| :------ | :------ | -| `iterable?` | `IterableIterator`<`T`\> \| `T`[] \| `Generator`<`T`, `void`, `unknown`\> | - -#### Returns - -[`LinkedList`](LinkedList.md)<`T`, `LNode`<`T`\>\> - -#### Inherited from - -[LinkedList](LinkedList.md).[create](LinkedList.md#create) - -#### Defined in - -[src/LinkedList.ts:20](https://github.com/zimmed/prefab/blob/a5ffdd1/src/LinkedList.ts#L20) - -___ - -### from - -▸ `Static` **from**<`T`\>(`iterable`): [`LinkedList`](LinkedList.md)<`T`, `LNode`<`T`\>\> - -Same as LinkedList.create() but requires constructor arg - -#### Type parameters - -| Name | -| :------ | -| `T` | - -#### Parameters - -| Name | Type | -| :------ | :------ | -| `iterable` | `IterableIterator`<`T`\> \| `T`[] \| `Generator`<`T`, `void`, `unknown`\> | - -#### Returns - -[`LinkedList`](LinkedList.md)<`T`, `LNode`<`T`\>\> - -#### Inherited from - -[LinkedList](LinkedList.md).[from](LinkedList.md#from) - -#### Defined in - -[src/LinkedList.ts:25](https://github.com/zimmed/prefab/blob/a5ffdd1/src/LinkedList.ts#L25) +[src/LinkedList.ts:198](https://github.com/zimmed/prefab/blob/83cd828/src/LinkedList.ts#L198) diff --git a/docs/classes/ObjectPool.md b/docs/classes/ObjectPool.md index 586f04e..a6e0ff1 100644 --- a/docs/classes/ObjectPool.md +++ b/docs/classes/ObjectPool.md @@ -6,7 +6,7 @@ | Name | Type | | :------ | :------ | -| `O` | extends `PoolObject` | +| `O` | extends [`PoolObject`](PoolObject.md) | ## Table of contents @@ -27,6 +27,7 @@ ### Methods +- [[iterator]](ObjectPool.md#[iterator]) - [add](ObjectPool.md#add) - [alloc](ObjectPool.md#alloc) - [clear](ObjectPool.md#clear) @@ -36,9 +37,11 @@ - [forceSpawn](ObjectPool.md#forcespawn) - [free](ObjectPool.md#free) - [insert](ObjectPool.md#insert) +- [items](ObjectPool.md#items) - [realloc](ObjectPool.md#realloc) - [reallocUnsafe](ObjectPool.md#reallocunsafe) - [spawn](ObjectPool.md#spawn) +- [toJSON](ObjectPool.md#tojson) - [create](ObjectPool.md#create-1) ## Constructors @@ -51,7 +54,7 @@ | Name | Type | | :------ | :------ | -| `O` | extends `PoolObject`<`O`\> | +| `O` | extends [`PoolObject`](PoolObject.md)<`O`\> | #### Parameters @@ -62,7 +65,7 @@ #### Defined in -[src/ObjectPool.ts:63](https://github.com/zimmed/prefab/blob/a5ffdd1/src/ObjectPool.ts#L63) +[src/ObjectPool.ts:57](https://github.com/zimmed/prefab/blob/83cd828/src/ObjectPool.ts#L57) ## Properties @@ -76,7 +79,7 @@ #### Defined in -[src/ObjectPool.ts:48](https://github.com/zimmed/prefab/blob/a5ffdd1/src/ObjectPool.ts#L48) +[src/ObjectPool.ts:47](https://github.com/zimmed/prefab/blob/83cd828/src/ObjectPool.ts#L47) ___ @@ -86,7 +89,7 @@ ___ #### Defined in -[src/ObjectPool.ts:45](https://github.com/zimmed/prefab/blob/a5ffdd1/src/ObjectPool.ts#L45) +[src/ObjectPool.ts:44](https://github.com/zimmed/prefab/blob/83cd828/src/ObjectPool.ts#L44) ___ @@ -96,19 +99,19 @@ ___ #### Defined in -[src/ObjectPool.ts:51](https://github.com/zimmed/prefab/blob/a5ffdd1/src/ObjectPool.ts#L51) +[src/ObjectPool.ts:50](https://github.com/zimmed/prefab/blob/83cd828/src/ObjectPool.ts#L50) ___ ### Object -▪ `Static` **Object**: typeof `PoolObject` = `PoolObject` +▪ `Static` **Object**: typeof [`PoolObject`](PoolObject.md) = `PoolObject` Objects within the pool must inherit from ObjectPool.Object #### Defined in -[src/ObjectPool.ts:37](https://github.com/zimmed/prefab/blob/a5ffdd1/src/ObjectPool.ts#L37) +[src/ObjectPool.ts:36](https://github.com/zimmed/prefab/blob/83cd828/src/ObjectPool.ts#L36) ## Accessors @@ -124,10 +127,24 @@ The current (max) size of the object pool #### Defined in -[src/ObjectPool.ts:54](https://github.com/zimmed/prefab/blob/a5ffdd1/src/ObjectPool.ts#L54) +[src/ObjectPool.ts:53](https://github.com/zimmed/prefab/blob/83cd828/src/ObjectPool.ts#L53) ## Methods +### [iterator] + +▸ **[iterator]**(): `Generator`<`O`, `void`, `unknown`\> + +#### Returns + +`Generator`<`O`, `void`, `unknown`\> + +#### Defined in + +[src/ObjectPool.ts:70](https://github.com/zimmed/prefab/blob/83cd828/src/ObjectPool.ts#L70) + +___ + ### add ▸ `Protected` **add**(`obj`): `void` @@ -146,13 +163,13 @@ Append new object to end of the pool queue #### Defined in -[src/ObjectPool.ts:175](https://github.com/zimmed/prefab/blob/a5ffdd1/src/ObjectPool.ts#L175) +[src/ObjectPool.ts:175](https://github.com/zimmed/prefab/blob/83cd828/src/ObjectPool.ts#L175) ___ ### alloc -▸ **alloc**(`size?`): `void` +▸ **alloc**(`size?`): [`ObjectPool`](ObjectPool.md)<`O`\> Increases pool size and allocates new objects to fill it @@ -164,27 +181,27 @@ Increases pool size and allocates new objects to fill it #### Returns -`void` +[`ObjectPool`](ObjectPool.md)<`O`\> #### Defined in -[src/ObjectPool.ts:121](https://github.com/zimmed/prefab/blob/a5ffdd1/src/ObjectPool.ts#L121) +[src/ObjectPool.ts:113](https://github.com/zimmed/prefab/blob/83cd828/src/ObjectPool.ts#L113) ___ ### clear -▸ **clear**(): `void` +▸ **clear**(): [`ObjectPool`](ObjectPool.md)<`O`\> Completely clear the pool, freeing all objects from memory #### Returns -`void` +[`ObjectPool`](ObjectPool.md)<`O`\> #### Defined in -[src/ObjectPool.ts:154](https://github.com/zimmed/prefab/blob/a5ffdd1/src/ObjectPool.ts#L154) +[src/ObjectPool.ts:150](https://github.com/zimmed/prefab/blob/83cd828/src/ObjectPool.ts#L150) ___ @@ -200,13 +217,13 @@ Create and return new PoolObject #### Defined in -[src/ObjectPool.ts:167](https://github.com/zimmed/prefab/blob/a5ffdd1/src/ObjectPool.ts#L167) +[src/ObjectPool.ts:167](https://github.com/zimmed/prefab/blob/83cd828/src/ObjectPool.ts#L167) ___ ### dealloc -▸ **dealloc**(`size?`): `void` +▸ **dealloc**(`size?`): [`ObjectPool`](ObjectPool.md)<`O`\> Downsize pool by specified amount, deallocating overflowing objects @@ -218,17 +235,17 @@ Downsize pool by specified amount, deallocating overflowing objects #### Returns -`void` +[`ObjectPool`](ObjectPool.md)<`O`\> #### Defined in -[src/ObjectPool.ts:159](https://github.com/zimmed/prefab/blob/a5ffdd1/src/ObjectPool.ts#L159) +[src/ObjectPool.ts:155](https://github.com/zimmed/prefab/blob/83cd828/src/ObjectPool.ts#L155) ___ ### deallocateObject -▸ **deallocateObject**(`obj?`, `del?`): `boolean` +▸ `Protected` **deallocateObject**(`obj?`, `del?`): `boolean` Cleans and removes object from pool entirely @@ -245,7 +262,7 @@ Cleans and removes object from pool entirely #### Defined in -[src/ObjectPool.ts:108](https://github.com/zimmed/prefab/blob/a5ffdd1/src/ObjectPool.ts#L108) +[src/ObjectPool.ts:187](https://github.com/zimmed/prefab/blob/83cd828/src/ObjectPool.ts#L187) ___ @@ -259,7 +276,7 @@ Spawns and initializes object from pool, or create new object and increase pool | Name | Type | | :------ | :------ | -| `...args` | `InitArgs`<`O`, `O`[``"onInit"``]\> | +| `...args` | `InitArgs`<`O`\> | #### Returns @@ -267,13 +284,13 @@ Spawns and initializes object from pool, or create new object and increase pool #### Defined in -[src/ObjectPool.ts:70](https://github.com/zimmed/prefab/blob/a5ffdd1/src/ObjectPool.ts#L70) +[src/ObjectPool.ts:75](https://github.com/zimmed/prefab/blob/83cd828/src/ObjectPool.ts#L75) ___ ### free -▸ **free**(`item`): `void` +▸ **free**(`item`): [`ObjectPool`](ObjectPool.md)<`O`\> Returns object back to pool to be re-used later @@ -285,11 +302,11 @@ Returns object back to pool to be re-used later #### Returns -`void` +[`ObjectPool`](ObjectPool.md)<`O`\> #### Defined in -[src/ObjectPool.ts:101](https://github.com/zimmed/prefab/blob/a5ffdd1/src/ObjectPool.ts#L101) +[src/ObjectPool.ts:106](https://github.com/zimmed/prefab/blob/83cd828/src/ObjectPool.ts#L106) ___ @@ -311,13 +328,27 @@ Insert new object into front of the pool queue #### Defined in -[src/ObjectPool.ts:181](https://github.com/zimmed/prefab/blob/a5ffdd1/src/ObjectPool.ts#L181) +[src/ObjectPool.ts:181](https://github.com/zimmed/prefab/blob/83cd828/src/ObjectPool.ts#L181) + +___ + +### items + +▸ **items**(): `Generator`<`O`, `void`, `unknown`\> + +#### Returns + +`Generator`<`O`, `void`, `unknown`\> + +#### Defined in + +[src/ObjectPool.ts:63](https://github.com/zimmed/prefab/blob/83cd828/src/ObjectPool.ts#L63) ___ ### realloc -▸ **realloc**(`size?`): `void` +▸ **realloc**(`size?`): [`ObjectPool`](ObjectPool.md)<`O`\> Sets max pool size, but ignores call if provided size is smaller than current max @@ -329,17 +360,17 @@ Sets max pool size, but ignores call if provided size is smaller than current ma #### Returns -`void` +[`ObjectPool`](ObjectPool.md)<`O`\> #### Defined in -[src/ObjectPool.ts:143](https://github.com/zimmed/prefab/blob/a5ffdd1/src/ObjectPool.ts#L143) +[src/ObjectPool.ts:139](https://github.com/zimmed/prefab/blob/83cd828/src/ObjectPool.ts#L139) ___ ### reallocUnsafe -▸ **reallocUnsafe**(`size?`): `void` +▸ **reallocUnsafe**(`size?`): [`ObjectPool`](ObjectPool.md)<`O`\> Overrides max pool size, deallocating any overflowing objects @@ -351,11 +382,11 @@ Overrides max pool size, deallocating any overflowing objects #### Returns -`void` +[`ObjectPool`](ObjectPool.md)<`O`\> #### Defined in -[src/ObjectPool.ts:129](https://github.com/zimmed/prefab/blob/a5ffdd1/src/ObjectPool.ts#L129) +[src/ObjectPool.ts:124](https://github.com/zimmed/prefab/blob/83cd828/src/ObjectPool.ts#L124) ___ @@ -369,7 +400,7 @@ Spawns and initializes object from pool (if any are free) | Name | Type | | :------ | :------ | -| `...args` | `InitArgs`<`O`, `O`[``"onInit"``]\> | +| `...args` | `InitArgs`<`O`\> | #### Returns @@ -377,7 +408,21 @@ Spawns and initializes object from pool (if any are free) #### Defined in -[src/ObjectPool.ts:88](https://github.com/zimmed/prefab/blob/a5ffdd1/src/ObjectPool.ts#L88) +[src/ObjectPool.ts:93](https://github.com/zimmed/prefab/blob/83cd828/src/ObjectPool.ts#L93) + +___ + +### toJSON + +▸ **toJSON**(): `O`[] + +#### Returns + +`O`[] + +#### Defined in + +[src/ObjectPool.ts:204](https://github.com/zimmed/prefab/blob/83cd828/src/ObjectPool.ts#L204) ___ @@ -391,7 +436,7 @@ Static factory method as alias for class constructor | Name | Type | | :------ | :------ | -| `O` | extends `PoolObject`<`O`\> | +| `O` | extends [`PoolObject`](PoolObject.md)<`O`\> | #### Parameters @@ -406,4 +451,4 @@ Static factory method as alias for class constructor #### Defined in -[src/ObjectPool.ts:40](https://github.com/zimmed/prefab/blob/a5ffdd1/src/ObjectPool.ts#L40) +[src/ObjectPool.ts:39](https://github.com/zimmed/prefab/blob/83cd828/src/ObjectPool.ts#L39) diff --git a/docs/classes/PoolObject.md b/docs/classes/PoolObject.md new file mode 100644 index 0000000..d95e59e --- /dev/null +++ b/docs/classes/PoolObject.md @@ -0,0 +1,78 @@ +[@zimmed/prefab](../README.md) / [Exports](../modules.md) / PoolObject + +# Class: PoolObject + +## Table of contents + +### Constructors + +- [constructor](PoolObject.md#constructor) + +### Properties + +- [poolState](PoolObject.md#poolstate) + +### Methods + +- [onClean](PoolObject.md#onclean) +- [onInit](PoolObject.md#oninit) + +## Constructors + +### constructor + +• **new PoolObject**() + +Constructor must take no arguments + +#### Defined in + +[src/ObjectPool.ts:25](https://github.com/zimmed/prefab/blob/83cd828/src/ObjectPool.ts#L25) + +## Properties + +### poolState + +• `Readonly` **poolState**: `PoolState`<[`PoolObject`](PoolObject.md)\> + +#### Defined in + +[src/ObjectPool.ts:16](https://github.com/zimmed/prefab/blob/83cd828/src/ObjectPool.ts#L16) + +## Methods + +### onClean + +▸ `Abstract` **onClean**(): `void` + +Deinitializer called when object is put back into the pool or freed from memory + +#### Returns + +`void` + +#### Defined in + +[src/ObjectPool.ts:31](https://github.com/zimmed/prefab/blob/83cd828/src/ObjectPool.ts#L31) + +___ + +### onInit + +▸ `Abstract` **onInit**(...`args`): `void` + +Initializer for when object is spawned by the pool + +#### Parameters + +| Name | Type | +| :------ | :------ | +| `...args` | `any`[] | + +#### Returns + +`void` + +#### Defined in + +[src/ObjectPool.ts:28](https://github.com/zimmed/prefab/blob/83cd828/src/ObjectPool.ts#L28) diff --git a/docs/classes/PriorityQueue.md b/docs/classes/PriorityQueue.md deleted file mode 100644 index 18b6305..0000000 --- a/docs/classes/PriorityQueue.md +++ /dev/null @@ -1,1402 +0,0 @@ -[@zimmed/prefab](../README.md) / [Exports](../modules.md) / PriorityQueue - -# Class: PriorityQueue - -## Type parameters - -| Name | -| :------ | -| `T` | - -## Hierarchy - -- [`SortedSet`](SortedSet.md)<`T`\> - - ↳ **`PriorityQueue`** - -## Table of contents - -### Constructors - -- [constructor](PriorityQueue.md#constructor) - -### Properties - -- [\_cMap](PriorityQueue.md#_cmap) -- [\_count](PriorityQueue.md#_count) -- [\_head](PriorityQueue.md#_head) -- [\_map](PriorityQueue.md#_map) -- [\_pMap](PriorityQueue.md#_pmap) -- [\_rCount](PriorityQueue.md#_rcount) -- [\_tail](PriorityQueue.md#_tail) -- [\_tree](PriorityQueue.md#_tree) - -### Accessors - -- [head](PriorityQueue.md#head) -- [size](PriorityQueue.md#size) -- [tail](PriorityQueue.md#tail) - -### Methods - -- [[iterator]](PriorityQueue.md#[iterator]) -- [add](PriorityQueue.md#add) -- [addNode](PriorityQueue.md#addnode) -- [append](PriorityQueue.md#append) -- [clear](PriorityQueue.md#clear) -- [cycle](PriorityQueue.md#cycle) -- [delete](PriorityQueue.md#delete) -- [deleteNode](PriorityQueue.md#deletenode) -- [dequeue](PriorityQueue.md#dequeue) -- [enqueue](PriorityQueue.md#enqueue) -- [entries](PriorityQueue.md#entries) -- [filter](PriorityQueue.md#filter) -- [find](PriorityQueue.md#find) -- [findRight](PriorityQueue.md#findright) -- [forEach](PriorityQueue.md#foreach) -- [has](PriorityQueue.md#has) -- [headNode](PriorityQueue.md#headnode) -- [insert](PriorityQueue.md#insert) -- [insertNode](PriorityQueue.md#insertnode) -- [join](PriorityQueue.md#join) -- [keys](PriorityQueue.md#keys) -- [map](PriorityQueue.md#map) -- [pop](PriorityQueue.md#pop) -- [recycle](PriorityQueue.md#recycle) -- [reduce](PriorityQueue.md#reduce) -- [reduceRight](PriorityQueue.md#reduceright) -- [reverse](PriorityQueue.md#reverse) -- [reverseMap](PriorityQueue.md#reversemap) -- [search](PriorityQueue.md#search) -- [shift](PriorityQueue.md#shift) -- [tailNode](PriorityQueue.md#tailnode) -- [toArray](PriorityQueue.md#toarray) -- [toJSON](PriorityQueue.md#tojson) -- [unshift](PriorityQueue.md#unshift) -- [values](PriorityQueue.md#values) -- [create](PriorityQueue.md#create) -- [from](PriorityQueue.md#from) - -## Constructors - -### constructor - -• **new PriorityQueue**<`T`\>(`iterable?`) - -#### Type parameters - -| Name | -| :------ | -| `T` | - -#### Parameters - -| Name | Type | -| :------ | :------ | -| `iterable?` | `IterableIterator`<`T`\> \| `T`[] \| `Generator`<`T`, `void`, `unknown`\> | - -#### Overrides - -[SortedSet](SortedSet.md).[constructor](SortedSet.md#constructor) - -#### Defined in - -[src/PriorityQueue.ts:38](https://github.com/zimmed/prefab/blob/a5ffdd1/src/PriorityQueue.ts#L38) - -## Properties - -### \_cMap - -• `Protected` `Readonly` **\_cMap**: `Map`<`T`, `number`\> - -#### Defined in - -[src/PriorityQueue.ts:36](https://github.com/zimmed/prefab/blob/a5ffdd1/src/PriorityQueue.ts#L36) - -___ - -### \_count - -• `Private` **\_count**: `number` = `0` - -#### Defined in - -[src/PriorityQueue.ts:30](https://github.com/zimmed/prefab/blob/a5ffdd1/src/PriorityQueue.ts#L30) - -___ - -### \_head - -• `Protected` `Optional` **\_head**: `LNode`<`T`\> - -#### Inherited from - -[SortedSet](SortedSet.md).[_head](SortedSet.md#_head) - -#### Defined in - -[src/LinkedList.ts:30](https://github.com/zimmed/prefab/blob/a5ffdd1/src/LinkedList.ts#L30) - -___ - -### \_map - -• `Protected` `Readonly` **\_map**: `Map`<`T`, `LNode`<`T`\>\> - -#### Inherited from - -[SortedSet](SortedSet.md).[_map](SortedSet.md#_map) - -#### Defined in - -[src/LinkedSet.ts:7](https://github.com/zimmed/prefab/blob/a5ffdd1/src/LinkedSet.ts#L7) - -___ - -### \_pMap - -• `Protected` `Readonly` **\_pMap**: `Map`<`T`, `number`\> - -#### Defined in - -[src/PriorityQueue.ts:33](https://github.com/zimmed/prefab/blob/a5ffdd1/src/PriorityQueue.ts#L33) - -___ - -### \_rCount - -• `Private` **\_rCount**: `number` = `0` - -#### Defined in - -[src/PriorityQueue.ts:27](https://github.com/zimmed/prefab/blob/a5ffdd1/src/PriorityQueue.ts#L27) - -___ - -### \_tail - -• `Protected` `Optional` **\_tail**: `LNode`<`T`\> - -#### Inherited from - -[SortedSet](SortedSet.md).[_tail](SortedSet.md#_tail) - -#### Defined in - -[src/LinkedList.ts:33](https://github.com/zimmed/prefab/blob/a5ffdd1/src/LinkedList.ts#L33) - -___ - -### \_tree - -• `Protected` `Optional` **\_tree**: `TNode`<`T`\> - -#### Inherited from - -[SortedSet](SortedSet.md).[_tree](SortedSet.md#_tree) - -#### Defined in - -[src/SortedSet.ts:35](https://github.com/zimmed/prefab/blob/a5ffdd1/src/SortedSet.ts#L35) - -## Accessors - -### head - -• `get` **head**(): `undefined` \| `T` - -Item at head of the list - -#### Returns - -`undefined` \| `T` - -#### Inherited from - -SortedSet.head - -#### Defined in - -[src/LinkedList.ts:36](https://github.com/zimmed/prefab/blob/a5ffdd1/src/LinkedList.ts#L36) - -___ - -### size - -• `get` **size**(): `number` - -Current size of set - -#### Returns - -`number` - -#### Inherited from - -SortedSet.size - -#### Defined in - -[src/LinkedSet.ts:10](https://github.com/zimmed/prefab/blob/a5ffdd1/src/LinkedSet.ts#L10) - -___ - -### tail - -• `get` **tail**(): `undefined` \| `T` - -Item at tail of the list - -#### Returns - -`undefined` \| `T` - -#### Inherited from - -SortedSet.tail - -#### Defined in - -[src/LinkedList.ts:40](https://github.com/zimmed/prefab/blob/a5ffdd1/src/LinkedList.ts#L40) - -## Methods - -### [iterator] - -▸ **[iterator]**(): `IterableIterator`<`T`\> - -#### Returns - -`IterableIterator`<`T`\> - -#### Inherited from - -[SortedSet](SortedSet.md).[[iterator]](SortedSet.md#[iterator]) - -#### Defined in - -[src/LinkedList.ts:391](https://github.com/zimmed/prefab/blob/a5ffdd1/src/LinkedList.ts#L391) - -___ - -### add - -▸ **add**(`item`): [`PriorityQueue`](PriorityQueue.md)<`T`\> - -Adds item into the Queue with priority=5 - -#### Parameters - -| Name | Type | -| :------ | :------ | -| `item` | `T` | - -#### Returns - -[`PriorityQueue`](PriorityQueue.md)<`T`\> - -#### Overrides - -[SortedSet](SortedSet.md).[add](SortedSet.md#add) - -#### Defined in - -[src/PriorityQueue.ts:43](https://github.com/zimmed/prefab/blob/a5ffdd1/src/PriorityQueue.ts#L43) - -___ - -### addNode - -▸ **addNode**(`node`): [`PriorityQueue`](PriorityQueue.md)<`T`\> - -Caution: Assumes node already has correct head and tail set -Adds node to the end of the list - -#### Parameters - -| Name | Type | -| :------ | :------ | -| `node` | `LNode`<`T`\> | - -#### Returns - -[`PriorityQueue`](PriorityQueue.md)<`T`\> - -#### Inherited from - -[SortedSet](SortedSet.md).[addNode](SortedSet.md#addnode) - -#### Defined in - -[src/LinkedList.ts:367](https://github.com/zimmed/prefab/blob/a5ffdd1/src/LinkedList.ts#L367) - -___ - -### append - -▸ **append**(`item`, `priority?`): [`PriorityQueue`](PriorityQueue.md)<`T`\> - -Appends item onto the Queue with priority=10 - -#### Parameters - -| Name | Type | Default value | -| :------ | :------ | :------ | -| `item` | `T` | `undefined` | -| `priority` | `number` | `10` | - -#### Returns - -[`PriorityQueue`](PriorityQueue.md)<`T`\> - -#### Overrides - -[SortedSet](SortedSet.md).[append](SortedSet.md#append) - -#### Defined in - -[src/PriorityQueue.ts:48](https://github.com/zimmed/prefab/blob/a5ffdd1/src/PriorityQueue.ts#L48) - -___ - -### clear - -▸ **clear**(): `void` - -Clears the set - -#### Returns - -`void` - -#### Inherited from - -[SortedSet](SortedSet.md).[clear](SortedSet.md#clear) - -#### Defined in - -[src/SortedSet.ts:94](https://github.com/zimmed/prefab/blob/a5ffdd1/src/SortedSet.ts#L94) - -___ - -### cycle - -▸ **cycle**(): [`PriorityQueue`](PriorityQueue.md)<`T`\> - -Moves element from end of list to the front - -#### Returns - -[`PriorityQueue`](PriorityQueue.md)<`T`\> - -#### Inherited from - -[SortedSet](SortedSet.md).[cycle](SortedSet.md#cycle) - -#### Defined in - -[src/LinkedList.ts:127](https://github.com/zimmed/prefab/blob/a5ffdd1/src/LinkedList.ts#L127) - -___ - -### delete - -▸ **delete**(`item`): `boolean` - -Deletes specified item from the Queue - -#### Parameters - -| Name | Type | -| :------ | :------ | -| `item` | `T` | - -#### Returns - -`boolean` - -#### Overrides - -[SortedSet](SortedSet.md).[delete](SortedSet.md#delete) - -#### Defined in - -[src/PriorityQueue.ts:77](https://github.com/zimmed/prefab/blob/a5ffdd1/src/PriorityQueue.ts#L77) - -___ - -### deleteNode - -▸ **deleteNode**(`cur?`): `boolean` - -Removes specified node from the list - -#### Parameters - -| Name | Type | -| :------ | :------ | -| `cur?` | `LNode`<`T`\> | - -#### Returns - -`boolean` - -#### Inherited from - -[SortedSet](SortedSet.md).[deleteNode](SortedSet.md#deletenode) - -#### Defined in - -[src/LinkedList.ts:376](https://github.com/zimmed/prefab/blob/a5ffdd1/src/LinkedList.ts#L376) - -___ - -### dequeue - -▸ **dequeue**(): `undefined` \| `T` - -Takes item from the front of the Queue - -#### Returns - -`undefined` \| `T` - -#### Defined in - -[src/PriorityQueue.ts:66](https://github.com/zimmed/prefab/blob/a5ffdd1/src/PriorityQueue.ts#L66) - -___ - -### enqueue - -▸ **enqueue**(`item`, `priority?`, `c?`): [`PriorityQueue`](PriorityQueue.md)<`T`\> - -Appends item onto the Queue at the specified priority - -#### Parameters - -| Name | Type | Default value | -| :------ | :------ | :------ | -| `item` | `T` | `undefined` | -| `priority` | `number` | `5` | -| `c` | `number` | `++this._count` | - -#### Returns - -[`PriorityQueue`](PriorityQueue.md)<`T`\> - -#### Defined in - -[src/PriorityQueue.ts:58](https://github.com/zimmed/prefab/blob/a5ffdd1/src/PriorityQueue.ts#L58) - -___ - -### entries - -▸ **entries**(): `IterableIterator`<[`T`, `T`]\> - -Kind of pointless, but needed for parity with builtin Set object - -#### Returns - -`IterableIterator`<[`T`, `T`]\> - -#### Inherited from - -[SortedSet](SortedSet.md).[entries](SortedSet.md#entries) - -#### Defined in - -[src/LinkedList.ts:196](https://github.com/zimmed/prefab/blob/a5ffdd1/src/LinkedList.ts#L196) - -___ - -### filter - -▸ **filter**(`predicate`): `T`[] - -Uses predicate to return a new array of all matching items (same signature is Array.protoype.filter) - -#### Parameters - -| Name | Type | -| :------ | :------ | -| `predicate` | `Callback`<`T`, [`PriorityQueue`](PriorityQueue.md)<`T`\>, `boolean`, [`PriorityQueue`](PriorityQueue.md)<`T`\>\> | - -#### Returns - -`T`[] - -#### Inherited from - -[SortedSet](SortedSet.md).[filter](SortedSet.md#filter) - -#### Defined in - -[src/LinkedList.ts:295](https://github.com/zimmed/prefab/blob/a5ffdd1/src/LinkedList.ts#L295) - -▸ **filter**<`This`\>(`predicate`, `thisArg`): `T`[] - -#### Type parameters - -| Name | -| :------ | -| `This` | - -#### Parameters - -| Name | Type | -| :------ | :------ | -| `predicate` | `Callback`<`T`, `This`, `boolean`, [`PriorityQueue`](PriorityQueue.md)<`T`\>\> | -| `thisArg` | `This` | - -#### Returns - -`T`[] - -#### Inherited from - -[SortedSet](SortedSet.md).[filter](SortedSet.md#filter) - -#### Defined in - -[src/LinkedList.ts:296](https://github.com/zimmed/prefab/blob/a5ffdd1/src/LinkedList.ts#L296) - -___ - -### find - -▸ **find**(`predicate`): `undefined` \| `T` - -Uses predicate to return first matching item or undefined if no matches (same signature as Array.prototype.find) - -#### Parameters - -| Name | Type | -| :------ | :------ | -| `predicate` | `Callback`<`T`, [`PriorityQueue`](PriorityQueue.md)<`T`\>, `boolean`, [`PriorityQueue`](PriorityQueue.md)<`T`\>\> | - -#### Returns - -`undefined` \| `T` - -#### Inherited from - -[SortedSet](SortedSet.md).[find](SortedSet.md#find) - -#### Defined in - -[src/LinkedList.ts:269](https://github.com/zimmed/prefab/blob/a5ffdd1/src/LinkedList.ts#L269) - -▸ **find**<`This`\>(`predicate`, `thisArg`): `undefined` \| `T` - -#### Type parameters - -| Name | -| :------ | -| `This` | - -#### Parameters - -| Name | Type | -| :------ | :------ | -| `predicate` | `Callback`<`T`, `This`, `boolean`, [`PriorityQueue`](PriorityQueue.md)<`T`\>\> | -| `thisArg` | `This` | - -#### Returns - -`undefined` \| `T` - -#### Inherited from - -[SortedSet](SortedSet.md).[find](SortedSet.md#find) - -#### Defined in - -[src/LinkedList.ts:270](https://github.com/zimmed/prefab/blob/a5ffdd1/src/LinkedList.ts#L270) - -___ - -### findRight - -▸ **findRight**(`predicate`): `undefined` \| `T` - -Finds predicate-matching item, with iteration beginning at the end of the set - -#### Parameters - -| Name | Type | -| :------ | :------ | -| `predicate` | `Callback`<`T`, [`PriorityQueue`](PriorityQueue.md)<`T`\>, `boolean`, [`PriorityQueue`](PriorityQueue.md)<`T`\>\> | - -#### Returns - -`undefined` \| `T` - -#### Inherited from - -[SortedSet](SortedSet.md).[findRight](SortedSet.md#findright) - -#### Defined in - -[src/LinkedSet.ts:92](https://github.com/zimmed/prefab/blob/a5ffdd1/src/LinkedSet.ts#L92) - -▸ **findRight**<`This`\>(`predicate`, `thisArg`): `undefined` \| `T` - -#### Type parameters - -| Name | -| :------ | -| `This` | - -#### Parameters - -| Name | Type | -| :------ | :------ | -| `predicate` | `Callback`<`T`, `This`, `boolean`, [`PriorityQueue`](PriorityQueue.md)<`T`\>\> | -| `thisArg` | `This` | - -#### Returns - -`undefined` \| `T` - -#### Inherited from - -[SortedSet](SortedSet.md).[findRight](SortedSet.md#findright) - -#### Defined in - -[src/LinkedSet.ts:93](https://github.com/zimmed/prefab/blob/a5ffdd1/src/LinkedSet.ts#L93) - -___ - -### forEach - -▸ **forEach**(`cb`): `void` - -Operates on each element of the list in a callback method (same signature as Array.prototype.forEach) - -#### Parameters - -| Name | Type | -| :------ | :------ | -| `cb` | `Callback`<`T`, [`PriorityQueue`](PriorityQueue.md)<`T`\>, `void`, [`PriorityQueue`](PriorityQueue.md)<`T`\>\> | - -#### Returns - -`void` - -#### Inherited from - -[SortedSet](SortedSet.md).[forEach](SortedSet.md#foreach) - -#### Defined in - -[src/LinkedList.ts:227](https://github.com/zimmed/prefab/blob/a5ffdd1/src/LinkedList.ts#L227) - -▸ **forEach**<`ThisArg`\>(`cb`, `thisArg?`): `void` - -#### Type parameters - -| Name | -| :------ | -| `ThisArg` | - -#### Parameters - -| Name | Type | -| :------ | :------ | -| `cb` | `Callback`<`T`, `ThisArg`, `void`, [`PriorityQueue`](PriorityQueue.md)<`T`\>\> | -| `thisArg?` | `ThisArg` | - -#### Returns - -`void` - -#### Inherited from - -[SortedSet](SortedSet.md).[forEach](SortedSet.md#foreach) - -#### Defined in - -[src/LinkedList.ts:228](https://github.com/zimmed/prefab/blob/a5ffdd1/src/LinkedList.ts#L228) - -___ - -### has - -▸ **has**(`item`): `boolean` - -Determines if set contains specified item - -#### Parameters - -| Name | Type | -| :------ | :------ | -| `item` | `T` | - -#### Returns - -`boolean` - -#### Inherited from - -[SortedSet](SortedSet.md).[has](SortedSet.md#has) - -#### Defined in - -[src/LinkedSet.ts:36](https://github.com/zimmed/prefab/blob/a5ffdd1/src/LinkedSet.ts#L36) - -___ - -### headNode - -▸ **headNode**(`node`): [`PriorityQueue`](PriorityQueue.md)<`T`\> - -Caution: Assumes node is already part of linked list -Moves node to the front of the list - -#### Parameters - -| Name | Type | -| :------ | :------ | -| `node` | `LNode`<`T`\> | - -#### Returns - -[`PriorityQueue`](PriorityQueue.md)<`T`\> - -#### Inherited from - -[SortedSet](SortedSet.md).[headNode](SortedSet.md#headnode) - -#### Defined in - -[src/LinkedList.ts:140](https://github.com/zimmed/prefab/blob/a5ffdd1/src/LinkedList.ts#L140) - -___ - -### insert - -▸ **insert**(`item`, `priority?`, `c?`): [`PriorityQueue`](PriorityQueue.md)<`T`\> - -Inserts item into the front of the specified priority order - -#### Parameters - -| Name | Type | Default value | -| :------ | :------ | :------ | -| `item` | `T` | `undefined` | -| `priority` | `number` | `-1` | -| `c` | `number` | `--this._rCount` | - -#### Returns - -[`PriorityQueue`](PriorityQueue.md)<`T`\> - -#### Overrides - -[SortedSet](SortedSet.md).[insert](SortedSet.md#insert) - -#### Defined in - -[src/PriorityQueue.ts:53](https://github.com/zimmed/prefab/blob/a5ffdd1/src/PriorityQueue.ts#L53) - -___ - -### insertNode - -▸ **insertNode**(`node`): [`PriorityQueue`](PriorityQueue.md)<`T`\> - -Caution: Assumes node already has correct head and tail set -Adds node to the front of the list - -#### Parameters - -| Name | Type | -| :------ | :------ | -| `node` | `LNode`<`T`\> | - -#### Returns - -[`PriorityQueue`](PriorityQueue.md)<`T`\> - -#### Inherited from - -[SortedSet](SortedSet.md).[insertNode](SortedSet.md#insertnode) - -#### Defined in - -[src/LinkedList.ts:355](https://github.com/zimmed/prefab/blob/a5ffdd1/src/LinkedList.ts#L355) - -___ - -### join - -▸ **join**(`separator?`): `string` - -Joins list elements into one string (same signature as Array.prototype.join) - -#### Parameters - -| Name | Type | -| :------ | :------ | -| `separator?` | `string` | - -#### Returns - -`string` - -#### Inherited from - -[SortedSet](SortedSet.md).[join](SortedSet.md#join) - -#### Defined in - -[src/LinkedList.ts:347](https://github.com/zimmed/prefab/blob/a5ffdd1/src/LinkedList.ts#L347) - -___ - -### keys - -▸ **keys**(): `IterableIterator`<`T`\> - -Alias for values() method - -#### Returns - -`IterableIterator`<`T`\> - -#### Inherited from - -[SortedSet](SortedSet.md).[keys](SortedSet.md#keys) - -#### Defined in - -[src/LinkedList.ts:191](https://github.com/zimmed/prefab/blob/a5ffdd1/src/LinkedList.ts#L191) - -___ - -### map - -▸ **map**<`RT`\>(`cb`): `RT`[] - -Maps set items into a new array - -#### Type parameters - -| Name | -| :------ | -| `RT` | - -#### Parameters - -| Name | Type | -| :------ | :------ | -| `cb` | `Callback`<`T`, [`PriorityQueue`](PriorityQueue.md)<`T`\>, `RT`, [`PriorityQueue`](PriorityQueue.md)<`T`\>\> | - -#### Returns - -`RT`[] - -#### Inherited from - -[SortedSet](SortedSet.md).[map](SortedSet.md#map) - -#### Defined in - -[src/LinkedSet.ts:103](https://github.com/zimmed/prefab/blob/a5ffdd1/src/LinkedSet.ts#L103) - -▸ **map**<`RT`, `This`\>(`cb`, `thisArg`): `RT`[] - -#### Type parameters - -| Name | -| :------ | -| `RT` | -| `This` | - -#### Parameters - -| Name | Type | -| :------ | :------ | -| `cb` | `Callback`<`T`, `This`, `RT`, [`PriorityQueue`](PriorityQueue.md)<`T`\>\> | -| `thisArg` | `This` | - -#### Returns - -`RT`[] - -#### Inherited from - -[SortedSet](SortedSet.md).[map](SortedSet.md#map) - -#### Defined in - -[src/LinkedSet.ts:104](https://github.com/zimmed/prefab/blob/a5ffdd1/src/LinkedSet.ts#L104) - -___ - -### pop - -▸ **pop**(): `undefined` \| `T` - -Pops item from end of the set - -#### Returns - -`undefined` \| `T` - -#### Inherited from - -[SortedSet](SortedSet.md).[pop](SortedSet.md#pop) - -#### Defined in - -[src/SortedSet.ts:72](https://github.com/zimmed/prefab/blob/a5ffdd1/src/SortedSet.ts#L72) - -___ - -### recycle - -▸ **recycle**(): [`PriorityQueue`](PriorityQueue.md)<`T`\> - -Moves element from front of list to the end - -#### Returns - -[`PriorityQueue`](PriorityQueue.md)<`T`\> - -#### Inherited from - -[SortedSet](SortedSet.md).[recycle](SortedSet.md#recycle) - -#### Defined in - -[src/LinkedList.ts:132](https://github.com/zimmed/prefab/blob/a5ffdd1/src/LinkedList.ts#L132) - -___ - -### reduce - -▸ **reduce**<`RT`\>(`cb`, `initialValue`): `RT` - -Reduces list into specified value (same signature as Array.prototype.reduce) - -#### Type parameters - -| Name | -| :------ | -| `RT` | - -#### Parameters - -| Name | Type | -| :------ | :------ | -| `cb` | `Reducer`<`T`, [`PriorityQueue`](PriorityQueue.md)<`T`\>, `RT`, [`PriorityQueue`](PriorityQueue.md)<`T`\>\> | -| `initialValue` | `RT` | - -#### Returns - -`RT` - -#### Inherited from - -[SortedSet](SortedSet.md).[reduce](SortedSet.md#reduce) - -#### Defined in - -[src/LinkedList.ts:248](https://github.com/zimmed/prefab/blob/a5ffdd1/src/LinkedList.ts#L248) - -▸ **reduce**<`RT`, `This`\>(`cb`, `initialValue`, `thisArg?`): `RT` - -#### Type parameters - -| Name | -| :------ | -| `RT` | -| `This` | - -#### Parameters - -| Name | Type | -| :------ | :------ | -| `cb` | `Reducer`<`T`, `This`, `RT`, [`PriorityQueue`](PriorityQueue.md)<`T`\>\> | -| `initialValue` | `RT` | -| `thisArg?` | `This` | - -#### Returns - -`RT` - -#### Inherited from - -[SortedSet](SortedSet.md).[reduce](SortedSet.md#reduce) - -#### Defined in - -[src/LinkedList.ts:249](https://github.com/zimmed/prefab/blob/a5ffdd1/src/LinkedList.ts#L249) - -___ - -### reduceRight - -▸ **reduceRight**<`RT`\>(`cb`, `initialValue`): `RT` - -Reduces items from the end of the set to the front - -#### Type parameters - -| Name | -| :------ | -| `RT` | - -#### Parameters - -| Name | Type | -| :------ | :------ | -| `cb` | `Reducer`<`T`, [`PriorityQueue`](PriorityQueue.md)<`T`\>, `RT`, [`PriorityQueue`](PriorityQueue.md)<`T`\>\> | -| `initialValue` | `RT` | - -#### Returns - -`RT` - -#### Inherited from - -[SortedSet](SortedSet.md).[reduceRight](SortedSet.md#reduceright) - -#### Defined in - -[src/LinkedSet.ts:76](https://github.com/zimmed/prefab/blob/a5ffdd1/src/LinkedSet.ts#L76) - -▸ **reduceRight**<`RT`, `This`\>(`cb`, `initialValue`, `thisArg?`): `RT` - -#### Type parameters - -| Name | -| :------ | -| `RT` | -| `This` | - -#### Parameters - -| Name | Type | -| :------ | :------ | -| `cb` | `Reducer`<`T`, `This`, `RT`, [`PriorityQueue`](PriorityQueue.md)<`T`\>\> | -| `initialValue` | `RT` | -| `thisArg?` | `This` | - -#### Returns - -`RT` - -#### Inherited from - -[SortedSet](SortedSet.md).[reduceRight](SortedSet.md#reduceright) - -#### Defined in - -[src/LinkedSet.ts:77](https://github.com/zimmed/prefab/blob/a5ffdd1/src/LinkedSet.ts#L77) - -___ - -### reverse - -▸ **reverse**(): `IterableIterator`<`T`\> - -Iterates through list items in reverse - -#### Returns - -`IterableIterator`<`T`\> - -#### Inherited from - -[SortedSet](SortedSet.md).[reverse](SortedSet.md#reverse) - -#### Defined in - -[src/LinkedList.ts:217](https://github.com/zimmed/prefab/blob/a5ffdd1/src/LinkedList.ts#L217) - -___ - -### reverseMap - -▸ **reverseMap**<`RT`\>(`cb`): `RT`[] - -Maps set items from the end of the set to the front into a new array - -#### Type parameters - -| Name | -| :------ | -| `RT` | - -#### Parameters - -| Name | Type | -| :------ | :------ | -| `cb` | `Callback`<`T`, [`PriorityQueue`](PriorityQueue.md)<`T`\>, `RT`, [`PriorityQueue`](PriorityQueue.md)<`T`\>\> | - -#### Returns - -`RT`[] - -#### Inherited from - -[SortedSet](SortedSet.md).[reverseMap](SortedSet.md#reversemap) - -#### Defined in - -[src/LinkedSet.ts:111](https://github.com/zimmed/prefab/blob/a5ffdd1/src/LinkedSet.ts#L111) - -▸ **reverseMap**<`RT`, `This`\>(`cb`, `thisArg`): `RT`[] - -#### Type parameters - -| Name | -| :------ | -| `RT` | -| `This` | - -#### Parameters - -| Name | Type | -| :------ | :------ | -| `cb` | `Callback`<`T`, `This`, `RT`, [`PriorityQueue`](PriorityQueue.md)<`T`\>\> | -| `thisArg` | `This` | - -#### Returns - -`RT`[] - -#### Inherited from - -[SortedSet](SortedSet.md).[reverseMap](SortedSet.md#reversemap) - -#### Defined in - -[src/LinkedSet.ts:112](https://github.com/zimmed/prefab/blob/a5ffdd1/src/LinkedSet.ts#L112) - -___ - -### search - -▸ **search**(`compareFunction`, `node?`): `undefined` \| `T` - -Searches set using compare function to find first match - -#### Parameters - -| Name | Type | Description | -| :------ | :------ | :------ | -| `compareFunction` | (`a`: `T`) => `number` | Takes an item from the set and returns 0 if a match, -1 (<0) if the desired match is lower in the sort order (closer to the front of the list), or 1 (>0) if the desired match is higher (towards the end of the list) | -| `node` | `undefined` \| `TNode`<`T`\> | - | - -#### Returns - -`undefined` \| `T` - -#### Inherited from - -[SortedSet](SortedSet.md).[search](SortedSet.md#search) - -#### Defined in - -[src/SortedSet.ts:52](https://github.com/zimmed/prefab/blob/a5ffdd1/src/SortedSet.ts#L52) - -___ - -### shift - -▸ **shift**(): `undefined` \| `T` - -Shifts item from the front of the set - -#### Returns - -`undefined` \| `T` - -#### Inherited from - -[SortedSet](SortedSet.md).[shift](SortedSet.md#shift) - -#### Defined in - -[src/SortedSet.ts:83](https://github.com/zimmed/prefab/blob/a5ffdd1/src/SortedSet.ts#L83) - -___ - -### tailNode - -▸ **tailNode**(`node`): [`PriorityQueue`](PriorityQueue.md)<`T`\> - -Caution: Assumes node is already part of linked list -Moves node to the end of the list - -#### Parameters - -| Name | Type | -| :------ | :------ | -| `node` | `LNode`<`T`\> | - -#### Returns - -[`PriorityQueue`](PriorityQueue.md)<`T`\> - -#### Inherited from - -[SortedSet](SortedSet.md).[tailNode](SortedSet.md#tailnode) - -#### Defined in - -[src/LinkedList.ts:155](https://github.com/zimmed/prefab/blob/a5ffdd1/src/LinkedList.ts#L155) - -___ - -### toArray - -▸ **toArray**(): `T`[] - -Converts list to native Array - -#### Returns - -`T`[] - -#### Inherited from - -[SortedSet](SortedSet.md).[toArray](SortedSet.md#toarray) - -#### Defined in - -[src/LinkedList.ts:179](https://github.com/zimmed/prefab/blob/a5ffdd1/src/LinkedList.ts#L179) - -___ - -### toJSON - -▸ **toJSON**(): `T`[] - -#### Returns - -`T`[] - -#### Inherited from - -[SortedSet](SortedSet.md).[toJSON](SortedSet.md#tojson) - -#### Defined in - -[src/LinkedList.ts:387](https://github.com/zimmed/prefab/blob/a5ffdd1/src/LinkedList.ts#L387) - -___ - -### unshift - -▸ **unshift**(`item`): [`PriorityQueue`](PriorityQueue.md)<`T`\> - -Alias for insert - -#### Parameters - -| Name | Type | -| :------ | :------ | -| `item` | `T` | - -#### Returns - -[`PriorityQueue`](PriorityQueue.md)<`T`\> - -#### Inherited from - -[SortedSet](SortedSet.md).[unshift](SortedSet.md#unshift) - -#### Defined in - -[src/LinkedList.ts:117](https://github.com/zimmed/prefab/blob/a5ffdd1/src/LinkedList.ts#L117) - -___ - -### values - -▸ **values**(): `IterableIterator`<`T`\> - -Iterates through list items - -#### Returns - -`IterableIterator`<`T`\> - -#### Inherited from - -[SortedSet](SortedSet.md).[values](SortedSet.md#values) - -#### Defined in - -[src/LinkedList.ts:207](https://github.com/zimmed/prefab/blob/a5ffdd1/src/LinkedList.ts#L207) - -___ - -### create - -▸ `Static` **create**<`T`\>(`iterable?`): [`PriorityQueue`](PriorityQueue.md)<`T`\> - -Static factory method as alias for class constructor - -#### Type parameters - -| Name | -| :------ | -| `T` | - -#### Parameters - -| Name | Type | -| :------ | :------ | -| `iterable?` | `IterableIterator`<`T`\> \| `T`[] \| `Generator`<`T`, `void`, `unknown`\> | - -#### Returns - -[`PriorityQueue`](PriorityQueue.md)<`T`\> - -#### Overrides - -[SortedSet](SortedSet.md).[create](SortedSet.md#create) - -#### Defined in - -[src/PriorityQueue.ts:17](https://github.com/zimmed/prefab/blob/a5ffdd1/src/PriorityQueue.ts#L17) - -___ - -### from - -▸ `Static` **from**<`T`\>(`iterable`): [`PriorityQueue`](PriorityQueue.md)<`T`\> - -Same as LinkedList.create() but requires constructor arg - -#### Type parameters - -| Name | -| :------ | -| `T` | - -#### Parameters - -| Name | Type | -| :------ | :------ | -| `iterable` | `IterableIterator`<`T`\> \| `T`[] \| `Generator`<`T`, `void`, `unknown`\> | - -#### Returns - -[`PriorityQueue`](PriorityQueue.md)<`T`\> - -#### Overrides - -[SortedSet](SortedSet.md).[from](SortedSet.md#from) - -#### Defined in - -[src/PriorityQueue.ts:22](https://github.com/zimmed/prefab/blob/a5ffdd1/src/PriorityQueue.ts#L22) diff --git a/docs/classes/Queue.md b/docs/classes/Queue.md deleted file mode 100644 index 0b4c883..0000000 --- a/docs/classes/Queue.md +++ /dev/null @@ -1,1334 +0,0 @@ -[@zimmed/prefab](../README.md) / [Exports](../modules.md) / Queue - -# Class: Queue - -## Type parameters - -| Name | -| :------ | -| `T` | - -## Hierarchy - -- [`SizedLinkedList`](SizedLinkedList.md)<`T`\> - - ↳ **`Queue`** - -## Table of contents - -### Constructors - -- [constructor](Queue.md#constructor) - -### Properties - -- [\_head](Queue.md#_head) -- [\_size](Queue.md#_size) -- [\_tail](Queue.md#_tail) -- [\_type](Queue.md#_type) -- [Type](Queue.md#type) - -### Accessors - -- [head](Queue.md#head) -- [size](Queue.md#size) -- [tail](Queue.md#tail) - -### Methods - -- [[iterator]](Queue.md#[iterator]) -- [add](Queue.md#add) -- [addNode](Queue.md#addnode) -- [append](Queue.md#append) -- [clear](Queue.md#clear) -- [cycle](Queue.md#cycle) -- [delete](Queue.md#delete) -- [deleteNode](Queue.md#deletenode) -- [dequeue](Queue.md#dequeue) -- [enqueue](Queue.md#enqueue) -- [entries](Queue.md#entries) -- [filter](Queue.md#filter) -- [find](Queue.md#find) -- [findRight](Queue.md#findright) -- [forEach](Queue.md#foreach) -- [has](Queue.md#has) -- [headNode](Queue.md#headnode) -- [insert](Queue.md#insert) -- [insertNode](Queue.md#insertnode) -- [join](Queue.md#join) -- [keys](Queue.md#keys) -- [map](Queue.md#map) -- [pop](Queue.md#pop) -- [recycle](Queue.md#recycle) -- [reduce](Queue.md#reduce) -- [reduceRight](Queue.md#reduceright) -- [reverse](Queue.md#reverse) -- [reverseMap](Queue.md#reversemap) -- [shift](Queue.md#shift) -- [tailNode](Queue.md#tailnode) -- [toArray](Queue.md#toarray) -- [toJSON](Queue.md#tojson) -- [unshift](Queue.md#unshift) -- [values](Queue.md#values) -- [create](Queue.md#create) -- [from](Queue.md#from) - -## Constructors - -### constructor - -• **new Queue**<`T`\>(`iterable?`, `type?`) - -#### Type parameters - -| Name | -| :------ | -| `T` | - -#### Parameters - -| Name | Type | Default value | -| :------ | :------ | :------ | -| `iterable?` | `IterableIterator`<`T`\> \| `T`[] \| `Generator`<`T`, `void`, `unknown`\> | `undefined` | -| `type` | `Type` | `Type.FIFO` | - -#### Overrides - -[SizedLinkedList](SizedLinkedList.md).[constructor](SizedLinkedList.md#constructor) - -#### Defined in - -[src/Queue.ts:31](https://github.com/zimmed/prefab/blob/a5ffdd1/src/Queue.ts#L31) - -## Properties - -### \_head - -• `Protected` `Optional` **\_head**: `LNode`<`T`\> - -#### Inherited from - -[SizedLinkedList](SizedLinkedList.md).[_head](SizedLinkedList.md#_head) - -#### Defined in - -[src/LinkedList.ts:30](https://github.com/zimmed/prefab/blob/a5ffdd1/src/LinkedList.ts#L30) - -___ - -### \_size - -• `Protected` **\_size**: `number` - -#### Inherited from - -[SizedLinkedList](SizedLinkedList.md).[_size](SizedLinkedList.md#_size) - -#### Defined in - -[src/SizedLinkedList.ts:6](https://github.com/zimmed/prefab/blob/a5ffdd1/src/SizedLinkedList.ts#L6) - -___ - -### \_tail - -• `Protected` `Optional` **\_tail**: `LNode`<`T`\> - -#### Inherited from - -[SizedLinkedList](SizedLinkedList.md).[_tail](SizedLinkedList.md#_tail) - -#### Defined in - -[src/LinkedList.ts:33](https://github.com/zimmed/prefab/blob/a5ffdd1/src/LinkedList.ts#L33) - -___ - -### \_type - -• `Protected` `Readonly` **\_type**: `Type` - -#### Defined in - -[src/Queue.ts:29](https://github.com/zimmed/prefab/blob/a5ffdd1/src/Queue.ts#L29) - -___ - -### Type - -▪ `Static` **Type**: typeof `Type` = `Type` - -#### Defined in - -[src/Queue.ts:10](https://github.com/zimmed/prefab/blob/a5ffdd1/src/Queue.ts#L10) - -## Accessors - -### head - -• `get` **head**(): `undefined` \| `T` - -Item at head of the list - -#### Returns - -`undefined` \| `T` - -#### Inherited from - -SizedLinkedList.head - -#### Defined in - -[src/LinkedList.ts:36](https://github.com/zimmed/prefab/blob/a5ffdd1/src/LinkedList.ts#L36) - -___ - -### size - -• `get` **size**(): `number` - -Current size of list - -#### Returns - -`number` - -#### Inherited from - -SizedLinkedList.size - -#### Defined in - -[src/SizedLinkedList.ts:9](https://github.com/zimmed/prefab/blob/a5ffdd1/src/SizedLinkedList.ts#L9) - -___ - -### tail - -• `get` **tail**(): `undefined` \| `T` - -Item at tail of the list - -#### Returns - -`undefined` \| `T` - -#### Inherited from - -SizedLinkedList.tail - -#### Defined in - -[src/LinkedList.ts:40](https://github.com/zimmed/prefab/blob/a5ffdd1/src/LinkedList.ts#L40) - -## Methods - -### [iterator] - -▸ **[iterator]**(): `IterableIterator`<`T`\> - -#### Returns - -`IterableIterator`<`T`\> - -#### Inherited from - -[SizedLinkedList](SizedLinkedList.md).[[iterator]](SizedLinkedList.md#[iterator]) - -#### Defined in - -[src/LinkedList.ts:391](https://github.com/zimmed/prefab/blob/a5ffdd1/src/LinkedList.ts#L391) - -___ - -### add - -▸ **add**(`item`): [`Queue`](Queue.md)<`T`\> - -Adds item to end of the list - -#### Parameters - -| Name | Type | -| :------ | :------ | -| `item` | `T` | - -#### Returns - -[`Queue`](Queue.md)<`T`\> - -#### Inherited from - -[SizedLinkedList](SizedLinkedList.md).[add](SizedLinkedList.md#add) - -#### Defined in - -[src/LinkedList.ts:122](https://github.com/zimmed/prefab/blob/a5ffdd1/src/LinkedList.ts#L122) - -___ - -### addNode - -▸ **addNode**(`node`): [`Queue`](Queue.md)<`T`\> - -Appends Node onto the end of the list - -#### Parameters - -| Name | Type | -| :------ | :------ | -| `node` | `LNode`<`T`\> | - -#### Returns - -[`Queue`](Queue.md)<`T`\> - -#### Inherited from - -[SizedLinkedList](SizedLinkedList.md).[addNode](SizedLinkedList.md#addnode) - -#### Defined in - -[src/SizedLinkedList.ts:42](https://github.com/zimmed/prefab/blob/a5ffdd1/src/SizedLinkedList.ts#L42) - -___ - -### append - -▸ **append**(`item`): [`Queue`](Queue.md)<`T`\> - -Adds item to end of the list - -#### Parameters - -| Name | Type | -| :------ | :------ | -| `item` | `T` | - -#### Returns - -[`Queue`](Queue.md)<`T`\> - -#### Inherited from - -[SizedLinkedList](SizedLinkedList.md).[append](SizedLinkedList.md#append) - -#### Defined in - -[src/LinkedList.ts:107](https://github.com/zimmed/prefab/blob/a5ffdd1/src/LinkedList.ts#L107) - -___ - -### clear - -▸ **clear**(): `void` - -Clears the list - -#### Returns - -`void` - -#### Inherited from - -[SizedLinkedList](SizedLinkedList.md).[clear](SizedLinkedList.md#clear) - -#### Defined in - -[src/SizedLinkedList.ts:48](https://github.com/zimmed/prefab/blob/a5ffdd1/src/SizedLinkedList.ts#L48) - -___ - -### cycle - -▸ **cycle**(): [`Queue`](Queue.md)<`T`\> - -Moves element from end of list to the front - -#### Returns - -[`Queue`](Queue.md)<`T`\> - -#### Inherited from - -[SizedLinkedList](SizedLinkedList.md).[cycle](SizedLinkedList.md#cycle) - -#### Defined in - -[src/LinkedList.ts:127](https://github.com/zimmed/prefab/blob/a5ffdd1/src/LinkedList.ts#L127) - -___ - -### delete - -▸ **delete**(`item`): `boolean` - -Removes item from the list - -#### Parameters - -| Name | Type | -| :------ | :------ | -| `item` | `T` | - -#### Returns - -`boolean` - -#### Inherited from - -[SizedLinkedList](SizedLinkedList.md).[delete](SizedLinkedList.md#delete) - -#### Defined in - -[src/LinkedList.ts:174](https://github.com/zimmed/prefab/blob/a5ffdd1/src/LinkedList.ts#L174) - -___ - -### deleteNode - -▸ **deleteNode**(`cur?`): `boolean` - -Deletes specified node from the list - -#### Parameters - -| Name | Type | -| :------ | :------ | -| `cur?` | `LNode`<`T`\> | - -#### Returns - -`boolean` - -#### Inherited from - -[SizedLinkedList](SizedLinkedList.md).[deleteNode](SizedLinkedList.md#deletenode) - -#### Defined in - -[src/SizedLinkedList.ts:54](https://github.com/zimmed/prefab/blob/a5ffdd1/src/SizedLinkedList.ts#L54) - -___ - -### dequeue - -▸ **dequeue**(): `undefined` \| `T` - -Shift item from front of front of Queue if type is FIFO, otherwise pop from end of Queue (LIFO) - -#### Returns - -`undefined` \| `T` - -#### Defined in - -[src/Queue.ts:45](https://github.com/zimmed/prefab/blob/a5ffdd1/src/Queue.ts#L45) - -___ - -### enqueue - -▸ **enqueue**(`item`): `void` - -Append item to Queue - -#### Parameters - -| Name | Type | -| :------ | :------ | -| `item` | `T` | - -#### Returns - -`void` - -#### Defined in - -[src/Queue.ts:40](https://github.com/zimmed/prefab/blob/a5ffdd1/src/Queue.ts#L40) - -___ - -### entries - -▸ **entries**(): `IterableIterator`<[`T`, `T`]\> - -Kind of pointless, but needed for parity with builtin Set object - -#### Returns - -`IterableIterator`<[`T`, `T`]\> - -#### Inherited from - -[SizedLinkedList](SizedLinkedList.md).[entries](SizedLinkedList.md#entries) - -#### Defined in - -[src/LinkedList.ts:196](https://github.com/zimmed/prefab/blob/a5ffdd1/src/LinkedList.ts#L196) - -___ - -### filter - -▸ **filter**(`predicate`): `T`[] - -Uses predicate to return a new array of all matching items (same signature is Array.protoype.filter) - -#### Parameters - -| Name | Type | -| :------ | :------ | -| `predicate` | `Callback`<`T`, [`Queue`](Queue.md)<`T`\>, `boolean`, [`Queue`](Queue.md)<`T`\>\> | - -#### Returns - -`T`[] - -#### Inherited from - -[SizedLinkedList](SizedLinkedList.md).[filter](SizedLinkedList.md#filter) - -#### Defined in - -[src/LinkedList.ts:295](https://github.com/zimmed/prefab/blob/a5ffdd1/src/LinkedList.ts#L295) - -▸ **filter**<`This`\>(`predicate`, `thisArg`): `T`[] - -#### Type parameters - -| Name | -| :------ | -| `This` | - -#### Parameters - -| Name | Type | -| :------ | :------ | -| `predicate` | `Callback`<`T`, `This`, `boolean`, [`Queue`](Queue.md)<`T`\>\> | -| `thisArg` | `This` | - -#### Returns - -`T`[] - -#### Inherited from - -[SizedLinkedList](SizedLinkedList.md).[filter](SizedLinkedList.md#filter) - -#### Defined in - -[src/LinkedList.ts:296](https://github.com/zimmed/prefab/blob/a5ffdd1/src/LinkedList.ts#L296) - -___ - -### find - -▸ **find**(`predicate`): `undefined` \| `T` - -Uses predicate to return first matching item or undefined if no matches (same signature as Array.prototype.find) - -#### Parameters - -| Name | Type | -| :------ | :------ | -| `predicate` | `Callback`<`T`, [`Queue`](Queue.md)<`T`\>, `boolean`, [`Queue`](Queue.md)<`T`\>\> | - -#### Returns - -`undefined` \| `T` - -#### Inherited from - -[SizedLinkedList](SizedLinkedList.md).[find](SizedLinkedList.md#find) - -#### Defined in - -[src/LinkedList.ts:269](https://github.com/zimmed/prefab/blob/a5ffdd1/src/LinkedList.ts#L269) - -▸ **find**<`This`\>(`predicate`, `thisArg`): `undefined` \| `T` - -#### Type parameters - -| Name | -| :------ | -| `This` | - -#### Parameters - -| Name | Type | -| :------ | :------ | -| `predicate` | `Callback`<`T`, `This`, `boolean`, [`Queue`](Queue.md)<`T`\>\> | -| `thisArg` | `This` | - -#### Returns - -`undefined` \| `T` - -#### Inherited from - -[SizedLinkedList](SizedLinkedList.md).[find](SizedLinkedList.md#find) - -#### Defined in - -[src/LinkedList.ts:270](https://github.com/zimmed/prefab/blob/a5ffdd1/src/LinkedList.ts#L270) - -___ - -### findRight - -▸ **findRight**(`predicate`): `undefined` \| `T` - -Finds predicate-matching item, with iteration beginning at the end of the list - -#### Parameters - -| Name | Type | -| :------ | :------ | -| `predicate` | `Callback`<`T`, [`Queue`](Queue.md)<`T`\>, `boolean`, [`Queue`](Queue.md)<`T`\>\> | - -#### Returns - -`undefined` \| `T` - -#### Inherited from - -[SizedLinkedList](SizedLinkedList.md).[findRight](SizedLinkedList.md#findright) - -#### Defined in - -[src/SizedLinkedList.ts:84](https://github.com/zimmed/prefab/blob/a5ffdd1/src/SizedLinkedList.ts#L84) - -▸ **findRight**<`This`\>(`predicate`, `thisArg`): `undefined` \| `T` - -#### Type parameters - -| Name | -| :------ | -| `This` | - -#### Parameters - -| Name | Type | -| :------ | :------ | -| `predicate` | `Callback`<`T`, `This`, `boolean`, [`Queue`](Queue.md)<`T`\>\> | -| `thisArg` | `This` | - -#### Returns - -`undefined` \| `T` - -#### Inherited from - -[SizedLinkedList](SizedLinkedList.md).[findRight](SizedLinkedList.md#findright) - -#### Defined in - -[src/SizedLinkedList.ts:85](https://github.com/zimmed/prefab/blob/a5ffdd1/src/SizedLinkedList.ts#L85) - -___ - -### forEach - -▸ **forEach**(`cb`): `void` - -Operates on each element of the list in a callback method (same signature as Array.prototype.forEach) - -#### Parameters - -| Name | Type | -| :------ | :------ | -| `cb` | `Callback`<`T`, [`Queue`](Queue.md)<`T`\>, `void`, [`Queue`](Queue.md)<`T`\>\> | - -#### Returns - -`void` - -#### Inherited from - -[SizedLinkedList](SizedLinkedList.md).[forEach](SizedLinkedList.md#foreach) - -#### Defined in - -[src/LinkedList.ts:227](https://github.com/zimmed/prefab/blob/a5ffdd1/src/LinkedList.ts#L227) - -▸ **forEach**<`ThisArg`\>(`cb`, `thisArg?`): `void` - -#### Type parameters - -| Name | -| :------ | -| `ThisArg` | - -#### Parameters - -| Name | Type | -| :------ | :------ | -| `cb` | `Callback`<`T`, `ThisArg`, `void`, [`Queue`](Queue.md)<`T`\>\> | -| `thisArg?` | `ThisArg` | - -#### Returns - -`void` - -#### Inherited from - -[SizedLinkedList](SizedLinkedList.md).[forEach](SizedLinkedList.md#foreach) - -#### Defined in - -[src/LinkedList.ts:228](https://github.com/zimmed/prefab/blob/a5ffdd1/src/LinkedList.ts#L228) - -___ - -### has - -▸ **has**(`item`): `boolean` - -Careful! O(n) -Checks to see if item exists in list - -#### Parameters - -| Name | Type | -| :------ | :------ | -| `item` | `T` | - -#### Returns - -`boolean` - -#### Inherited from - -[SizedLinkedList](SizedLinkedList.md).[has](SizedLinkedList.md#has) - -#### Defined in - -[src/LinkedList.ts:102](https://github.com/zimmed/prefab/blob/a5ffdd1/src/LinkedList.ts#L102) - -___ - -### headNode - -▸ **headNode**(`node`): [`Queue`](Queue.md)<`T`\> - -Caution: Assumes node is already part of linked list -Moves node to the front of the list - -#### Parameters - -| Name | Type | -| :------ | :------ | -| `node` | `LNode`<`T`\> | - -#### Returns - -[`Queue`](Queue.md)<`T`\> - -#### Inherited from - -[SizedLinkedList](SizedLinkedList.md).[headNode](SizedLinkedList.md#headnode) - -#### Defined in - -[src/LinkedList.ts:140](https://github.com/zimmed/prefab/blob/a5ffdd1/src/LinkedList.ts#L140) - -___ - -### insert - -▸ **insert**(`item`): [`Queue`](Queue.md)<`T`\> - -Adds item to front of the list - -#### Parameters - -| Name | Type | -| :------ | :------ | -| `item` | `T` | - -#### Returns - -[`Queue`](Queue.md)<`T`\> - -#### Inherited from - -[SizedLinkedList](SizedLinkedList.md).[insert](SizedLinkedList.md#insert) - -#### Defined in - -[src/LinkedList.ts:112](https://github.com/zimmed/prefab/blob/a5ffdd1/src/LinkedList.ts#L112) - -___ - -### insertNode - -▸ **insertNode**(`node`): [`Queue`](Queue.md)<`T`\> - -Inserts Node into the front the list - -#### Parameters - -| Name | Type | -| :------ | :------ | -| `node` | `LNode`<`T`\> | - -#### Returns - -[`Queue`](Queue.md)<`T`\> - -#### Inherited from - -[SizedLinkedList](SizedLinkedList.md).[insertNode](SizedLinkedList.md#insertnode) - -#### Defined in - -[src/SizedLinkedList.ts:36](https://github.com/zimmed/prefab/blob/a5ffdd1/src/SizedLinkedList.ts#L36) - -___ - -### join - -▸ **join**(`separator?`): `string` - -Joins list elements into one string (same signature as Array.prototype.join) - -#### Parameters - -| Name | Type | -| :------ | :------ | -| `separator?` | `string` | - -#### Returns - -`string` - -#### Inherited from - -[SizedLinkedList](SizedLinkedList.md).[join](SizedLinkedList.md#join) - -#### Defined in - -[src/LinkedList.ts:347](https://github.com/zimmed/prefab/blob/a5ffdd1/src/LinkedList.ts#L347) - -___ - -### keys - -▸ **keys**(): `IterableIterator`<`T`\> - -Alias for values() method - -#### Returns - -`IterableIterator`<`T`\> - -#### Inherited from - -[SizedLinkedList](SizedLinkedList.md).[keys](SizedLinkedList.md#keys) - -#### Defined in - -[src/LinkedList.ts:191](https://github.com/zimmed/prefab/blob/a5ffdd1/src/LinkedList.ts#L191) - -___ - -### map - -▸ **map**<`RT`\>(`cb`): `RT`[] - -Maps list items into a new array - -#### Type parameters - -| Name | -| :------ | -| `RT` | - -#### Parameters - -| Name | Type | -| :------ | :------ | -| `cb` | `Callback`<`T`, [`Queue`](Queue.md)<`T`\>, `RT`, [`Queue`](Queue.md)<`T`\>\> | - -#### Returns - -`RT`[] - -#### Inherited from - -[SizedLinkedList](SizedLinkedList.md).[map](SizedLinkedList.md#map) - -#### Defined in - -[src/SizedLinkedList.ts:110](https://github.com/zimmed/prefab/blob/a5ffdd1/src/SizedLinkedList.ts#L110) - -▸ **map**<`RT`, `This`\>(`cb`, `thisArg`): `RT`[] - -#### Type parameters - -| Name | -| :------ | -| `RT` | -| `This` | - -#### Parameters - -| Name | Type | -| :------ | :------ | -| `cb` | `Callback`<`T`, `This`, `RT`, [`Queue`](Queue.md)<`T`\>\> | -| `thisArg` | `This` | - -#### Returns - -`RT`[] - -#### Inherited from - -[SizedLinkedList](SizedLinkedList.md).[map](SizedLinkedList.md#map) - -#### Defined in - -[src/SizedLinkedList.ts:111](https://github.com/zimmed/prefab/blob/a5ffdd1/src/SizedLinkedList.ts#L111) - -___ - -### pop - -▸ **pop**(): `undefined` \| `T` - -Pops item from end of the list - -#### Returns - -`undefined` \| `T` - -#### Inherited from - -[SizedLinkedList](SizedLinkedList.md).[pop](SizedLinkedList.md#pop) - -#### Defined in - -[src/SizedLinkedList.ts:14](https://github.com/zimmed/prefab/blob/a5ffdd1/src/SizedLinkedList.ts#L14) - -___ - -### recycle - -▸ **recycle**(): [`Queue`](Queue.md)<`T`\> - -Moves element from front of list to the end - -#### Returns - -[`Queue`](Queue.md)<`T`\> - -#### Inherited from - -[SizedLinkedList](SizedLinkedList.md).[recycle](SizedLinkedList.md#recycle) - -#### Defined in - -[src/LinkedList.ts:132](https://github.com/zimmed/prefab/blob/a5ffdd1/src/LinkedList.ts#L132) - -___ - -### reduce - -▸ **reduce**<`RT`\>(`cb`, `initialValue`): `RT` - -Reduces list into specified value (same signature as Array.prototype.reduce) - -#### Type parameters - -| Name | -| :------ | -| `RT` | - -#### Parameters - -| Name | Type | -| :------ | :------ | -| `cb` | `Reducer`<`T`, [`Queue`](Queue.md)<`T`\>, `RT`, [`Queue`](Queue.md)<`T`\>\> | -| `initialValue` | `RT` | - -#### Returns - -`RT` - -#### Inherited from - -[SizedLinkedList](SizedLinkedList.md).[reduce](SizedLinkedList.md#reduce) - -#### Defined in - -[src/LinkedList.ts:248](https://github.com/zimmed/prefab/blob/a5ffdd1/src/LinkedList.ts#L248) - -▸ **reduce**<`RT`, `This`\>(`cb`, `initialValue`, `thisArg?`): `RT` - -#### Type parameters - -| Name | -| :------ | -| `RT` | -| `This` | - -#### Parameters - -| Name | Type | -| :------ | :------ | -| `cb` | `Reducer`<`T`, `This`, `RT`, [`Queue`](Queue.md)<`T`\>\> | -| `initialValue` | `RT` | -| `thisArg?` | `This` | - -#### Returns - -`RT` - -#### Inherited from - -[SizedLinkedList](SizedLinkedList.md).[reduce](SizedLinkedList.md#reduce) - -#### Defined in - -[src/LinkedList.ts:249](https://github.com/zimmed/prefab/blob/a5ffdd1/src/LinkedList.ts#L249) - -___ - -### reduceRight - -▸ **reduceRight**<`RT`\>(`cb`, `initialValue`): `RT` - -Reduces items from the end of the list to the front - -#### Type parameters - -| Name | -| :------ | -| `RT` | - -#### Parameters - -| Name | Type | -| :------ | :------ | -| `cb` | `Reducer`<`T`, [`Queue`](Queue.md)<`T`\>, `RT`, [`Queue`](Queue.md)<`T`\>\> | -| `initialValue` | `RT` | - -#### Returns - -`RT` - -#### Inherited from - -[SizedLinkedList](SizedLinkedList.md).[reduceRight](SizedLinkedList.md#reduceright) - -#### Defined in - -[src/SizedLinkedList.ts:63](https://github.com/zimmed/prefab/blob/a5ffdd1/src/SizedLinkedList.ts#L63) - -▸ **reduceRight**<`RT`, `This`\>(`cb`, `initialValue`, `thisArg`): `RT` - -#### Type parameters - -| Name | -| :------ | -| `RT` | -| `This` | - -#### Parameters - -| Name | Type | -| :------ | :------ | -| `cb` | `Reducer`<`T`, `This`, `RT`, [`Queue`](Queue.md)<`T`\>\> | -| `initialValue` | `RT` | -| `thisArg` | `This` | - -#### Returns - -`RT` - -#### Inherited from - -[SizedLinkedList](SizedLinkedList.md).[reduceRight](SizedLinkedList.md#reduceright) - -#### Defined in - -[src/SizedLinkedList.ts:64](https://github.com/zimmed/prefab/blob/a5ffdd1/src/SizedLinkedList.ts#L64) - -___ - -### reverse - -▸ **reverse**(): `IterableIterator`<`T`\> - -Iterates through list items in reverse - -#### Returns - -`IterableIterator`<`T`\> - -#### Inherited from - -[SizedLinkedList](SizedLinkedList.md).[reverse](SizedLinkedList.md#reverse) - -#### Defined in - -[src/LinkedList.ts:217](https://github.com/zimmed/prefab/blob/a5ffdd1/src/LinkedList.ts#L217) - -___ - -### reverseMap - -▸ **reverseMap**<`RT`\>(`cb`): `RT`[] - -Maps list items from the end of the set to the front into a new array - -#### Type parameters - -| Name | -| :------ | -| `RT` | - -#### Parameters - -| Name | Type | -| :------ | :------ | -| `cb` | `Callback`<`T`, [`Queue`](Queue.md)<`T`\>, `RT`, [`Queue`](Queue.md)<`T`\>\> | - -#### Returns - -`RT`[] - -#### Inherited from - -[SizedLinkedList](SizedLinkedList.md).[reverseMap](SizedLinkedList.md#reversemap) - -#### Defined in - -[src/SizedLinkedList.ts:133](https://github.com/zimmed/prefab/blob/a5ffdd1/src/SizedLinkedList.ts#L133) - -▸ **reverseMap**<`RT`, `This`\>(`cb`, `thisArg`): `RT`[] - -#### Type parameters - -| Name | -| :------ | -| `RT` | -| `This` | - -#### Parameters - -| Name | Type | -| :------ | :------ | -| `cb` | `Callback`<`T`, `This`, `RT`, [`Queue`](Queue.md)<`T`\>\> | -| `thisArg` | `This` | - -#### Returns - -`RT`[] - -#### Inherited from - -[SizedLinkedList](SizedLinkedList.md).[reverseMap](SizedLinkedList.md#reversemap) - -#### Defined in - -[src/SizedLinkedList.ts:134](https://github.com/zimmed/prefab/blob/a5ffdd1/src/SizedLinkedList.ts#L134) - -___ - -### shift - -▸ **shift**(): `undefined` \| `T` - -Shifts item from the front of the list - -#### Returns - -`undefined` \| `T` - -#### Inherited from - -[SizedLinkedList](SizedLinkedList.md).[shift](SizedLinkedList.md#shift) - -#### Defined in - -[src/SizedLinkedList.ts:25](https://github.com/zimmed/prefab/blob/a5ffdd1/src/SizedLinkedList.ts#L25) - -___ - -### tailNode - -▸ **tailNode**(`node`): [`Queue`](Queue.md)<`T`\> - -Caution: Assumes node is already part of linked list -Moves node to the end of the list - -#### Parameters - -| Name | Type | -| :------ | :------ | -| `node` | `LNode`<`T`\> | - -#### Returns - -[`Queue`](Queue.md)<`T`\> - -#### Inherited from - -[SizedLinkedList](SizedLinkedList.md).[tailNode](SizedLinkedList.md#tailnode) - -#### Defined in - -[src/LinkedList.ts:155](https://github.com/zimmed/prefab/blob/a5ffdd1/src/LinkedList.ts#L155) - -___ - -### toArray - -▸ **toArray**(): `T`[] - -Converts list to native Array - -#### Returns - -`T`[] - -#### Inherited from - -[SizedLinkedList](SizedLinkedList.md).[toArray](SizedLinkedList.md#toarray) - -#### Defined in - -[src/LinkedList.ts:179](https://github.com/zimmed/prefab/blob/a5ffdd1/src/LinkedList.ts#L179) - -___ - -### toJSON - -▸ **toJSON**(): `T`[] - -#### Returns - -`T`[] - -#### Inherited from - -[SizedLinkedList](SizedLinkedList.md).[toJSON](SizedLinkedList.md#tojson) - -#### Defined in - -[src/LinkedList.ts:387](https://github.com/zimmed/prefab/blob/a5ffdd1/src/LinkedList.ts#L387) - -___ - -### unshift - -▸ **unshift**(`item`): [`Queue`](Queue.md)<`T`\> - -Alias for insert - -#### Parameters - -| Name | Type | -| :------ | :------ | -| `item` | `T` | - -#### Returns - -[`Queue`](Queue.md)<`T`\> - -#### Inherited from - -[SizedLinkedList](SizedLinkedList.md).[unshift](SizedLinkedList.md#unshift) - -#### Defined in - -[src/LinkedList.ts:117](https://github.com/zimmed/prefab/blob/a5ffdd1/src/LinkedList.ts#L117) - -___ - -### values - -▸ **values**(): `IterableIterator`<`T`\> - -Iterates through list items - -#### Returns - -`IterableIterator`<`T`\> - -#### Inherited from - -[SizedLinkedList](SizedLinkedList.md).[values](SizedLinkedList.md#values) - -#### Defined in - -[src/LinkedList.ts:207](https://github.com/zimmed/prefab/blob/a5ffdd1/src/LinkedList.ts#L207) - -___ - -### create - -▸ `Static` **create**<`T`\>(`iterable?`, `type?`): [`Queue`](Queue.md)<`T`\> - -Static factory method as alias for class constructor - -#### Type parameters - -| Name | -| :------ | -| `T` | - -#### Parameters - -| Name | Type | -| :------ | :------ | -| `iterable?` | `IterableIterator`<`T`\> \| `T`[] \| `Generator`<`T`, `void`, `unknown`\> | -| `type?` | `Type` | - -#### Returns - -[`Queue`](Queue.md)<`T`\> - -#### Overrides - -[SizedLinkedList](SizedLinkedList.md).[create](SizedLinkedList.md#create) - -#### Defined in - -[src/Queue.ts:13](https://github.com/zimmed/prefab/blob/a5ffdd1/src/Queue.ts#L13) - -___ - -### from - -▸ `Static` **from**<`T`\>(`iterable`, `type?`): [`Queue`](Queue.md)<`T`\> - -Same as LinkedList.create() but requires constructor arg - -#### Type parameters - -| Name | -| :------ | -| `T` | - -#### Parameters - -| Name | Type | -| :------ | :------ | -| `iterable` | `IterableIterator`<`T`\> \| `T`[] \| `Generator`<`T`, `void`, `unknown`\> | -| `type?` | `Type` | - -#### Returns - -[`Queue`](Queue.md)<`T`\> - -#### Overrides - -[SizedLinkedList](SizedLinkedList.md).[from](SizedLinkedList.md#from) - -#### Defined in - -[src/Queue.ts:21](https://github.com/zimmed/prefab/blob/a5ffdd1/src/Queue.ts#L21) diff --git a/docs/classes/SizedLinkedList.md b/docs/classes/SizedLinkedList.md index aba1a63..5a7b216 100644 --- a/docs/classes/SizedLinkedList.md +++ b/docs/classes/SizedLinkedList.md @@ -15,8 +15,6 @@ ↳ **`SizedLinkedList`** - ↳↳ [`Queue`](Queue.md) - ## Table of contents ### Constructors @@ -69,8 +67,6 @@ - [toJSON](SizedLinkedList.md#tojson) - [unshift](SizedLinkedList.md#unshift) - [values](SizedLinkedList.md#values) -- [create](SizedLinkedList.md#create) -- [from](SizedLinkedList.md#from) ## Constructors @@ -98,7 +94,7 @@ #### Defined in -[src/LinkedList.ts:59](https://github.com/zimmed/prefab/blob/a5ffdd1/src/LinkedList.ts#L59) +[src/LinkedList.ts:49](https://github.com/zimmed/prefab/blob/83cd828/src/LinkedList.ts#L49) ## Properties @@ -112,7 +108,7 @@ #### Defined in -[src/LinkedList.ts:30](https://github.com/zimmed/prefab/blob/a5ffdd1/src/LinkedList.ts#L30) +[src/LinkedList.ts:20](https://github.com/zimmed/prefab/blob/83cd828/src/LinkedList.ts#L20) ___ @@ -122,7 +118,7 @@ ___ #### Defined in -[src/SizedLinkedList.ts:6](https://github.com/zimmed/prefab/blob/a5ffdd1/src/SizedLinkedList.ts#L6) +[src/SizedLinkedList.ts:6](https://github.com/zimmed/prefab/blob/83cd828/src/SizedLinkedList.ts#L6) ___ @@ -136,7 +132,7 @@ ___ #### Defined in -[src/LinkedList.ts:33](https://github.com/zimmed/prefab/blob/a5ffdd1/src/LinkedList.ts#L33) +[src/LinkedList.ts:23](https://github.com/zimmed/prefab/blob/83cd828/src/LinkedList.ts#L23) ## Accessors @@ -156,7 +152,7 @@ LinkedList.head #### Defined in -[src/LinkedList.ts:36](https://github.com/zimmed/prefab/blob/a5ffdd1/src/LinkedList.ts#L36) +[src/LinkedList.ts:26](https://github.com/zimmed/prefab/blob/83cd828/src/LinkedList.ts#L26) ___ @@ -172,7 +168,7 @@ Current size of list #### Defined in -[src/SizedLinkedList.ts:9](https://github.com/zimmed/prefab/blob/a5ffdd1/src/SizedLinkedList.ts#L9) +[src/SizedLinkedList.ts:9](https://github.com/zimmed/prefab/blob/83cd828/src/SizedLinkedList.ts#L9) ___ @@ -192,7 +188,7 @@ LinkedList.tail #### Defined in -[src/LinkedList.ts:40](https://github.com/zimmed/prefab/blob/a5ffdd1/src/LinkedList.ts#L40) +[src/LinkedList.ts:30](https://github.com/zimmed/prefab/blob/83cd828/src/LinkedList.ts#L30) ## Methods @@ -210,7 +206,7 @@ LinkedList.tail #### Defined in -[src/LinkedList.ts:391](https://github.com/zimmed/prefab/blob/a5ffdd1/src/LinkedList.ts#L391) +[src/LinkedList.ts:382](https://github.com/zimmed/prefab/blob/83cd828/src/LinkedList.ts#L382) ___ @@ -236,7 +232,7 @@ Adds item to end of the list #### Defined in -[src/LinkedList.ts:122](https://github.com/zimmed/prefab/blob/a5ffdd1/src/LinkedList.ts#L122) +[src/LinkedList.ts:112](https://github.com/zimmed/prefab/blob/83cd828/src/LinkedList.ts#L112) ___ @@ -262,7 +258,7 @@ Appends Node onto the end of the list #### Defined in -[src/SizedLinkedList.ts:42](https://github.com/zimmed/prefab/blob/a5ffdd1/src/SizedLinkedList.ts#L42) +[src/SizedLinkedList.ts:42](https://github.com/zimmed/prefab/blob/83cd828/src/SizedLinkedList.ts#L42) ___ @@ -288,7 +284,7 @@ Adds item to end of the list #### Defined in -[src/LinkedList.ts:107](https://github.com/zimmed/prefab/blob/a5ffdd1/src/LinkedList.ts#L107) +[src/LinkedList.ts:97](https://github.com/zimmed/prefab/blob/83cd828/src/LinkedList.ts#L97) ___ @@ -308,7 +304,7 @@ Clears the list #### Defined in -[src/SizedLinkedList.ts:48](https://github.com/zimmed/prefab/blob/a5ffdd1/src/SizedLinkedList.ts#L48) +[src/SizedLinkedList.ts:48](https://github.com/zimmed/prefab/blob/83cd828/src/SizedLinkedList.ts#L48) ___ @@ -328,7 +324,7 @@ Moves element from end of list to the front #### Defined in -[src/LinkedList.ts:127](https://github.com/zimmed/prefab/blob/a5ffdd1/src/LinkedList.ts#L127) +[src/LinkedList.ts:117](https://github.com/zimmed/prefab/blob/83cd828/src/LinkedList.ts#L117) ___ @@ -354,7 +350,7 @@ Removes item from the list #### Defined in -[src/LinkedList.ts:174](https://github.com/zimmed/prefab/blob/a5ffdd1/src/LinkedList.ts#L174) +[src/LinkedList.ts:165](https://github.com/zimmed/prefab/blob/83cd828/src/LinkedList.ts#L165) ___ @@ -380,7 +376,7 @@ Deletes specified node from the list #### Defined in -[src/SizedLinkedList.ts:54](https://github.com/zimmed/prefab/blob/a5ffdd1/src/SizedLinkedList.ts#L54) +[src/SizedLinkedList.ts:54](https://github.com/zimmed/prefab/blob/83cd828/src/SizedLinkedList.ts#L54) ___ @@ -400,7 +396,7 @@ Kind of pointless, but needed for parity with builtin Set object #### Defined in -[src/LinkedList.ts:196](https://github.com/zimmed/prefab/blob/a5ffdd1/src/LinkedList.ts#L196) +[src/LinkedList.ts:187](https://github.com/zimmed/prefab/blob/83cd828/src/LinkedList.ts#L187) ___ @@ -426,7 +422,7 @@ Uses predicate to return a new array of all matching items (same signature is Ar #### Defined in -[src/LinkedList.ts:295](https://github.com/zimmed/prefab/blob/a5ffdd1/src/LinkedList.ts#L295) +[src/LinkedList.ts:286](https://github.com/zimmed/prefab/blob/83cd828/src/LinkedList.ts#L286) ▸ **filter**<`This`\>(`predicate`, `thisArg`): `T`[] @@ -453,7 +449,7 @@ Uses predicate to return a new array of all matching items (same signature is Ar #### Defined in -[src/LinkedList.ts:296](https://github.com/zimmed/prefab/blob/a5ffdd1/src/LinkedList.ts#L296) +[src/LinkedList.ts:287](https://github.com/zimmed/prefab/blob/83cd828/src/LinkedList.ts#L287) ___ @@ -479,7 +475,7 @@ Uses predicate to return first matching item or undefined if no matches (same si #### Defined in -[src/LinkedList.ts:269](https://github.com/zimmed/prefab/blob/a5ffdd1/src/LinkedList.ts#L269) +[src/LinkedList.ts:260](https://github.com/zimmed/prefab/blob/83cd828/src/LinkedList.ts#L260) ▸ **find**<`This`\>(`predicate`, `thisArg`): `undefined` \| `T` @@ -506,7 +502,7 @@ Uses predicate to return first matching item or undefined if no matches (same si #### Defined in -[src/LinkedList.ts:270](https://github.com/zimmed/prefab/blob/a5ffdd1/src/LinkedList.ts#L270) +[src/LinkedList.ts:261](https://github.com/zimmed/prefab/blob/83cd828/src/LinkedList.ts#L261) ___ @@ -528,7 +524,7 @@ Finds predicate-matching item, with iteration beginning at the end of the list #### Defined in -[src/SizedLinkedList.ts:84](https://github.com/zimmed/prefab/blob/a5ffdd1/src/SizedLinkedList.ts#L84) +[src/SizedLinkedList.ts:84](https://github.com/zimmed/prefab/blob/83cd828/src/SizedLinkedList.ts#L84) ▸ **findRight**<`This`\>(`predicate`, `thisArg`): `undefined` \| `T` @@ -551,7 +547,7 @@ Finds predicate-matching item, with iteration beginning at the end of the list #### Defined in -[src/SizedLinkedList.ts:85](https://github.com/zimmed/prefab/blob/a5ffdd1/src/SizedLinkedList.ts#L85) +[src/SizedLinkedList.ts:85](https://github.com/zimmed/prefab/blob/83cd828/src/SizedLinkedList.ts#L85) ___ @@ -577,7 +573,7 @@ Operates on each element of the list in a callback method (same signature as Arr #### Defined in -[src/LinkedList.ts:227](https://github.com/zimmed/prefab/blob/a5ffdd1/src/LinkedList.ts#L227) +[src/LinkedList.ts:218](https://github.com/zimmed/prefab/blob/83cd828/src/LinkedList.ts#L218) ▸ **forEach**<`ThisArg`\>(`cb`, `thisArg?`): `void` @@ -604,7 +600,7 @@ Operates on each element of the list in a callback method (same signature as Arr #### Defined in -[src/LinkedList.ts:228](https://github.com/zimmed/prefab/blob/a5ffdd1/src/LinkedList.ts#L228) +[src/LinkedList.ts:219](https://github.com/zimmed/prefab/blob/83cd828/src/LinkedList.ts#L219) ___ @@ -631,7 +627,7 @@ Checks to see if item exists in list #### Defined in -[src/LinkedList.ts:102](https://github.com/zimmed/prefab/blob/a5ffdd1/src/LinkedList.ts#L102) +[src/LinkedList.ts:92](https://github.com/zimmed/prefab/blob/83cd828/src/LinkedList.ts#L92) ___ @@ -658,7 +654,7 @@ Moves node to the front of the list #### Defined in -[src/LinkedList.ts:140](https://github.com/zimmed/prefab/blob/a5ffdd1/src/LinkedList.ts#L140) +[src/LinkedList.ts:130](https://github.com/zimmed/prefab/blob/83cd828/src/LinkedList.ts#L130) ___ @@ -684,7 +680,7 @@ Adds item to front of the list #### Defined in -[src/LinkedList.ts:112](https://github.com/zimmed/prefab/blob/a5ffdd1/src/LinkedList.ts#L112) +[src/LinkedList.ts:102](https://github.com/zimmed/prefab/blob/83cd828/src/LinkedList.ts#L102) ___ @@ -710,7 +706,7 @@ Inserts Node into the front the list #### Defined in -[src/SizedLinkedList.ts:36](https://github.com/zimmed/prefab/blob/a5ffdd1/src/SizedLinkedList.ts#L36) +[src/SizedLinkedList.ts:36](https://github.com/zimmed/prefab/blob/83cd828/src/SizedLinkedList.ts#L36) ___ @@ -736,7 +732,7 @@ Joins list elements into one string (same signature as Array.prototype.join) #### Defined in -[src/LinkedList.ts:347](https://github.com/zimmed/prefab/blob/a5ffdd1/src/LinkedList.ts#L347) +[src/LinkedList.ts:338](https://github.com/zimmed/prefab/blob/83cd828/src/LinkedList.ts#L338) ___ @@ -756,7 +752,7 @@ Alias for values() method #### Defined in -[src/LinkedList.ts:191](https://github.com/zimmed/prefab/blob/a5ffdd1/src/LinkedList.ts#L191) +[src/LinkedList.ts:182](https://github.com/zimmed/prefab/blob/83cd828/src/LinkedList.ts#L182) ___ @@ -788,7 +784,7 @@ Maps list items into a new array #### Defined in -[src/SizedLinkedList.ts:110](https://github.com/zimmed/prefab/blob/a5ffdd1/src/SizedLinkedList.ts#L110) +[src/SizedLinkedList.ts:110](https://github.com/zimmed/prefab/blob/83cd828/src/SizedLinkedList.ts#L110) ▸ **map**<`RT`, `This`\>(`cb`, `thisArg`): `RT`[] @@ -816,7 +812,7 @@ Maps list items into a new array #### Defined in -[src/SizedLinkedList.ts:111](https://github.com/zimmed/prefab/blob/a5ffdd1/src/SizedLinkedList.ts#L111) +[src/SizedLinkedList.ts:111](https://github.com/zimmed/prefab/blob/83cd828/src/SizedLinkedList.ts#L111) ___ @@ -836,7 +832,7 @@ Pops item from end of the list #### Defined in -[src/SizedLinkedList.ts:14](https://github.com/zimmed/prefab/blob/a5ffdd1/src/SizedLinkedList.ts#L14) +[src/SizedLinkedList.ts:14](https://github.com/zimmed/prefab/blob/83cd828/src/SizedLinkedList.ts#L14) ___ @@ -856,7 +852,7 @@ Moves element from front of list to the end #### Defined in -[src/LinkedList.ts:132](https://github.com/zimmed/prefab/blob/a5ffdd1/src/LinkedList.ts#L132) +[src/LinkedList.ts:122](https://github.com/zimmed/prefab/blob/83cd828/src/LinkedList.ts#L122) ___ @@ -889,7 +885,7 @@ Reduces list into specified value (same signature as Array.prototype.reduce) #### Defined in -[src/LinkedList.ts:248](https://github.com/zimmed/prefab/blob/a5ffdd1/src/LinkedList.ts#L248) +[src/LinkedList.ts:239](https://github.com/zimmed/prefab/blob/83cd828/src/LinkedList.ts#L239) ▸ **reduce**<`RT`, `This`\>(`cb`, `initialValue`, `thisArg?`): `RT` @@ -918,7 +914,7 @@ Reduces list into specified value (same signature as Array.prototype.reduce) #### Defined in -[src/LinkedList.ts:249](https://github.com/zimmed/prefab/blob/a5ffdd1/src/LinkedList.ts#L249) +[src/LinkedList.ts:240](https://github.com/zimmed/prefab/blob/83cd828/src/LinkedList.ts#L240) ___ @@ -947,7 +943,7 @@ Reduces items from the end of the list to the front #### Defined in -[src/SizedLinkedList.ts:63](https://github.com/zimmed/prefab/blob/a5ffdd1/src/SizedLinkedList.ts#L63) +[src/SizedLinkedList.ts:63](https://github.com/zimmed/prefab/blob/83cd828/src/SizedLinkedList.ts#L63) ▸ **reduceRight**<`RT`, `This`\>(`cb`, `initialValue`, `thisArg`): `RT` @@ -972,7 +968,7 @@ Reduces items from the end of the list to the front #### Defined in -[src/SizedLinkedList.ts:64](https://github.com/zimmed/prefab/blob/a5ffdd1/src/SizedLinkedList.ts#L64) +[src/SizedLinkedList.ts:64](https://github.com/zimmed/prefab/blob/83cd828/src/SizedLinkedList.ts#L64) ___ @@ -992,7 +988,7 @@ Iterates through list items in reverse #### Defined in -[src/LinkedList.ts:217](https://github.com/zimmed/prefab/blob/a5ffdd1/src/LinkedList.ts#L217) +[src/LinkedList.ts:208](https://github.com/zimmed/prefab/blob/83cd828/src/LinkedList.ts#L208) ___ @@ -1020,7 +1016,7 @@ Maps list items from the end of the set to the front into a new array #### Defined in -[src/SizedLinkedList.ts:133](https://github.com/zimmed/prefab/blob/a5ffdd1/src/SizedLinkedList.ts#L133) +[src/SizedLinkedList.ts:133](https://github.com/zimmed/prefab/blob/83cd828/src/SizedLinkedList.ts#L133) ▸ **reverseMap**<`RT`, `This`\>(`cb`, `thisArg`): `RT`[] @@ -1044,7 +1040,7 @@ Maps list items from the end of the set to the front into a new array #### Defined in -[src/SizedLinkedList.ts:134](https://github.com/zimmed/prefab/blob/a5ffdd1/src/SizedLinkedList.ts#L134) +[src/SizedLinkedList.ts:134](https://github.com/zimmed/prefab/blob/83cd828/src/SizedLinkedList.ts#L134) ___ @@ -1064,7 +1060,7 @@ Shifts item from the front of the list #### Defined in -[src/SizedLinkedList.ts:25](https://github.com/zimmed/prefab/blob/a5ffdd1/src/SizedLinkedList.ts#L25) +[src/SizedLinkedList.ts:25](https://github.com/zimmed/prefab/blob/83cd828/src/SizedLinkedList.ts#L25) ___ @@ -1091,7 +1087,7 @@ Moves node to the end of the list #### Defined in -[src/LinkedList.ts:155](https://github.com/zimmed/prefab/blob/a5ffdd1/src/LinkedList.ts#L155) +[src/LinkedList.ts:146](https://github.com/zimmed/prefab/blob/83cd828/src/LinkedList.ts#L146) ___ @@ -1111,7 +1107,7 @@ Converts list to native Array #### Defined in -[src/LinkedList.ts:179](https://github.com/zimmed/prefab/blob/a5ffdd1/src/LinkedList.ts#L179) +[src/LinkedList.ts:170](https://github.com/zimmed/prefab/blob/83cd828/src/LinkedList.ts#L170) ___ @@ -1129,7 +1125,7 @@ ___ #### Defined in -[src/LinkedList.ts:387](https://github.com/zimmed/prefab/blob/a5ffdd1/src/LinkedList.ts#L387) +[src/LinkedList.ts:378](https://github.com/zimmed/prefab/blob/83cd828/src/LinkedList.ts#L378) ___ @@ -1155,7 +1151,7 @@ Alias for insert #### Defined in -[src/LinkedList.ts:117](https://github.com/zimmed/prefab/blob/a5ffdd1/src/LinkedList.ts#L117) +[src/LinkedList.ts:107](https://github.com/zimmed/prefab/blob/83cd828/src/LinkedList.ts#L107) ___ @@ -1175,68 +1171,4 @@ Iterates through list items #### Defined in -[src/LinkedList.ts:207](https://github.com/zimmed/prefab/blob/a5ffdd1/src/LinkedList.ts#L207) - -___ - -### create - -▸ `Static` **create**<`T`\>(`iterable?`): [`LinkedList`](LinkedList.md)<`T`, `LNode`<`T`\>\> - -Static factory method as alias for class constructor - -#### Type parameters - -| Name | -| :------ | -| `T` | - -#### Parameters - -| Name | Type | -| :------ | :------ | -| `iterable?` | `IterableIterator`<`T`\> \| `T`[] \| `Generator`<`T`, `void`, `unknown`\> | - -#### Returns - -[`LinkedList`](LinkedList.md)<`T`, `LNode`<`T`\>\> - -#### Inherited from - -[LinkedList](LinkedList.md).[create](LinkedList.md#create) - -#### Defined in - -[src/LinkedList.ts:20](https://github.com/zimmed/prefab/blob/a5ffdd1/src/LinkedList.ts#L20) - -___ - -### from - -▸ `Static` **from**<`T`\>(`iterable`): [`LinkedList`](LinkedList.md)<`T`, `LNode`<`T`\>\> - -Same as LinkedList.create() but requires constructor arg - -#### Type parameters - -| Name | -| :------ | -| `T` | - -#### Parameters - -| Name | Type | -| :------ | :------ | -| `iterable` | `IterableIterator`<`T`\> \| `T`[] \| `Generator`<`T`, `void`, `unknown`\> | - -#### Returns - -[`LinkedList`](LinkedList.md)<`T`, `LNode`<`T`\>\> - -#### Inherited from - -[LinkedList](LinkedList.md).[from](LinkedList.md#from) - -#### Defined in - -[src/LinkedList.ts:25](https://github.com/zimmed/prefab/blob/a5ffdd1/src/LinkedList.ts#L25) +[src/LinkedList.ts:198](https://github.com/zimmed/prefab/blob/83cd828/src/LinkedList.ts#L198) diff --git a/docs/classes/SortedSet.md b/docs/classes/SortedSet.md deleted file mode 100644 index 67f44c1..0000000 --- a/docs/classes/SortedSet.md +++ /dev/null @@ -1,1323 +0,0 @@ -[@zimmed/prefab](../README.md) / [Exports](../modules.md) / SortedSet - -# Class: SortedSet - -## Type parameters - -| Name | Type | -| :------ | :------ | -| `T` | `T` | -| `N` | extends `LNode`<`T`\> = `LNode`<`T`\> | - -## Hierarchy - -- [`LinkedSet`](LinkedSet.md)<`T`, `N`\> - - ↳ **`SortedSet`** - - ↳↳ [`PriorityQueue`](PriorityQueue.md) - -## Table of contents - -### Constructors - -- [constructor](SortedSet.md#constructor) - -### Properties - -- [\_cmp](SortedSet.md#_cmp) -- [\_head](SortedSet.md#_head) -- [\_map](SortedSet.md#_map) -- [\_tail](SortedSet.md#_tail) -- [\_tree](SortedSet.md#_tree) - -### Accessors - -- [head](SortedSet.md#head) -- [size](SortedSet.md#size) -- [tail](SortedSet.md#tail) - -### Methods - -- [[iterator]](SortedSet.md#[iterator]) -- [add](SortedSet.md#add) -- [addNode](SortedSet.md#addnode) -- [append](SortedSet.md#append) -- [clear](SortedSet.md#clear) -- [cycle](SortedSet.md#cycle) -- [delete](SortedSet.md#delete) -- [deleteNode](SortedSet.md#deletenode) -- [entries](SortedSet.md#entries) -- [filter](SortedSet.md#filter) -- [find](SortedSet.md#find) -- [findRight](SortedSet.md#findright) -- [forEach](SortedSet.md#foreach) -- [has](SortedSet.md#has) -- [headNode](SortedSet.md#headnode) -- [insert](SortedSet.md#insert) -- [insertNode](SortedSet.md#insertnode) -- [join](SortedSet.md#join) -- [keys](SortedSet.md#keys) -- [map](SortedSet.md#map) -- [pop](SortedSet.md#pop) -- [recycle](SortedSet.md#recycle) -- [reduce](SortedSet.md#reduce) -- [reduceRight](SortedSet.md#reduceright) -- [reverse](SortedSet.md#reverse) -- [reverseMap](SortedSet.md#reversemap) -- [search](SortedSet.md#search) -- [shift](SortedSet.md#shift) -- [tailNode](SortedSet.md#tailnode) -- [toArray](SortedSet.md#toarray) -- [toJSON](SortedSet.md#tojson) -- [unshift](SortedSet.md#unshift) -- [values](SortedSet.md#values) -- [create](SortedSet.md#create) -- [from](SortedSet.md#from) - -## Constructors - -### constructor - -• **new SortedSet**<`T`, `N`\>(`iterable?`, `compareFunction?`) - -#### Type parameters - -| Name | Type | -| :------ | :------ | -| `T` | `T` | -| `N` | extends `LNode`<`T`\> = `LNode`<`T`\> | - -#### Parameters - -| Name | Type | Default value | -| :------ | :------ | :------ | -| `iterable?` | `IterableIterator`<`T`\> \| `T`[] \| `Generator`<`T`, `void`, `unknown`\> | `undefined` | -| `compareFunction` | `Sort`<`T`, `any`\> | `DEFAULT_SORT` | - -#### Overrides - -[LinkedSet](LinkedSet.md).[constructor](LinkedSet.md#constructor) - -#### Defined in - -[src/SortedSet.ts:40](https://github.com/zimmed/prefab/blob/a5ffdd1/src/SortedSet.ts#L40) - -## Properties - -### \_cmp - -• `Private` `Readonly` **\_cmp**: `Sort`<`T`, `any`\> - -#### Defined in - -[src/SortedSet.ts:38](https://github.com/zimmed/prefab/blob/a5ffdd1/src/SortedSet.ts#L38) - -___ - -### \_head - -• `Protected` `Optional` **\_head**: `N` - -#### Inherited from - -[LinkedSet](LinkedSet.md).[_head](LinkedSet.md#_head) - -#### Defined in - -[src/LinkedList.ts:30](https://github.com/zimmed/prefab/blob/a5ffdd1/src/LinkedList.ts#L30) - -___ - -### \_map - -• `Protected` `Readonly` **\_map**: `Map`<`T`, `N`\> - -#### Inherited from - -[LinkedSet](LinkedSet.md).[_map](LinkedSet.md#_map) - -#### Defined in - -[src/LinkedSet.ts:7](https://github.com/zimmed/prefab/blob/a5ffdd1/src/LinkedSet.ts#L7) - -___ - -### \_tail - -• `Protected` `Optional` **\_tail**: `N` - -#### Inherited from - -[LinkedSet](LinkedSet.md).[_tail](LinkedSet.md#_tail) - -#### Defined in - -[src/LinkedList.ts:33](https://github.com/zimmed/prefab/blob/a5ffdd1/src/LinkedList.ts#L33) - -___ - -### \_tree - -• `Protected` `Optional` **\_tree**: `TNode`<`T`\> - -#### Defined in - -[src/SortedSet.ts:35](https://github.com/zimmed/prefab/blob/a5ffdd1/src/SortedSet.ts#L35) - -## Accessors - -### head - -• `get` **head**(): `undefined` \| `T` - -Item at head of the list - -#### Returns - -`undefined` \| `T` - -#### Inherited from - -LinkedSet.head - -#### Defined in - -[src/LinkedList.ts:36](https://github.com/zimmed/prefab/blob/a5ffdd1/src/LinkedList.ts#L36) - -___ - -### size - -• `get` **size**(): `number` - -Current size of set - -#### Returns - -`number` - -#### Inherited from - -LinkedSet.size - -#### Defined in - -[src/LinkedSet.ts:10](https://github.com/zimmed/prefab/blob/a5ffdd1/src/LinkedSet.ts#L10) - -___ - -### tail - -• `get` **tail**(): `undefined` \| `T` - -Item at tail of the list - -#### Returns - -`undefined` \| `T` - -#### Inherited from - -LinkedSet.tail - -#### Defined in - -[src/LinkedList.ts:40](https://github.com/zimmed/prefab/blob/a5ffdd1/src/LinkedList.ts#L40) - -## Methods - -### [iterator] - -▸ **[iterator]**(): `IterableIterator`<`T`\> - -#### Returns - -`IterableIterator`<`T`\> - -#### Inherited from - -[LinkedSet](LinkedSet.md).[[iterator]](LinkedSet.md#[iterator]) - -#### Defined in - -[src/LinkedList.ts:391](https://github.com/zimmed/prefab/blob/a5ffdd1/src/LinkedList.ts#L391) - -___ - -### add - -▸ **add**(`item`): [`SortedSet`](SortedSet.md)<`T`, `N`\> - -Appends item onto the end of the set - -#### Parameters - -| Name | Type | -| :------ | :------ | -| `item` | `T` | - -#### Returns - -[`SortedSet`](SortedSet.md)<`T`, `N`\> - -#### Overrides - -[LinkedSet](LinkedSet.md).[add](LinkedSet.md#add) - -#### Defined in - -[src/SortedSet.ts:105](https://github.com/zimmed/prefab/blob/a5ffdd1/src/SortedSet.ts#L105) - -___ - -### addNode - -▸ **addNode**(`node`): [`SortedSet`](SortedSet.md)<`T`, `N`\> - -Caution: Assumes node already has correct head and tail set -Adds node to the end of the list - -#### Parameters - -| Name | Type | -| :------ | :------ | -| `node` | `N` | - -#### Returns - -[`SortedSet`](SortedSet.md)<`T`, `N`\> - -#### Inherited from - -[LinkedSet](LinkedSet.md).[addNode](LinkedSet.md#addnode) - -#### Defined in - -[src/LinkedList.ts:367](https://github.com/zimmed/prefab/blob/a5ffdd1/src/LinkedList.ts#L367) - -___ - -### append - -▸ **append**(`item`): [`SortedSet`](SortedSet.md)<`T`, `N`\> - -Adds item to end of the list - -#### Parameters - -| Name | Type | -| :------ | :------ | -| `item` | `T` | - -#### Returns - -[`SortedSet`](SortedSet.md)<`T`, `N`\> - -#### Inherited from - -[LinkedSet](LinkedSet.md).[append](LinkedSet.md#append) - -#### Defined in - -[src/LinkedList.ts:107](https://github.com/zimmed/prefab/blob/a5ffdd1/src/LinkedList.ts#L107) - -___ - -### clear - -▸ **clear**(): `void` - -Clears the set - -#### Returns - -`void` - -#### Overrides - -[LinkedSet](LinkedSet.md).[clear](LinkedSet.md#clear) - -#### Defined in - -[src/SortedSet.ts:94](https://github.com/zimmed/prefab/blob/a5ffdd1/src/SortedSet.ts#L94) - -___ - -### cycle - -▸ **cycle**(): [`SortedSet`](SortedSet.md)<`T`, `N`\> - -Moves element from end of list to the front - -#### Returns - -[`SortedSet`](SortedSet.md)<`T`, `N`\> - -#### Inherited from - -[LinkedSet](LinkedSet.md).[cycle](LinkedSet.md#cycle) - -#### Defined in - -[src/LinkedList.ts:127](https://github.com/zimmed/prefab/blob/a5ffdd1/src/LinkedList.ts#L127) - -___ - -### delete - -▸ **delete**(`item`): `boolean` - -Deletes specified item from the set - -#### Parameters - -| Name | Type | -| :------ | :------ | -| `item` | `T` | - -#### Returns - -`boolean` - -#### Overrides - -[LinkedSet](LinkedSet.md).[delete](LinkedSet.md#delete) - -#### Defined in - -[src/SortedSet.ts:147](https://github.com/zimmed/prefab/blob/a5ffdd1/src/SortedSet.ts#L147) - -___ - -### deleteNode - -▸ **deleteNode**(`cur?`): `boolean` - -Removes specified node from the list - -#### Parameters - -| Name | Type | -| :------ | :------ | -| `cur?` | `N` | - -#### Returns - -`boolean` - -#### Inherited from - -[LinkedSet](LinkedSet.md).[deleteNode](LinkedSet.md#deletenode) - -#### Defined in - -[src/LinkedList.ts:376](https://github.com/zimmed/prefab/blob/a5ffdd1/src/LinkedList.ts#L376) - -___ - -### entries - -▸ **entries**(): `IterableIterator`<[`T`, `T`]\> - -Kind of pointless, but needed for parity with builtin Set object - -#### Returns - -`IterableIterator`<[`T`, `T`]\> - -#### Inherited from - -[LinkedSet](LinkedSet.md).[entries](LinkedSet.md#entries) - -#### Defined in - -[src/LinkedList.ts:196](https://github.com/zimmed/prefab/blob/a5ffdd1/src/LinkedList.ts#L196) - -___ - -### filter - -▸ **filter**(`predicate`): `T`[] - -Uses predicate to return a new array of all matching items (same signature is Array.protoype.filter) - -#### Parameters - -| Name | Type | -| :------ | :------ | -| `predicate` | `Callback`<`T`, [`SortedSet`](SortedSet.md)<`T`, `N`\>, `boolean`, [`SortedSet`](SortedSet.md)<`T`, `N`\>\> | - -#### Returns - -`T`[] - -#### Inherited from - -[LinkedSet](LinkedSet.md).[filter](LinkedSet.md#filter) - -#### Defined in - -[src/LinkedList.ts:295](https://github.com/zimmed/prefab/blob/a5ffdd1/src/LinkedList.ts#L295) - -▸ **filter**<`This`\>(`predicate`, `thisArg`): `T`[] - -#### Type parameters - -| Name | -| :------ | -| `This` | - -#### Parameters - -| Name | Type | -| :------ | :------ | -| `predicate` | `Callback`<`T`, `This`, `boolean`, [`SortedSet`](SortedSet.md)<`T`, `N`\>\> | -| `thisArg` | `This` | - -#### Returns - -`T`[] - -#### Inherited from - -[LinkedSet](LinkedSet.md).[filter](LinkedSet.md#filter) - -#### Defined in - -[src/LinkedList.ts:296](https://github.com/zimmed/prefab/blob/a5ffdd1/src/LinkedList.ts#L296) - -___ - -### find - -▸ **find**(`predicate`): `undefined` \| `T` - -Uses predicate to return first matching item or undefined if no matches (same signature as Array.prototype.find) - -#### Parameters - -| Name | Type | -| :------ | :------ | -| `predicate` | `Callback`<`T`, [`SortedSet`](SortedSet.md)<`T`, `N`\>, `boolean`, [`SortedSet`](SortedSet.md)<`T`, `N`\>\> | - -#### Returns - -`undefined` \| `T` - -#### Inherited from - -[LinkedSet](LinkedSet.md).[find](LinkedSet.md#find) - -#### Defined in - -[src/LinkedList.ts:269](https://github.com/zimmed/prefab/blob/a5ffdd1/src/LinkedList.ts#L269) - -▸ **find**<`This`\>(`predicate`, `thisArg`): `undefined` \| `T` - -#### Type parameters - -| Name | -| :------ | -| `This` | - -#### Parameters - -| Name | Type | -| :------ | :------ | -| `predicate` | `Callback`<`T`, `This`, `boolean`, [`SortedSet`](SortedSet.md)<`T`, `N`\>\> | -| `thisArg` | `This` | - -#### Returns - -`undefined` \| `T` - -#### Inherited from - -[LinkedSet](LinkedSet.md).[find](LinkedSet.md#find) - -#### Defined in - -[src/LinkedList.ts:270](https://github.com/zimmed/prefab/blob/a5ffdd1/src/LinkedList.ts#L270) - -___ - -### findRight - -▸ **findRight**(`predicate`): `undefined` \| `T` - -Finds predicate-matching item, with iteration beginning at the end of the set - -#### Parameters - -| Name | Type | -| :------ | :------ | -| `predicate` | `Callback`<`T`, [`SortedSet`](SortedSet.md)<`T`, `N`\>, `boolean`, [`SortedSet`](SortedSet.md)<`T`, `N`\>\> | - -#### Returns - -`undefined` \| `T` - -#### Inherited from - -[LinkedSet](LinkedSet.md).[findRight](LinkedSet.md#findright) - -#### Defined in - -[src/LinkedSet.ts:92](https://github.com/zimmed/prefab/blob/a5ffdd1/src/LinkedSet.ts#L92) - -▸ **findRight**<`This`\>(`predicate`, `thisArg`): `undefined` \| `T` - -#### Type parameters - -| Name | -| :------ | -| `This` | - -#### Parameters - -| Name | Type | -| :------ | :------ | -| `predicate` | `Callback`<`T`, `This`, `boolean`, [`SortedSet`](SortedSet.md)<`T`, `N`\>\> | -| `thisArg` | `This` | - -#### Returns - -`undefined` \| `T` - -#### Inherited from - -[LinkedSet](LinkedSet.md).[findRight](LinkedSet.md#findright) - -#### Defined in - -[src/LinkedSet.ts:93](https://github.com/zimmed/prefab/blob/a5ffdd1/src/LinkedSet.ts#L93) - -___ - -### forEach - -▸ **forEach**(`cb`): `void` - -Operates on each element of the list in a callback method (same signature as Array.prototype.forEach) - -#### Parameters - -| Name | Type | -| :------ | :------ | -| `cb` | `Callback`<`T`, [`SortedSet`](SortedSet.md)<`T`, `N`\>, `void`, [`SortedSet`](SortedSet.md)<`T`, `N`\>\> | - -#### Returns - -`void` - -#### Inherited from - -[LinkedSet](LinkedSet.md).[forEach](LinkedSet.md#foreach) - -#### Defined in - -[src/LinkedList.ts:227](https://github.com/zimmed/prefab/blob/a5ffdd1/src/LinkedList.ts#L227) - -▸ **forEach**<`ThisArg`\>(`cb`, `thisArg?`): `void` - -#### Type parameters - -| Name | -| :------ | -| `ThisArg` | - -#### Parameters - -| Name | Type | -| :------ | :------ | -| `cb` | `Callback`<`T`, `ThisArg`, `void`, [`SortedSet`](SortedSet.md)<`T`, `N`\>\> | -| `thisArg?` | `ThisArg` | - -#### Returns - -`void` - -#### Inherited from - -[LinkedSet](LinkedSet.md).[forEach](LinkedSet.md#foreach) - -#### Defined in - -[src/LinkedList.ts:228](https://github.com/zimmed/prefab/blob/a5ffdd1/src/LinkedList.ts#L228) - -___ - -### has - -▸ **has**(`item`): `boolean` - -Determines if set contains specified item - -#### Parameters - -| Name | Type | -| :------ | :------ | -| `item` | `T` | - -#### Returns - -`boolean` - -#### Inherited from - -[LinkedSet](LinkedSet.md).[has](LinkedSet.md#has) - -#### Defined in - -[src/LinkedSet.ts:36](https://github.com/zimmed/prefab/blob/a5ffdd1/src/LinkedSet.ts#L36) - -___ - -### headNode - -▸ **headNode**(`node`): [`SortedSet`](SortedSet.md)<`T`, `N`\> - -Caution: Assumes node is already part of linked list -Moves node to the front of the list - -#### Parameters - -| Name | Type | -| :------ | :------ | -| `node` | `N` | - -#### Returns - -[`SortedSet`](SortedSet.md)<`T`, `N`\> - -#### Inherited from - -[LinkedSet](LinkedSet.md).[headNode](LinkedSet.md#headnode) - -#### Defined in - -[src/LinkedList.ts:140](https://github.com/zimmed/prefab/blob/a5ffdd1/src/LinkedList.ts#L140) - -___ - -### insert - -▸ **insert**(`item`): [`SortedSet`](SortedSet.md)<`T`, `N`\> - -Inserts item into the front the set - -#### Parameters - -| Name | Type | -| :------ | :------ | -| `item` | `T` | - -#### Returns - -[`SortedSet`](SortedSet.md)<`T`, `N`\> - -#### Overrides - -[LinkedSet](LinkedSet.md).[insert](LinkedSet.md#insert) - -#### Defined in - -[src/SortedSet.ts:100](https://github.com/zimmed/prefab/blob/a5ffdd1/src/SortedSet.ts#L100) - -___ - -### insertNode - -▸ **insertNode**(`node`): [`SortedSet`](SortedSet.md)<`T`, `N`\> - -Caution: Assumes node already has correct head and tail set -Adds node to the front of the list - -#### Parameters - -| Name | Type | -| :------ | :------ | -| `node` | `N` | - -#### Returns - -[`SortedSet`](SortedSet.md)<`T`, `N`\> - -#### Inherited from - -[LinkedSet](LinkedSet.md).[insertNode](LinkedSet.md#insertnode) - -#### Defined in - -[src/LinkedList.ts:355](https://github.com/zimmed/prefab/blob/a5ffdd1/src/LinkedList.ts#L355) - -___ - -### join - -▸ **join**(`separator?`): `string` - -Joins list elements into one string (same signature as Array.prototype.join) - -#### Parameters - -| Name | Type | -| :------ | :------ | -| `separator?` | `string` | - -#### Returns - -`string` - -#### Inherited from - -[LinkedSet](LinkedSet.md).[join](LinkedSet.md#join) - -#### Defined in - -[src/LinkedList.ts:347](https://github.com/zimmed/prefab/blob/a5ffdd1/src/LinkedList.ts#L347) - -___ - -### keys - -▸ **keys**(): `IterableIterator`<`T`\> - -Alias for values() method - -#### Returns - -`IterableIterator`<`T`\> - -#### Inherited from - -[LinkedSet](LinkedSet.md).[keys](LinkedSet.md#keys) - -#### Defined in - -[src/LinkedList.ts:191](https://github.com/zimmed/prefab/blob/a5ffdd1/src/LinkedList.ts#L191) - -___ - -### map - -▸ **map**<`RT`\>(`cb`): `RT`[] - -Maps set items into a new array - -#### Type parameters - -| Name | -| :------ | -| `RT` | - -#### Parameters - -| Name | Type | -| :------ | :------ | -| `cb` | `Callback`<`T`, [`SortedSet`](SortedSet.md)<`T`, `N`\>, `RT`, [`SortedSet`](SortedSet.md)<`T`, `N`\>\> | - -#### Returns - -`RT`[] - -#### Inherited from - -[LinkedSet](LinkedSet.md).[map](LinkedSet.md#map) - -#### Defined in - -[src/LinkedSet.ts:103](https://github.com/zimmed/prefab/blob/a5ffdd1/src/LinkedSet.ts#L103) - -▸ **map**<`RT`, `This`\>(`cb`, `thisArg`): `RT`[] - -#### Type parameters - -| Name | -| :------ | -| `RT` | -| `This` | - -#### Parameters - -| Name | Type | -| :------ | :------ | -| `cb` | `Callback`<`T`, `This`, `RT`, [`SortedSet`](SortedSet.md)<`T`, `N`\>\> | -| `thisArg` | `This` | - -#### Returns - -`RT`[] - -#### Inherited from - -[LinkedSet](LinkedSet.md).[map](LinkedSet.md#map) - -#### Defined in - -[src/LinkedSet.ts:104](https://github.com/zimmed/prefab/blob/a5ffdd1/src/LinkedSet.ts#L104) - -___ - -### pop - -▸ **pop**(): `undefined` \| `T` - -Pops item from end of the set - -#### Returns - -`undefined` \| `T` - -#### Overrides - -[LinkedSet](LinkedSet.md).[pop](LinkedSet.md#pop) - -#### Defined in - -[src/SortedSet.ts:72](https://github.com/zimmed/prefab/blob/a5ffdd1/src/SortedSet.ts#L72) - -___ - -### recycle - -▸ **recycle**(): [`SortedSet`](SortedSet.md)<`T`, `N`\> - -Moves element from front of list to the end - -#### Returns - -[`SortedSet`](SortedSet.md)<`T`, `N`\> - -#### Inherited from - -[LinkedSet](LinkedSet.md).[recycle](LinkedSet.md#recycle) - -#### Defined in - -[src/LinkedList.ts:132](https://github.com/zimmed/prefab/blob/a5ffdd1/src/LinkedList.ts#L132) - -___ - -### reduce - -▸ **reduce**<`RT`\>(`cb`, `initialValue`): `RT` - -Reduces list into specified value (same signature as Array.prototype.reduce) - -#### Type parameters - -| Name | -| :------ | -| `RT` | - -#### Parameters - -| Name | Type | -| :------ | :------ | -| `cb` | `Reducer`<`T`, [`SortedSet`](SortedSet.md)<`T`, `N`\>, `RT`, [`SortedSet`](SortedSet.md)<`T`, `N`\>\> | -| `initialValue` | `RT` | - -#### Returns - -`RT` - -#### Inherited from - -[LinkedSet](LinkedSet.md).[reduce](LinkedSet.md#reduce) - -#### Defined in - -[src/LinkedList.ts:248](https://github.com/zimmed/prefab/blob/a5ffdd1/src/LinkedList.ts#L248) - -▸ **reduce**<`RT`, `This`\>(`cb`, `initialValue`, `thisArg?`): `RT` - -#### Type parameters - -| Name | -| :------ | -| `RT` | -| `This` | - -#### Parameters - -| Name | Type | -| :------ | :------ | -| `cb` | `Reducer`<`T`, `This`, `RT`, [`SortedSet`](SortedSet.md)<`T`, `N`\>\> | -| `initialValue` | `RT` | -| `thisArg?` | `This` | - -#### Returns - -`RT` - -#### Inherited from - -[LinkedSet](LinkedSet.md).[reduce](LinkedSet.md#reduce) - -#### Defined in - -[src/LinkedList.ts:249](https://github.com/zimmed/prefab/blob/a5ffdd1/src/LinkedList.ts#L249) - -___ - -### reduceRight - -▸ **reduceRight**<`RT`\>(`cb`, `initialValue`): `RT` - -Reduces items from the end of the set to the front - -#### Type parameters - -| Name | -| :------ | -| `RT` | - -#### Parameters - -| Name | Type | -| :------ | :------ | -| `cb` | `Reducer`<`T`, [`SortedSet`](SortedSet.md)<`T`, `N`\>, `RT`, [`SortedSet`](SortedSet.md)<`T`, `N`\>\> | -| `initialValue` | `RT` | - -#### Returns - -`RT` - -#### Inherited from - -[LinkedSet](LinkedSet.md).[reduceRight](LinkedSet.md#reduceright) - -#### Defined in - -[src/LinkedSet.ts:76](https://github.com/zimmed/prefab/blob/a5ffdd1/src/LinkedSet.ts#L76) - -▸ **reduceRight**<`RT`, `This`\>(`cb`, `initialValue`, `thisArg?`): `RT` - -#### Type parameters - -| Name | -| :------ | -| `RT` | -| `This` | - -#### Parameters - -| Name | Type | -| :------ | :------ | -| `cb` | `Reducer`<`T`, `This`, `RT`, [`SortedSet`](SortedSet.md)<`T`, `N`\>\> | -| `initialValue` | `RT` | -| `thisArg?` | `This` | - -#### Returns - -`RT` - -#### Inherited from - -[LinkedSet](LinkedSet.md).[reduceRight](LinkedSet.md#reduceright) - -#### Defined in - -[src/LinkedSet.ts:77](https://github.com/zimmed/prefab/blob/a5ffdd1/src/LinkedSet.ts#L77) - -___ - -### reverse - -▸ **reverse**(): `IterableIterator`<`T`\> - -Iterates through list items in reverse - -#### Returns - -`IterableIterator`<`T`\> - -#### Inherited from - -[LinkedSet](LinkedSet.md).[reverse](LinkedSet.md#reverse) - -#### Defined in - -[src/LinkedList.ts:217](https://github.com/zimmed/prefab/blob/a5ffdd1/src/LinkedList.ts#L217) - -___ - -### reverseMap - -▸ **reverseMap**<`RT`\>(`cb`): `RT`[] - -Maps set items from the end of the set to the front into a new array - -#### Type parameters - -| Name | -| :------ | -| `RT` | - -#### Parameters - -| Name | Type | -| :------ | :------ | -| `cb` | `Callback`<`T`, [`SortedSet`](SortedSet.md)<`T`, `N`\>, `RT`, [`SortedSet`](SortedSet.md)<`T`, `N`\>\> | - -#### Returns - -`RT`[] - -#### Inherited from - -[LinkedSet](LinkedSet.md).[reverseMap](LinkedSet.md#reversemap) - -#### Defined in - -[src/LinkedSet.ts:111](https://github.com/zimmed/prefab/blob/a5ffdd1/src/LinkedSet.ts#L111) - -▸ **reverseMap**<`RT`, `This`\>(`cb`, `thisArg`): `RT`[] - -#### Type parameters - -| Name | -| :------ | -| `RT` | -| `This` | - -#### Parameters - -| Name | Type | -| :------ | :------ | -| `cb` | `Callback`<`T`, `This`, `RT`, [`SortedSet`](SortedSet.md)<`T`, `N`\>\> | -| `thisArg` | `This` | - -#### Returns - -`RT`[] - -#### Inherited from - -[LinkedSet](LinkedSet.md).[reverseMap](LinkedSet.md#reversemap) - -#### Defined in - -[src/LinkedSet.ts:112](https://github.com/zimmed/prefab/blob/a5ffdd1/src/LinkedSet.ts#L112) - -___ - -### search - -▸ **search**(`compareFunction`, `node?`): `undefined` \| `T` - -Searches set using compare function to find first match - -#### Parameters - -| Name | Type | Description | -| :------ | :------ | :------ | -| `compareFunction` | (`a`: `T`) => `number` | Takes an item from the set and returns 0 if a match, -1 (<0) if the desired match is lower in the sort order (closer to the front of the list), or 1 (>0) if the desired match is higher (towards the end of the list) | -| `node` | `undefined` \| `TNode`<`T`\> | - | - -#### Returns - -`undefined` \| `T` - -#### Defined in - -[src/SortedSet.ts:52](https://github.com/zimmed/prefab/blob/a5ffdd1/src/SortedSet.ts#L52) - -___ - -### shift - -▸ **shift**(): `undefined` \| `T` - -Shifts item from the front of the set - -#### Returns - -`undefined` \| `T` - -#### Overrides - -[LinkedSet](LinkedSet.md).[shift](LinkedSet.md#shift) - -#### Defined in - -[src/SortedSet.ts:83](https://github.com/zimmed/prefab/blob/a5ffdd1/src/SortedSet.ts#L83) - -___ - -### tailNode - -▸ **tailNode**(`node`): [`SortedSet`](SortedSet.md)<`T`, `N`\> - -Caution: Assumes node is already part of linked list -Moves node to the end of the list - -#### Parameters - -| Name | Type | -| :------ | :------ | -| `node` | `N` | - -#### Returns - -[`SortedSet`](SortedSet.md)<`T`, `N`\> - -#### Inherited from - -[LinkedSet](LinkedSet.md).[tailNode](LinkedSet.md#tailnode) - -#### Defined in - -[src/LinkedList.ts:155](https://github.com/zimmed/prefab/blob/a5ffdd1/src/LinkedList.ts#L155) - -___ - -### toArray - -▸ **toArray**(): `T`[] - -Converts list to native Array - -#### Returns - -`T`[] - -#### Inherited from - -[LinkedSet](LinkedSet.md).[toArray](LinkedSet.md#toarray) - -#### Defined in - -[src/LinkedList.ts:179](https://github.com/zimmed/prefab/blob/a5ffdd1/src/LinkedList.ts#L179) - -___ - -### toJSON - -▸ **toJSON**(): `T`[] - -#### Returns - -`T`[] - -#### Inherited from - -[LinkedSet](LinkedSet.md).[toJSON](LinkedSet.md#tojson) - -#### Defined in - -[src/LinkedList.ts:387](https://github.com/zimmed/prefab/blob/a5ffdd1/src/LinkedList.ts#L387) - -___ - -### unshift - -▸ **unshift**(`item`): [`SortedSet`](SortedSet.md)<`T`, `N`\> - -Alias for insert - -#### Parameters - -| Name | Type | -| :------ | :------ | -| `item` | `T` | - -#### Returns - -[`SortedSet`](SortedSet.md)<`T`, `N`\> - -#### Inherited from - -[LinkedSet](LinkedSet.md).[unshift](LinkedSet.md#unshift) - -#### Defined in - -[src/LinkedList.ts:117](https://github.com/zimmed/prefab/blob/a5ffdd1/src/LinkedList.ts#L117) - -___ - -### values - -▸ **values**(): `IterableIterator`<`T`\> - -Iterates through list items - -#### Returns - -`IterableIterator`<`T`\> - -#### Inherited from - -[LinkedSet](LinkedSet.md).[values](LinkedSet.md#values) - -#### Defined in - -[src/LinkedList.ts:207](https://github.com/zimmed/prefab/blob/a5ffdd1/src/LinkedList.ts#L207) - -___ - -### create - -▸ `Static` **create**<`T`\>(`iterable?`, `compareFunction?`): [`SortedSet`](SortedSet.md)<`T`, `LNode`<`T`\>\> - -Static factory method as alias for class constructor - -#### Type parameters - -| Name | -| :------ | -| `T` | - -#### Parameters - -| Name | Type | -| :------ | :------ | -| `iterable?` | `IterableIterator`<`T`\> \| `T`[] \| `Generator`<`T`, `void`, `unknown`\> | -| `compareFunction?` | `Sort`<`T`, `any`\> | - -#### Returns - -[`SortedSet`](SortedSet.md)<`T`, `LNode`<`T`\>\> - -#### Overrides - -[LinkedSet](LinkedSet.md).[create](LinkedSet.md#create) - -#### Defined in - -[src/SortedSet.ts:19](https://github.com/zimmed/prefab/blob/a5ffdd1/src/SortedSet.ts#L19) - -___ - -### from - -▸ `Static` **from**<`T`\>(`iterable`, `compareFunction?`): [`SortedSet`](SortedSet.md)<`T`, `LNode`<`T`\>\> - -Same as LinkedList.create() but requires constructor arg - -#### Type parameters - -| Name | -| :------ | -| `T` | - -#### Parameters - -| Name | Type | -| :------ | :------ | -| `iterable` | `IterableIterator`<`T`\> \| `T`[] \| `Generator`<`T`, `void`, `unknown`\> | -| `compareFunction?` | `Sort`<`T`, `any`\> | - -#### Returns - -[`SortedSet`](SortedSet.md)<`T`, `LNode`<`T`\>\> - -#### Overrides - -[LinkedSet](LinkedSet.md).[from](LinkedSet.md#from) - -#### Defined in - -[src/SortedSet.ts:27](https://github.com/zimmed/prefab/blob/a5ffdd1/src/SortedSet.ts#L27) diff --git a/docs/classes/UniQueue.md b/docs/classes/UniQueue.md deleted file mode 100644 index 573173f..0000000 --- a/docs/classes/UniQueue.md +++ /dev/null @@ -1,1335 +0,0 @@ -[@zimmed/prefab](../README.md) / [Exports](../modules.md) / UniQueue - -# Class: UniQueue - -## Type parameters - -| Name | -| :------ | -| `T` | - -## Hierarchy - -- [`LinkedSet`](LinkedSet.md)<`T`\> - - ↳ **`UniQueue`** - -## Table of contents - -### Constructors - -- [constructor](UniQueue.md#constructor) - -### Properties - -- [\_head](UniQueue.md#_head) -- [\_map](UniQueue.md#_map) -- [\_tail](UniQueue.md#_tail) -- [\_type](UniQueue.md#_type) -- [Type](UniQueue.md#type) - -### Accessors - -- [head](UniQueue.md#head) -- [size](UniQueue.md#size) -- [tail](UniQueue.md#tail) - -### Methods - -- [[iterator]](UniQueue.md#[iterator]) -- [add](UniQueue.md#add) -- [addNode](UniQueue.md#addnode) -- [append](UniQueue.md#append) -- [clear](UniQueue.md#clear) -- [cycle](UniQueue.md#cycle) -- [delete](UniQueue.md#delete) -- [deleteNode](UniQueue.md#deletenode) -- [dequeue](UniQueue.md#dequeue) -- [enqueue](UniQueue.md#enqueue) -- [entries](UniQueue.md#entries) -- [filter](UniQueue.md#filter) -- [find](UniQueue.md#find) -- [findRight](UniQueue.md#findright) -- [forEach](UniQueue.md#foreach) -- [has](UniQueue.md#has) -- [headNode](UniQueue.md#headnode) -- [insert](UniQueue.md#insert) -- [insertNode](UniQueue.md#insertnode) -- [join](UniQueue.md#join) -- [keys](UniQueue.md#keys) -- [map](UniQueue.md#map) -- [pop](UniQueue.md#pop) -- [recycle](UniQueue.md#recycle) -- [reduce](UniQueue.md#reduce) -- [reduceRight](UniQueue.md#reduceright) -- [reverse](UniQueue.md#reverse) -- [reverseMap](UniQueue.md#reversemap) -- [shift](UniQueue.md#shift) -- [tailNode](UniQueue.md#tailnode) -- [toArray](UniQueue.md#toarray) -- [toJSON](UniQueue.md#tojson) -- [unshift](UniQueue.md#unshift) -- [values](UniQueue.md#values) -- [create](UniQueue.md#create) -- [from](UniQueue.md#from) - -## Constructors - -### constructor - -• **new UniQueue**<`T`\>(`iterable?`, `type?`) - -#### Type parameters - -| Name | -| :------ | -| `T` | - -#### Parameters - -| Name | Type | Default value | -| :------ | :------ | :------ | -| `iterable?` | `IterableIterator`<`T`\> \| `T`[] \| `Generator`<`T`, `void`, `unknown`\> | `undefined` | -| `type` | `Type` | `Type.FIFO` | - -#### Overrides - -[LinkedSet](LinkedSet.md).[constructor](LinkedSet.md#constructor) - -#### Defined in - -[src/UniQueue.ts:31](https://github.com/zimmed/prefab/blob/a5ffdd1/src/UniQueue.ts#L31) - -## Properties - -### \_head - -• `Protected` `Optional` **\_head**: `LNode`<`T`\> - -#### Inherited from - -[LinkedSet](LinkedSet.md).[_head](LinkedSet.md#_head) - -#### Defined in - -[src/LinkedList.ts:30](https://github.com/zimmed/prefab/blob/a5ffdd1/src/LinkedList.ts#L30) - -___ - -### \_map - -• `Protected` `Readonly` **\_map**: `Map`<`T`, `LNode`<`T`\>\> - -#### Inherited from - -[LinkedSet](LinkedSet.md).[_map](LinkedSet.md#_map) - -#### Defined in - -[src/LinkedSet.ts:7](https://github.com/zimmed/prefab/blob/a5ffdd1/src/LinkedSet.ts#L7) - -___ - -### \_tail - -• `Protected` `Optional` **\_tail**: `LNode`<`T`\> - -#### Inherited from - -[LinkedSet](LinkedSet.md).[_tail](LinkedSet.md#_tail) - -#### Defined in - -[src/LinkedList.ts:33](https://github.com/zimmed/prefab/blob/a5ffdd1/src/LinkedList.ts#L33) - -___ - -### \_type - -• `Protected` `Readonly` **\_type**: `Type` - -#### Defined in - -[src/UniQueue.ts:29](https://github.com/zimmed/prefab/blob/a5ffdd1/src/UniQueue.ts#L29) - -___ - -### Type - -▪ `Static` **Type**: typeof `Type` = `Type` - -#### Defined in - -[src/UniQueue.ts:10](https://github.com/zimmed/prefab/blob/a5ffdd1/src/UniQueue.ts#L10) - -## Accessors - -### head - -• `get` **head**(): `undefined` \| `T` - -Item at head of the list - -#### Returns - -`undefined` \| `T` - -#### Inherited from - -LinkedSet.head - -#### Defined in - -[src/LinkedList.ts:36](https://github.com/zimmed/prefab/blob/a5ffdd1/src/LinkedList.ts#L36) - -___ - -### size - -• `get` **size**(): `number` - -Current size of set - -#### Returns - -`number` - -#### Inherited from - -LinkedSet.size - -#### Defined in - -[src/LinkedSet.ts:10](https://github.com/zimmed/prefab/blob/a5ffdd1/src/LinkedSet.ts#L10) - -___ - -### tail - -• `get` **tail**(): `undefined` \| `T` - -Item at tail of the list - -#### Returns - -`undefined` \| `T` - -#### Inherited from - -LinkedSet.tail - -#### Defined in - -[src/LinkedList.ts:40](https://github.com/zimmed/prefab/blob/a5ffdd1/src/LinkedList.ts#L40) - -## Methods - -### [iterator] - -▸ **[iterator]**(): `IterableIterator`<`T`\> - -#### Returns - -`IterableIterator`<`T`\> - -#### Inherited from - -[LinkedSet](LinkedSet.md).[[iterator]](LinkedSet.md#[iterator]) - -#### Defined in - -[src/LinkedList.ts:391](https://github.com/zimmed/prefab/blob/a5ffdd1/src/LinkedList.ts#L391) - -___ - -### add - -▸ **add**(`item`): [`UniQueue`](UniQueue.md)<`T`\> - -Appends unique item to end of the collection - -#### Parameters - -| Name | Type | -| :------ | :------ | -| `item` | `T` | - -#### Returns - -[`UniQueue`](UniQueue.md)<`T`\> - -#### Inherited from - -[LinkedSet](LinkedSet.md).[add](LinkedSet.md#add) - -#### Defined in - -[src/LinkedSet.ts:41](https://github.com/zimmed/prefab/blob/a5ffdd1/src/LinkedSet.ts#L41) - -___ - -### addNode - -▸ **addNode**(`node`): [`UniQueue`](UniQueue.md)<`T`\> - -Caution: Assumes node already has correct head and tail set -Adds node to the end of the list - -#### Parameters - -| Name | Type | -| :------ | :------ | -| `node` | `LNode`<`T`\> | - -#### Returns - -[`UniQueue`](UniQueue.md)<`T`\> - -#### Inherited from - -[LinkedSet](LinkedSet.md).[addNode](LinkedSet.md#addnode) - -#### Defined in - -[src/LinkedList.ts:367](https://github.com/zimmed/prefab/blob/a5ffdd1/src/LinkedList.ts#L367) - -___ - -### append - -▸ **append**(`item`): [`UniQueue`](UniQueue.md)<`T`\> - -Adds item to end of the list - -#### Parameters - -| Name | Type | -| :------ | :------ | -| `item` | `T` | - -#### Returns - -[`UniQueue`](UniQueue.md)<`T`\> - -#### Inherited from - -[LinkedSet](LinkedSet.md).[append](LinkedSet.md#append) - -#### Defined in - -[src/LinkedList.ts:107](https://github.com/zimmed/prefab/blob/a5ffdd1/src/LinkedList.ts#L107) - -___ - -### clear - -▸ **clear**(): `void` - -Clears set - -#### Returns - -`void` - -#### Inherited from - -[LinkedSet](LinkedSet.md).[clear](LinkedSet.md#clear) - -#### Defined in - -[src/LinkedSet.ts:70](https://github.com/zimmed/prefab/blob/a5ffdd1/src/LinkedSet.ts#L70) - -___ - -### cycle - -▸ **cycle**(): [`UniQueue`](UniQueue.md)<`T`\> - -Moves element from end of list to the front - -#### Returns - -[`UniQueue`](UniQueue.md)<`T`\> - -#### Inherited from - -[LinkedSet](LinkedSet.md).[cycle](LinkedSet.md#cycle) - -#### Defined in - -[src/LinkedList.ts:127](https://github.com/zimmed/prefab/blob/a5ffdd1/src/LinkedList.ts#L127) - -___ - -### delete - -▸ **delete**(`item`): `boolean` - -Removes specified item from the set - -#### Parameters - -| Name | Type | -| :------ | :------ | -| `item` | `T` | - -#### Returns - -`boolean` - -#### Inherited from - -[LinkedSet](LinkedSet.md).[delete](LinkedSet.md#delete) - -#### Defined in - -[src/LinkedSet.ts:61](https://github.com/zimmed/prefab/blob/a5ffdd1/src/LinkedSet.ts#L61) - -___ - -### deleteNode - -▸ **deleteNode**(`cur?`): `boolean` - -Removes specified node from the list - -#### Parameters - -| Name | Type | -| :------ | :------ | -| `cur?` | `LNode`<`T`\> | - -#### Returns - -`boolean` - -#### Inherited from - -[LinkedSet](LinkedSet.md).[deleteNode](LinkedSet.md#deletenode) - -#### Defined in - -[src/LinkedList.ts:376](https://github.com/zimmed/prefab/blob/a5ffdd1/src/LinkedList.ts#L376) - -___ - -### dequeue - -▸ **dequeue**(): `undefined` \| `T` - -Shift item from front of front of Queue if type is FIFO, otherwise pop from end of Queue (LIFO) - -#### Returns - -`undefined` \| `T` - -#### Defined in - -[src/UniQueue.ts:45](https://github.com/zimmed/prefab/blob/a5ffdd1/src/UniQueue.ts#L45) - -___ - -### enqueue - -▸ **enqueue**(`item`): `void` - -Append item to Queue - -#### Parameters - -| Name | Type | -| :------ | :------ | -| `item` | `T` | - -#### Returns - -`void` - -#### Defined in - -[src/UniQueue.ts:40](https://github.com/zimmed/prefab/blob/a5ffdd1/src/UniQueue.ts#L40) - -___ - -### entries - -▸ **entries**(): `IterableIterator`<[`T`, `T`]\> - -Kind of pointless, but needed for parity with builtin Set object - -#### Returns - -`IterableIterator`<[`T`, `T`]\> - -#### Inherited from - -[LinkedSet](LinkedSet.md).[entries](LinkedSet.md#entries) - -#### Defined in - -[src/LinkedList.ts:196](https://github.com/zimmed/prefab/blob/a5ffdd1/src/LinkedList.ts#L196) - -___ - -### filter - -▸ **filter**(`predicate`): `T`[] - -Uses predicate to return a new array of all matching items (same signature is Array.protoype.filter) - -#### Parameters - -| Name | Type | -| :------ | :------ | -| `predicate` | `Callback`<`T`, [`UniQueue`](UniQueue.md)<`T`\>, `boolean`, [`UniQueue`](UniQueue.md)<`T`\>\> | - -#### Returns - -`T`[] - -#### Inherited from - -[LinkedSet](LinkedSet.md).[filter](LinkedSet.md#filter) - -#### Defined in - -[src/LinkedList.ts:295](https://github.com/zimmed/prefab/blob/a5ffdd1/src/LinkedList.ts#L295) - -▸ **filter**<`This`\>(`predicate`, `thisArg`): `T`[] - -#### Type parameters - -| Name | -| :------ | -| `This` | - -#### Parameters - -| Name | Type | -| :------ | :------ | -| `predicate` | `Callback`<`T`, `This`, `boolean`, [`UniQueue`](UniQueue.md)<`T`\>\> | -| `thisArg` | `This` | - -#### Returns - -`T`[] - -#### Inherited from - -[LinkedSet](LinkedSet.md).[filter](LinkedSet.md#filter) - -#### Defined in - -[src/LinkedList.ts:296](https://github.com/zimmed/prefab/blob/a5ffdd1/src/LinkedList.ts#L296) - -___ - -### find - -▸ **find**(`predicate`): `undefined` \| `T` - -Uses predicate to return first matching item or undefined if no matches (same signature as Array.prototype.find) - -#### Parameters - -| Name | Type | -| :------ | :------ | -| `predicate` | `Callback`<`T`, [`UniQueue`](UniQueue.md)<`T`\>, `boolean`, [`UniQueue`](UniQueue.md)<`T`\>\> | - -#### Returns - -`undefined` \| `T` - -#### Inherited from - -[LinkedSet](LinkedSet.md).[find](LinkedSet.md#find) - -#### Defined in - -[src/LinkedList.ts:269](https://github.com/zimmed/prefab/blob/a5ffdd1/src/LinkedList.ts#L269) - -▸ **find**<`This`\>(`predicate`, `thisArg`): `undefined` \| `T` - -#### Type parameters - -| Name | -| :------ | -| `This` | - -#### Parameters - -| Name | Type | -| :------ | :------ | -| `predicate` | `Callback`<`T`, `This`, `boolean`, [`UniQueue`](UniQueue.md)<`T`\>\> | -| `thisArg` | `This` | - -#### Returns - -`undefined` \| `T` - -#### Inherited from - -[LinkedSet](LinkedSet.md).[find](LinkedSet.md#find) - -#### Defined in - -[src/LinkedList.ts:270](https://github.com/zimmed/prefab/blob/a5ffdd1/src/LinkedList.ts#L270) - -___ - -### findRight - -▸ **findRight**(`predicate`): `undefined` \| `T` - -Finds predicate-matching item, with iteration beginning at the end of the set - -#### Parameters - -| Name | Type | -| :------ | :------ | -| `predicate` | `Callback`<`T`, [`UniQueue`](UniQueue.md)<`T`\>, `boolean`, [`UniQueue`](UniQueue.md)<`T`\>\> | - -#### Returns - -`undefined` \| `T` - -#### Inherited from - -[LinkedSet](LinkedSet.md).[findRight](LinkedSet.md#findright) - -#### Defined in - -[src/LinkedSet.ts:92](https://github.com/zimmed/prefab/blob/a5ffdd1/src/LinkedSet.ts#L92) - -▸ **findRight**<`This`\>(`predicate`, `thisArg`): `undefined` \| `T` - -#### Type parameters - -| Name | -| :------ | -| `This` | - -#### Parameters - -| Name | Type | -| :------ | :------ | -| `predicate` | `Callback`<`T`, `This`, `boolean`, [`UniQueue`](UniQueue.md)<`T`\>\> | -| `thisArg` | `This` | - -#### Returns - -`undefined` \| `T` - -#### Inherited from - -[LinkedSet](LinkedSet.md).[findRight](LinkedSet.md#findright) - -#### Defined in - -[src/LinkedSet.ts:93](https://github.com/zimmed/prefab/blob/a5ffdd1/src/LinkedSet.ts#L93) - -___ - -### forEach - -▸ **forEach**(`cb`): `void` - -Operates on each element of the list in a callback method (same signature as Array.prototype.forEach) - -#### Parameters - -| Name | Type | -| :------ | :------ | -| `cb` | `Callback`<`T`, [`UniQueue`](UniQueue.md)<`T`\>, `void`, [`UniQueue`](UniQueue.md)<`T`\>\> | - -#### Returns - -`void` - -#### Inherited from - -[LinkedSet](LinkedSet.md).[forEach](LinkedSet.md#foreach) - -#### Defined in - -[src/LinkedList.ts:227](https://github.com/zimmed/prefab/blob/a5ffdd1/src/LinkedList.ts#L227) - -▸ **forEach**<`ThisArg`\>(`cb`, `thisArg?`): `void` - -#### Type parameters - -| Name | -| :------ | -| `ThisArg` | - -#### Parameters - -| Name | Type | -| :------ | :------ | -| `cb` | `Callback`<`T`, `ThisArg`, `void`, [`UniQueue`](UniQueue.md)<`T`\>\> | -| `thisArg?` | `ThisArg` | - -#### Returns - -`void` - -#### Inherited from - -[LinkedSet](LinkedSet.md).[forEach](LinkedSet.md#foreach) - -#### Defined in - -[src/LinkedList.ts:228](https://github.com/zimmed/prefab/blob/a5ffdd1/src/LinkedList.ts#L228) - -___ - -### has - -▸ **has**(`item`): `boolean` - -Determines if set contains specified item - -#### Parameters - -| Name | Type | -| :------ | :------ | -| `item` | `T` | - -#### Returns - -`boolean` - -#### Inherited from - -[LinkedSet](LinkedSet.md).[has](LinkedSet.md#has) - -#### Defined in - -[src/LinkedSet.ts:36](https://github.com/zimmed/prefab/blob/a5ffdd1/src/LinkedSet.ts#L36) - -___ - -### headNode - -▸ **headNode**(`node`): [`UniQueue`](UniQueue.md)<`T`\> - -Caution: Assumes node is already part of linked list -Moves node to the front of the list - -#### Parameters - -| Name | Type | -| :------ | :------ | -| `node` | `LNode`<`T`\> | - -#### Returns - -[`UniQueue`](UniQueue.md)<`T`\> - -#### Inherited from - -[LinkedSet](LinkedSet.md).[headNode](LinkedSet.md#headnode) - -#### Defined in - -[src/LinkedList.ts:140](https://github.com/zimmed/prefab/blob/a5ffdd1/src/LinkedList.ts#L140) - -___ - -### insert - -▸ **insert**(`item`): [`UniQueue`](UniQueue.md)<`T`\> - -Inserts unique item into the front of the collection - -#### Parameters - -| Name | Type | -| :------ | :------ | -| `item` | `T` | - -#### Returns - -[`UniQueue`](UniQueue.md)<`T`\> - -#### Inherited from - -[LinkedSet](LinkedSet.md).[insert](LinkedSet.md#insert) - -#### Defined in - -[src/LinkedSet.ts:51](https://github.com/zimmed/prefab/blob/a5ffdd1/src/LinkedSet.ts#L51) - -___ - -### insertNode - -▸ **insertNode**(`node`): [`UniQueue`](UniQueue.md)<`T`\> - -Caution: Assumes node already has correct head and tail set -Adds node to the front of the list - -#### Parameters - -| Name | Type | -| :------ | :------ | -| `node` | `LNode`<`T`\> | - -#### Returns - -[`UniQueue`](UniQueue.md)<`T`\> - -#### Inherited from - -[LinkedSet](LinkedSet.md).[insertNode](LinkedSet.md#insertnode) - -#### Defined in - -[src/LinkedList.ts:355](https://github.com/zimmed/prefab/blob/a5ffdd1/src/LinkedList.ts#L355) - -___ - -### join - -▸ **join**(`separator?`): `string` - -Joins list elements into one string (same signature as Array.prototype.join) - -#### Parameters - -| Name | Type | -| :------ | :------ | -| `separator?` | `string` | - -#### Returns - -`string` - -#### Inherited from - -[LinkedSet](LinkedSet.md).[join](LinkedSet.md#join) - -#### Defined in - -[src/LinkedList.ts:347](https://github.com/zimmed/prefab/blob/a5ffdd1/src/LinkedList.ts#L347) - -___ - -### keys - -▸ **keys**(): `IterableIterator`<`T`\> - -Alias for values() method - -#### Returns - -`IterableIterator`<`T`\> - -#### Inherited from - -[LinkedSet](LinkedSet.md).[keys](LinkedSet.md#keys) - -#### Defined in - -[src/LinkedList.ts:191](https://github.com/zimmed/prefab/blob/a5ffdd1/src/LinkedList.ts#L191) - -___ - -### map - -▸ **map**<`RT`\>(`cb`): `RT`[] - -Maps set items into a new array - -#### Type parameters - -| Name | -| :------ | -| `RT` | - -#### Parameters - -| Name | Type | -| :------ | :------ | -| `cb` | `Callback`<`T`, [`UniQueue`](UniQueue.md)<`T`\>, `RT`, [`UniQueue`](UniQueue.md)<`T`\>\> | - -#### Returns - -`RT`[] - -#### Inherited from - -[LinkedSet](LinkedSet.md).[map](LinkedSet.md#map) - -#### Defined in - -[src/LinkedSet.ts:103](https://github.com/zimmed/prefab/blob/a5ffdd1/src/LinkedSet.ts#L103) - -▸ **map**<`RT`, `This`\>(`cb`, `thisArg`): `RT`[] - -#### Type parameters - -| Name | -| :------ | -| `RT` | -| `This` | - -#### Parameters - -| Name | Type | -| :------ | :------ | -| `cb` | `Callback`<`T`, `This`, `RT`, [`UniQueue`](UniQueue.md)<`T`\>\> | -| `thisArg` | `This` | - -#### Returns - -`RT`[] - -#### Inherited from - -[LinkedSet](LinkedSet.md).[map](LinkedSet.md#map) - -#### Defined in - -[src/LinkedSet.ts:104](https://github.com/zimmed/prefab/blob/a5ffdd1/src/LinkedSet.ts#L104) - -___ - -### pop - -▸ **pop**(): `undefined` \| `T` - -Pops item from the end of the set - -#### Returns - -`undefined` \| `T` - -#### Inherited from - -[LinkedSet](LinkedSet.md).[pop](LinkedSet.md#pop) - -#### Defined in - -[src/LinkedSet.ts:15](https://github.com/zimmed/prefab/blob/a5ffdd1/src/LinkedSet.ts#L15) - -___ - -### recycle - -▸ **recycle**(): [`UniQueue`](UniQueue.md)<`T`\> - -Moves element from front of list to the end - -#### Returns - -[`UniQueue`](UniQueue.md)<`T`\> - -#### Inherited from - -[LinkedSet](LinkedSet.md).[recycle](LinkedSet.md#recycle) - -#### Defined in - -[src/LinkedList.ts:132](https://github.com/zimmed/prefab/blob/a5ffdd1/src/LinkedList.ts#L132) - -___ - -### reduce - -▸ **reduce**<`RT`\>(`cb`, `initialValue`): `RT` - -Reduces list into specified value (same signature as Array.prototype.reduce) - -#### Type parameters - -| Name | -| :------ | -| `RT` | - -#### Parameters - -| Name | Type | -| :------ | :------ | -| `cb` | `Reducer`<`T`, [`UniQueue`](UniQueue.md)<`T`\>, `RT`, [`UniQueue`](UniQueue.md)<`T`\>\> | -| `initialValue` | `RT` | - -#### Returns - -`RT` - -#### Inherited from - -[LinkedSet](LinkedSet.md).[reduce](LinkedSet.md#reduce) - -#### Defined in - -[src/LinkedList.ts:248](https://github.com/zimmed/prefab/blob/a5ffdd1/src/LinkedList.ts#L248) - -▸ **reduce**<`RT`, `This`\>(`cb`, `initialValue`, `thisArg?`): `RT` - -#### Type parameters - -| Name | -| :------ | -| `RT` | -| `This` | - -#### Parameters - -| Name | Type | -| :------ | :------ | -| `cb` | `Reducer`<`T`, `This`, `RT`, [`UniQueue`](UniQueue.md)<`T`\>\> | -| `initialValue` | `RT` | -| `thisArg?` | `This` | - -#### Returns - -`RT` - -#### Inherited from - -[LinkedSet](LinkedSet.md).[reduce](LinkedSet.md#reduce) - -#### Defined in - -[src/LinkedList.ts:249](https://github.com/zimmed/prefab/blob/a5ffdd1/src/LinkedList.ts#L249) - -___ - -### reduceRight - -▸ **reduceRight**<`RT`\>(`cb`, `initialValue`): `RT` - -Reduces items from the end of the set to the front - -#### Type parameters - -| Name | -| :------ | -| `RT` | - -#### Parameters - -| Name | Type | -| :------ | :------ | -| `cb` | `Reducer`<`T`, [`UniQueue`](UniQueue.md)<`T`\>, `RT`, [`UniQueue`](UniQueue.md)<`T`\>\> | -| `initialValue` | `RT` | - -#### Returns - -`RT` - -#### Inherited from - -[LinkedSet](LinkedSet.md).[reduceRight](LinkedSet.md#reduceright) - -#### Defined in - -[src/LinkedSet.ts:76](https://github.com/zimmed/prefab/blob/a5ffdd1/src/LinkedSet.ts#L76) - -▸ **reduceRight**<`RT`, `This`\>(`cb`, `initialValue`, `thisArg?`): `RT` - -#### Type parameters - -| Name | -| :------ | -| `RT` | -| `This` | - -#### Parameters - -| Name | Type | -| :------ | :------ | -| `cb` | `Reducer`<`T`, `This`, `RT`, [`UniQueue`](UniQueue.md)<`T`\>\> | -| `initialValue` | `RT` | -| `thisArg?` | `This` | - -#### Returns - -`RT` - -#### Inherited from - -[LinkedSet](LinkedSet.md).[reduceRight](LinkedSet.md#reduceright) - -#### Defined in - -[src/LinkedSet.ts:77](https://github.com/zimmed/prefab/blob/a5ffdd1/src/LinkedSet.ts#L77) - -___ - -### reverse - -▸ **reverse**(): `IterableIterator`<`T`\> - -Iterates through list items in reverse - -#### Returns - -`IterableIterator`<`T`\> - -#### Inherited from - -[LinkedSet](LinkedSet.md).[reverse](LinkedSet.md#reverse) - -#### Defined in - -[src/LinkedList.ts:217](https://github.com/zimmed/prefab/blob/a5ffdd1/src/LinkedList.ts#L217) - -___ - -### reverseMap - -▸ **reverseMap**<`RT`\>(`cb`): `RT`[] - -Maps set items from the end of the set to the front into a new array - -#### Type parameters - -| Name | -| :------ | -| `RT` | - -#### Parameters - -| Name | Type | -| :------ | :------ | -| `cb` | `Callback`<`T`, [`UniQueue`](UniQueue.md)<`T`\>, `RT`, [`UniQueue`](UniQueue.md)<`T`\>\> | - -#### Returns - -`RT`[] - -#### Inherited from - -[LinkedSet](LinkedSet.md).[reverseMap](LinkedSet.md#reversemap) - -#### Defined in - -[src/LinkedSet.ts:111](https://github.com/zimmed/prefab/blob/a5ffdd1/src/LinkedSet.ts#L111) - -▸ **reverseMap**<`RT`, `This`\>(`cb`, `thisArg`): `RT`[] - -#### Type parameters - -| Name | -| :------ | -| `RT` | -| `This` | - -#### Parameters - -| Name | Type | -| :------ | :------ | -| `cb` | `Callback`<`T`, `This`, `RT`, [`UniQueue`](UniQueue.md)<`T`\>\> | -| `thisArg` | `This` | - -#### Returns - -`RT`[] - -#### Inherited from - -[LinkedSet](LinkedSet.md).[reverseMap](LinkedSet.md#reversemap) - -#### Defined in - -[src/LinkedSet.ts:112](https://github.com/zimmed/prefab/blob/a5ffdd1/src/LinkedSet.ts#L112) - -___ - -### shift - -▸ **shift**(): `undefined` \| `T` - -Shifts item off of the front of the set - -#### Returns - -`undefined` \| `T` - -#### Inherited from - -[LinkedSet](LinkedSet.md).[shift](LinkedSet.md#shift) - -#### Defined in - -[src/LinkedSet.ts:26](https://github.com/zimmed/prefab/blob/a5ffdd1/src/LinkedSet.ts#L26) - -___ - -### tailNode - -▸ **tailNode**(`node`): [`UniQueue`](UniQueue.md)<`T`\> - -Caution: Assumes node is already part of linked list -Moves node to the end of the list - -#### Parameters - -| Name | Type | -| :------ | :------ | -| `node` | `LNode`<`T`\> | - -#### Returns - -[`UniQueue`](UniQueue.md)<`T`\> - -#### Inherited from - -[LinkedSet](LinkedSet.md).[tailNode](LinkedSet.md#tailnode) - -#### Defined in - -[src/LinkedList.ts:155](https://github.com/zimmed/prefab/blob/a5ffdd1/src/LinkedList.ts#L155) - -___ - -### toArray - -▸ **toArray**(): `T`[] - -Converts list to native Array - -#### Returns - -`T`[] - -#### Inherited from - -[LinkedSet](LinkedSet.md).[toArray](LinkedSet.md#toarray) - -#### Defined in - -[src/LinkedList.ts:179](https://github.com/zimmed/prefab/blob/a5ffdd1/src/LinkedList.ts#L179) - -___ - -### toJSON - -▸ **toJSON**(): `T`[] - -#### Returns - -`T`[] - -#### Inherited from - -[LinkedSet](LinkedSet.md).[toJSON](LinkedSet.md#tojson) - -#### Defined in - -[src/LinkedList.ts:387](https://github.com/zimmed/prefab/blob/a5ffdd1/src/LinkedList.ts#L387) - -___ - -### unshift - -▸ **unshift**(`item`): [`UniQueue`](UniQueue.md)<`T`\> - -Alias for insert - -#### Parameters - -| Name | Type | -| :------ | :------ | -| `item` | `T` | - -#### Returns - -[`UniQueue`](UniQueue.md)<`T`\> - -#### Inherited from - -[LinkedSet](LinkedSet.md).[unshift](LinkedSet.md#unshift) - -#### Defined in - -[src/LinkedList.ts:117](https://github.com/zimmed/prefab/blob/a5ffdd1/src/LinkedList.ts#L117) - -___ - -### values - -▸ **values**(): `IterableIterator`<`T`\> - -Iterates through list items - -#### Returns - -`IterableIterator`<`T`\> - -#### Inherited from - -[LinkedSet](LinkedSet.md).[values](LinkedSet.md#values) - -#### Defined in - -[src/LinkedList.ts:207](https://github.com/zimmed/prefab/blob/a5ffdd1/src/LinkedList.ts#L207) - -___ - -### create - -▸ `Static` **create**<`T`\>(`iterable?`, `type?`): [`UniQueue`](UniQueue.md)<`T`\> - -Static factory method as alias for class constructor - -#### Type parameters - -| Name | -| :------ | -| `T` | - -#### Parameters - -| Name | Type | -| :------ | :------ | -| `iterable?` | `IterableIterator`<`T`\> \| `T`[] \| `Generator`<`T`, `void`, `unknown`\> | -| `type?` | `Type` | - -#### Returns - -[`UniQueue`](UniQueue.md)<`T`\> - -#### Overrides - -[LinkedSet](LinkedSet.md).[create](LinkedSet.md#create) - -#### Defined in - -[src/UniQueue.ts:13](https://github.com/zimmed/prefab/blob/a5ffdd1/src/UniQueue.ts#L13) - -___ - -### from - -▸ `Static` **from**<`T`\>(`iterable`, `type?`): [`UniQueue`](UniQueue.md)<`T`\> - -Same as LinkedList.create() but requires constructor arg - -#### Type parameters - -| Name | -| :------ | -| `T` | - -#### Parameters - -| Name | Type | -| :------ | :------ | -| `iterable` | `IterableIterator`<`T`\> \| `T`[] \| `Generator`<`T`, `void`, `unknown`\> | -| `type?` | `Type` | - -#### Returns - -[`UniQueue`](UniQueue.md)<`T`\> - -#### Overrides - -[LinkedSet](LinkedSet.md).[from](LinkedSet.md#from) - -#### Defined in - -[src/UniQueue.ts:21](https://github.com/zimmed/prefab/blob/a5ffdd1/src/UniQueue.ts#L21) diff --git a/docs/modules.md b/docs/modules.md index 65f764f..7dc8418 100644 --- a/docs/modules.md +++ b/docs/modules.md @@ -14,8 +14,5 @@ - [LinkedList](classes/LinkedList.md) - [LinkedSet](classes/LinkedSet.md) - [ObjectPool](classes/ObjectPool.md) -- [PriorityQueue](classes/PriorityQueue.md) -- [Queue](classes/Queue.md) +- [PoolObject](classes/PoolObject.md) - [SizedLinkedList](classes/SizedLinkedList.md) -- [SortedSet](classes/SortedSet.md) -- [UniQueue](classes/UniQueue.md) diff --git a/docs/modules/decorators.md b/docs/modules/decorators.md index 35b65bd..59cfbfa 100644 --- a/docs/modules/decorators.md +++ b/docs/modules/decorators.md @@ -30,7 +30,7 @@ #### Defined in -[src/decorators.ts:3](https://github.com/zimmed/prefab/blob/a5ffdd1/src/decorators.ts#L3) +[src/decorators.ts:3](https://github.com/zimmed/prefab/blob/83cd828/src/decorators.ts#L3) ___ @@ -58,7 +58,7 @@ ___ #### Defined in -[src/decorators.ts:39](https://github.com/zimmed/prefab/blob/a5ffdd1/src/decorators.ts#L39) +[src/decorators.ts:38](https://github.com/zimmed/prefab/blob/83cd828/src/decorators.ts#L38) ___ @@ -98,7 +98,7 @@ node_modules/typescript/lib/lib.es5.d.ts:1494 #### Defined in -[src/decorators.ts:8](https://github.com/zimmed/prefab/blob/a5ffdd1/src/decorators.ts#L8) +[src/decorators.ts:8](https://github.com/zimmed/prefab/blob/83cd828/src/decorators.ts#L8) ___ @@ -138,7 +138,7 @@ node_modules/typescript/lib/lib.es5.d.ts:1494 #### Defined in -[src/decorators.ts:8](https://github.com/zimmed/prefab/blob/a5ffdd1/src/decorators.ts#L8) +[src/decorators.ts:8](https://github.com/zimmed/prefab/blob/83cd828/src/decorators.ts#L8) ___ @@ -178,4 +178,4 @@ node_modules/typescript/lib/lib.es5.d.ts:1494 #### Defined in -[src/decorators.ts:8](https://github.com/zimmed/prefab/blob/a5ffdd1/src/decorators.ts#L8) +[src/decorators.ts:8](https://github.com/zimmed/prefab/blob/83cd828/src/decorators.ts#L8) diff --git a/package.json b/package.json index 52e58ba..56f20d4 100644 --- a/package.json +++ b/package.json @@ -1,6 +1,6 @@ { "name": "@zimmed/prefab", - "version": "0.1.8", + "version": "0.2.0", "description": "TypeScript library for optimized data structures.", "keywords": [], "main": "dist/prefab.umd.js", diff --git a/src/LinkedCollection.ts b/src/LinkedCollection.ts index a2881e6..374fb81 100644 --- a/src/LinkedCollection.ts +++ b/src/LinkedCollection.ts @@ -66,10 +66,10 @@ export class LinkedCollection< return this._map.has(key); } - // public get(key: T[K]) { - // console.log('get key', key); - // return this._map.get(key)?.body; - // } + /** Get an item in the collection by its key */ + public select(key: T[K]) { + return this._map.get(key)?.body; + } /** Append unique item to the end of the collection or update exiting item */ public uppend(item: T) { diff --git a/src/LinkedList.ts b/src/LinkedList.ts index 80c7a04..dd946ea 100644 --- a/src/LinkedList.ts +++ b/src/LinkedList.ts @@ -16,16 +16,6 @@ export type Reducer = export type LNode = { head?: LNode; body: T; tail?: LNode }; export class LinkedList = LNode> { - /** Static factory method as alias for class constructor */ - static create(iterable?: IterableIterator | Array | Generator) { - return new this(iterable); - } - - /** Same as LinkedList.create() but requires constructor arg */ - static from(iterable: IterableIterator | Array | Generator) { - return new this(iterable); - } - @hidden protected _head?: N; @@ -144,6 +134,7 @@ export class LinkedList = LNode> { if (node.tail) node.tail.head = node.head; node.head = undefined; node.tail = this._head; + if (node.tail) node.tail.head = node; this._head = node; return this; } @@ -159,7 +150,7 @@ export class LinkedList = LNode> { if (node.tail) node.tail.head = node.head; node.tail = undefined; node.head = this._tail; - if (this._tail) this._tail.tail = node; + if (node.head) node.head.tail = node; this._tail = node; return this; } diff --git a/src/ObjectPool.ts b/src/ObjectPool.ts index c0e3d15..967655a 100644 --- a/src/ObjectPool.ts +++ b/src/ObjectPool.ts @@ -1,19 +1,18 @@ import LinkedList, { LNode } from './LinkedList'; -import { hidden } from './decorators'; +import { describe } from './decorators'; + +type InitArgs = T['onInit'] extends (...args: infer A) => any ? A : never; -type InitArgs = K extends (...args: infer A) => T - ? A - : never; export type PoolState = { pool?: ObjectPool; inUse: boolean; - body: T; + readonly body: T; head?: LNode; tail?: LNode; }; export abstract class PoolObject { - @hidden({ writable: false }) + @describe({ writable: false, enumerable: false }) public readonly poolState = { pool: undefined, inUse: false, @@ -41,13 +40,13 @@ export class ObjectPool { return new this(PoolObjectClass, allocSize); } - @hidden({ writable: false }) + @describe({ enumerable: false, writable: false }) protected readonly _list = new LinkedList>(); - @hidden({ writable: false }) + @describe({ enumerable: false, writable: false }) protected readonly _Class: new () => O; - @hidden + @describe({ enumerable: false }) private _max = 0; /** The current (max) size of the object pool */ @@ -55,22 +54,28 @@ export class ObjectPool { return this._max; } - /** @hidden */ - get [Symbol.toStringTag]() { - return `${this.constructor.name}<${this._Class.name}>(${this._max})`; - } - public constructor(PoolObjectClass: new () => O, allocSize = 0) { this._Class = PoolObjectClass; - if (allocSize) this.alloc(allocSize); + if (allocSize > 0) this.alloc(allocSize); + } + + public *items() { + for (const item of this._list) { + if (item.poolState.inUse) yield item; + else break; + } + } + + public [Symbol.iterator]() { + return this.items(); } /** Spawns and initializes object from pool, or create new object and increase pool size if full */ public forceSpawn(...args: InitArgs): O { let item = this._list.tail; - if (!item || item?.poolState?.inUse) { + if (!item || item.poolState.inUse) { item = this.create(); item.onInit(...args); item.poolState.inUse = true; @@ -88,7 +93,7 @@ export class ObjectPool { public spawn(...args: InitArgs): O | undefined { const item = this._list.tail; - if (item && !item?.poolState?.inUse) { + if (item && !item.poolState.inUse) { this._list.headNode(item.poolState); item.poolState.inUse = true; item.onInit(...args); @@ -99,30 +104,20 @@ export class ObjectPool { /** Returns object back to pool to be re-used later */ public free(item: O) { - item.onClean(); - item.poolState.inUse = false; this._list.tailNode(item.poolState); - } - - /** Cleans and removes object from pool entirely */ - public deallocateObject(obj?: O, del = true) { - if (obj && (!del || this._list.deleteNode(obj.poolState))) { - obj.onClean(); - obj.poolState.inUse = false; - obj.poolState.pool = undefined; - obj.poolState.tail = undefined; - obj.poolState.head = undefined; - return true; - } - return false; + this.deallocateObject(item, false); + return this; } /** Increases pool size and allocates new objects to fill it */ public alloc(size = 1) { - let i = -1; + if (size > 0) { + let i = -1; - this._max += size; - while (++i < size) this.add(this.create()); + this._max += size; + while (++i < size) this.add(this.create()); + } + return this; } /** Overrides max pool size, deallocating any overflowing objects */ @@ -137,6 +132,7 @@ export class ObjectPool { while (--i >= size) this.deallocateObject(this._list.pop(), false); } this._max = size; + return this; } /** Sets max pool size, but ignores call if provided size is smaller than current max */ @@ -144,23 +140,27 @@ export class ObjectPool { if (size > this._max) { let i = this._max - 1; - while (++i < size) this.add(this.create()); - } else { this._max = size; + while (++i < size) this.add(this.create()); } + return this; } /** Completely clear the pool, freeing all objects from memory */ public clear() { - this.dealloc(this.size); + return this.dealloc(this._max); } /** Downsize pool by specified amount, deallocating overflowing objects */ public dealloc(size = 1) { - let i = -1; + if (size > 0) { + const m = Math.min(size, this._max); + let i = -1; - while (++i < size) this.deallocateObject(this._list.pop(), false); - this._max -= size; + while (++i < m) this.deallocateObject(this._list.pop(), false); + this._max -= m; + } + return this; } /** Create and return new PoolObject */ @@ -182,6 +182,28 @@ export class ObjectPool { obj.poolState.tail = this._list.head?.poolState; this._list.insertNode(obj.poolState); } + + /** Cleans and removes object from pool entirely */ + protected deallocateObject(obj?: O, del = true) { + if (obj && (!del || this._list.deleteNode(obj.poolState))) { + obj.onClean(); + obj.poolState.inUse = false; + obj.poolState.pool = undefined; + obj.poolState.tail = undefined; + obj.poolState.head = undefined; + return true; + } + return false; + } + + /** @hidden */ + get [Symbol.toStringTag]() { + return `${this.constructor.name}<${this._Class.name}>(${this._max})`; + } + + public toJSON() { + return [...this.items()]; + } } export default ObjectPool; diff --git a/src/PriorityQueue.ts b/src/PriorityQueue.ts deleted file mode 100644 index 17417ef..0000000 --- a/src/PriorityQueue.ts +++ /dev/null @@ -1,88 +0,0 @@ -import SortedSet from './SortedSet'; -import { hidden, forceInit } from './decorators'; - -function compare>(a: T, b: T, q: S) { - // @ts-expect-error - const x = q._pMap.get(a) as number; - // @ts-expect-error - const y = q._pMap.get(b) as number; - - // @ts-expect-error - if (x === y) return (q._cMap.get(a) as number) < (q._cMap.get(b) as number) ? -1 : 1; - return x < y ? -1 : 1; -} - -export class PriorityQueue extends SortedSet { - /** Static factory method as alias for class constructor */ - static create(iterable?: IterableIterator | Array | Generator) { - return new this(iterable); - } - - /** Same as LinkedList.create() but requires constructor arg */ - static from(iterable: IterableIterator | Array | Generator) { - return new this(iterable); - } - - @hidden - private _rCount = 0; - - @hidden - private _count = 0; - - @forceInit(() => new Map(), { enumerable: false, writable: false }) - protected readonly _pMap!: Map; - - @forceInit(() => new Map(), { enumerable: false, writable: false }) - protected readonly _cMap!: Map; - - public constructor(iterable?: IterableIterator | Array | Generator) { - super(iterable, compare); - } - - /** Adds item into the Queue with priority=5 */ - public add(item: T) { - return this.enqueue(item); - } - - /** Appends item onto the Queue with priority=10 */ - public append(item: T, priority = 10) { - return this.enqueue(item, priority); - } - - /** Inserts item into the front of the specified priority order */ - public insert(item: T, priority = -1, c = --this._rCount) { - return this.enqueue(item, priority, c); - } - - /** Appends item onto the Queue at the specified priority */ - public enqueue(item: T, priority = 5, c = ++this._count) { - if (this._pMap.has(item)) return this; - this._pMap.set(item, priority); - this._cMap.set(item, c); - return super.add(item); - } - - /** Takes item from the front of the Queue */ - public dequeue() { - const item = this.shift(); - - if (typeof item !== 'undefined') { - this._pMap.delete(item); - this._cMap.delete(item); - } - return item; - } - - /** Deletes specified item from the Queue */ - public delete(item: T) { - const r = super.delete(item); - - if (r) { - this._pMap.delete(item); - this._cMap.delete(item); - } - return r; - } -} - -export default PriorityQueue; diff --git a/src/Queue.ts b/src/Queue.ts deleted file mode 100644 index f5ad816..0000000 --- a/src/Queue.ts +++ /dev/null @@ -1,50 +0,0 @@ -import { hidden } from './decorators'; -import SizedLinkedList from './SizedLinkedList'; - -export enum Type { - LIFO = 'LIFO', - FIFO = 'FIFO', -} - -export class Queue extends SizedLinkedList { - public static Type = Type; - - /** Static factory method as alias for class constructor */ - static create( - iterable?: IterableIterator | Array | Generator, - type?: Type - ) { - return new this(iterable, type); - } - - /** Same as LinkedList.create() but requires constructor arg */ - static from( - iterable: IterableIterator | Array | Generator, - type?: Type - ) { - return new this(iterable, type); - } - - @hidden({ writable: false }) - protected readonly _type: Type; - - public constructor( - iterable?: IterableIterator | Array | Generator, - type: Type = Type.FIFO - ) { - super(iterable); - this._type = type; - } - - /** Append item to Queue */ - public enqueue(item: T) { - this.add(item); - } - - /** Shift item from front of front of Queue if type is FIFO, otherwise pop from end of Queue (LIFO) */ - public dequeue() { - return this._type === Type.LIFO ? this.pop() : this.shift(); - } -} - -export default Queue; diff --git a/src/SortedSet.ts b/src/SortedSet.ts deleted file mode 100644 index db8d1d3..0000000 --- a/src/SortedSet.ts +++ /dev/null @@ -1,190 +0,0 @@ -import LinkedSet from './LinkedSet'; -import { hidden } from './decorators'; - -const LEFT = 'left' as const; -const RIGHT = 'right' as const; - -type LNode = { head?: LNode; body: T; tree: TNode; tail?: LNode }; - -type TNode = { left?: TNode; root?: TNode; leaf: LNode; right?: TNode }; - -export type Sort>> = - | ((a: T, b: T) => number) - | ((a: T, b: T, s: S) => number); - -const DEFAULT_SORT: Sort = (a: T, b: T) => (a < b ? -1 : 1); - -export class SortedSet = LNode> extends LinkedSet { - /** Static factory method as alias for class constructor */ - static create( - iterable?: IterableIterator | Array | Generator, - compareFunction?: Sort - ) { - return new this(iterable, compareFunction); - } - - /** Same as LinkedList.create() but requires constructor arg */ - static from( - iterable: IterableIterator | Array | Generator, - compareFunction?: Sort - ) { - return new this(iterable, compareFunction); - } - - @hidden - protected _tree?: TNode; - - @hidden({ writable: false }) - private readonly _cmp!: Sort; - - public constructor( - iterable?: IterableIterator | Array | Generator, - compareFunction: Sort = DEFAULT_SORT - ) { - super(iterable, { _cmp: compareFunction }); - } - - /** Searches set using compare function to find first match - * @param compareFunction Takes an item from the set and returns 0 if a match, -1 (<0) - * if the desired match is lower in the sort order (closer to the front of the list), - * or 1 (>0) if the desired match is higher (towards the end of the list) - */ - public search(compareFunction: (a: T) => number, node = this._tree): T | undefined { - if (!node) return undefined; - let cmp = compareFunction(node.leaf.body); - - while (cmp < 0) { - node = (node as TNode).left; - cmp = node ? compareFunction(node.leaf.body) : 0; - } - while (cmp > 0) { - node = (node as TNode).right; - cmp = node ? compareFunction(node.leaf.body) : 0; - } - if (cmp === 0) { - if (node) return node.leaf.body; - else return undefined; - } - return this.search(compareFunction, node); - } - - /** Pops item from end of the set */ - public pop() { - if (this._tail) { - const tnode = this._tail.tree; - - if (tnode.root) tnode.root.right = tnode.left; - else this._tree = tnode.left; - } - return super.pop(); - } - - /** Shifts item from the front of the set */ - public shift() { - if (this._head) { - const tnode = this._head.tree; - - if (tnode.root) tnode.root.left = tnode.right; - else this._tree = tnode.right; - } - return super.shift(); - } - - /** Clears the set */ - public clear() { - this._tree = undefined; - super.clear(); - } - - /** Inserts item into the front the set */ - public insert(item: T) { - return this.add(item); - } - - /** Appends item onto the end of the set */ - public add(item: T) { - const map = this._map; - - if (!map.has(item)) { - let lnode: Partial; - let tnode: TNode; - - if (!map.size) { - lnode = { body: item } as Partial; - tnode = { leaf: lnode as N }; - lnode.tree = tnode; - this._tree = tnode; - this._head = this._tail = lnode as N; - } else { - const cmp = this._cmp; - let nextNode: typeof LEFT | typeof RIGHT; - let sibling: N; - - tnode = this._tree as TNode; - nextNode = cmp(item, tnode.leaf.body, this) < 0 ? LEFT : RIGHT; - while (tnode[nextNode]) { - tnode = tnode[nextNode] as TNode; - nextNode = cmp(item, tnode.leaf.body, this) < 0 ? LEFT : RIGHT; - } - sibling = tnode.leaf as N; - lnode = - nextNode === LEFT - ? ({ head: sibling.head, body: item, tail: sibling } as unknown as Partial) - : ({ head: sibling, body: item, tail: sibling.tail } as unknown as Partial); - if (lnode.head) lnode.head.tail = lnode as N; - if (lnode.tail) lnode.tail.head = lnode as N; - tnode[nextNode] = { leaf: lnode as N, root: tnode }; - lnode.tree = tnode[nextNode]; - if (nextNode === LEFT && sibling === this._head) this._head = lnode as N; - else if (nextNode === RIGHT && sibling === this._tail) this._tail = lnode as N; - } - map.set(item, lnode as N); - } - return this; - } - - /** Deletes specified item from the set */ - public delete(item: T) { - const map = this._map; - let cur = map.get(item); - let t: TNode; - - if (cur) { - t = cur.tree; - map.delete(item); - if (this._head === cur) this._head = cur.tail as N; - else if (this._tail === cur) this._tail = cur.head as N; - else { - if (cur.head) cur.head.tail = cur.tail; - if (cur.tail) cur.tail.head = cur.head; - } - if (!t.left) { - if (t.root) t.root[t === t.root.left ? LEFT : RIGHT] = t.right; - else this._tree = t.right; - } else if (!t.right) { - if (t.root) t.root[t === t.root.left ? LEFT : RIGHT] = t.left; - else this._tree = t.left; - } else { - let parent = t; - let child = t.right; - - while (child.left) { - parent = child; - child = child.left; - } - if (parent === t) { - } else { - parent.left = child.right; - } - if (t.root) t.root[t === t.root.left ? LEFT : RIGHT] = child; - else this._tree = child; - child.right = t.right; - child.left = t.left; - } - return true; - } - return false; - } -} - -export default SortedSet; diff --git a/src/UniQueue.ts b/src/UniQueue.ts deleted file mode 100644 index 8ae3f8e..0000000 --- a/src/UniQueue.ts +++ /dev/null @@ -1,50 +0,0 @@ -import { hidden } from './decorators'; -import LinkedSet from './LinkedSet'; - -export enum Type { - LIFO = 'LIFO', - FIFO = 'FIFO', -} - -export class UniQueue extends LinkedSet { - public static Type = Type; - - /** Static factory method as alias for class constructor */ - static create( - iterable?: IterableIterator | Array | Generator, - type?: Type - ) { - return new this(iterable, type); - } - - /** Same as LinkedList.create() but requires constructor arg */ - static from( - iterable: IterableIterator | Array | Generator, - type?: Type - ) { - return new this(iterable, type); - } - - @hidden - protected readonly _type: Type; - - public constructor( - iterable?: IterableIterator | Array | Generator, - type: Type = Type.FIFO - ) { - super(iterable); - this._type = type; - } - - /** Append item to Queue */ - public enqueue(item: T) { - this.add(item); - } - - /** Shift item from front of front of Queue if type is FIFO, otherwise pop from end of Queue (LIFO) */ - public dequeue() { - return this._type === Type.LIFO ? this.pop() : this.shift(); - } -} - -export default UniQueue; diff --git a/src/decorators.ts b/src/decorators.ts index 216c98b..8b33f53 100644 --- a/src/decorators.ts +++ b/src/decorators.ts @@ -7,10 +7,9 @@ export function describe({ }: Partial = {}): PropertyDecorator & ((a: { configurable?: boolean; writable?: boolean; enumerable?: boolean }) => PropertyDecorator) { return ((target: any, key: string) => { - if ( - typeof target === 'object' && - Object.keys(target).reduce((f, k, i) => (!i || f) && K.includes(k), false) - ) { + const keys = Object.keys(target); + + if (keys.length && keys.reduce((f, k) => f && K.includes(k), true)) { return describe({ configurable, writable, enumerable, ...target }); } const desc = Object.getOwnPropertyDescriptor(target, key) || {}; diff --git a/src/index.ts b/src/index.ts index 091f2a5..78e8dfb 100644 --- a/src/index.ts +++ b/src/index.ts @@ -1,10 +1,10 @@ export { LinkedList } from './LinkedList'; export { SizedLinkedList } from './SizedLinkedList'; export { LinkedSet } from './LinkedSet'; -export { ObjectPool } from './ObjectPool'; -export { PriorityQueue } from './PriorityQueue'; -export { UniQueue } from './UniQueue'; -export { Queue } from './Queue'; -export { SortedSet } from './SortedSet'; +export { ObjectPool, PoolObject } from './ObjectPool'; +// export { PriorityQueue } from './PriorityQueue'; +// export { UniQueue } from './UniQueue'; +// export { Queue } from './Queue'; +// export { SortedSet } from './SortedSet'; export { LinkedCollection } from './LinkedCollection'; export * as decorators from './decorators'; diff --git a/src/wip/PriorityQueue.ts b/src/wip/PriorityQueue.ts new file mode 100644 index 0000000..b4e2065 --- /dev/null +++ b/src/wip/PriorityQueue.ts @@ -0,0 +1,88 @@ +// import SortedSet from './SortedSet'; +// import { hidden, forceInit } from './decorators'; + +// function compare>(a: T, b: T, q: S) { +// // @ts-expect-error +// const x = q._pMap.get(a) as number; +// // @ts-expect-error +// const y = q._pMap.get(b) as number; + +// // @ts-expect-error +// if (x === y) return (q._cMap.get(a) as number) < (q._cMap.get(b) as number) ? -1 : 1; +// return x < y ? -1 : 1; +// } + +// export class PriorityQueue extends SortedSet { +// /** Static factory method as alias for class constructor */ +// static create(iterable?: IterableIterator | Array | Generator) { +// return new this(iterable); +// } + +// /** Same as LinkedList.create() but requires constructor arg */ +// static from(iterable: IterableIterator | Array | Generator) { +// return new this(iterable); +// } + +// @hidden +// private _rCount = 0; + +// @hidden +// private _count = 0; + +// @forceInit(() => new Map(), { enumerable: false, writable: false }) +// protected readonly _pMap!: Map; + +// @forceInit(() => new Map(), { enumerable: false, writable: false }) +// protected readonly _cMap!: Map; + +// public constructor(iterable?: IterableIterator | Array | Generator) { +// super(iterable, compare); +// } + +// /** Adds item into the Queue with priority=5 */ +// public add(item: T) { +// return this.enqueue(item); +// } + +// /** Appends item onto the Queue with priority=10 */ +// public append(item: T, priority = 10) { +// return this.enqueue(item, priority); +// } + +// /** Inserts item into the front of the specified priority order */ +// public insert(item: T, priority = -1, c = --this._rCount) { +// return this.enqueue(item, priority, c); +// } + +// /** Appends item onto the Queue at the specified priority */ +// public enqueue(item: T, priority = 5, c = ++this._count) { +// if (this._pMap.has(item)) return this; +// this._pMap.set(item, priority); +// this._cMap.set(item, c); +// return super.add(item); +// } + +// /** Takes item from the front of the Queue */ +// public dequeue() { +// const item = this.shift(); + +// if (typeof item !== 'undefined') { +// this._pMap.delete(item); +// this._cMap.delete(item); +// } +// return item; +// } + +// /** Deletes specified item from the Queue */ +// public delete(item: T) { +// const r = super.delete(item); + +// if (r) { +// this._pMap.delete(item); +// this._cMap.delete(item); +// } +// return r; +// } +// } + +// export default PriorityQueue; diff --git a/src/wip/Queue.ts b/src/wip/Queue.ts new file mode 100644 index 0000000..e3a89c2 --- /dev/null +++ b/src/wip/Queue.ts @@ -0,0 +1,50 @@ +// import { hidden } from './decorators'; +// import SizedLinkedList from './SizedLinkedList'; + +// export enum Type { +// LIFO = 'LIFO', +// FIFO = 'FIFO', +// } + +// export class Queue extends SizedLinkedList { +// public static Type = Type; + +// /** Static factory method as alias for class constructor */ +// static create( +// iterable?: IterableIterator | Array | Generator, +// type?: Type +// ) { +// return new this(iterable, type); +// } + +// /** Same as LinkedList.create() but requires constructor arg */ +// static from( +// iterable: IterableIterator | Array | Generator, +// type?: Type +// ) { +// return new this(iterable, type); +// } + +// @hidden({ writable: false }) +// protected readonly _type: Type; + +// public constructor( +// iterable?: IterableIterator | Array | Generator, +// type: Type = Type.FIFO +// ) { +// super(iterable); +// this._type = type; +// } + +// /** Append item to Queue */ +// public enqueue(item: T) { +// this.add(item); +// } + +// /** Shift item from front of front of Queue if type is FIFO, otherwise pop from end of Queue (LIFO) */ +// public dequeue() { +// return this._type === Type.LIFO ? this.pop() : this.shift(); +// } +// } + +// export default Queue; diff --git a/src/wip/SortedSet.ts b/src/wip/SortedSet.ts new file mode 100644 index 0000000..f448b40 --- /dev/null +++ b/src/wip/SortedSet.ts @@ -0,0 +1,174 @@ +// import SizedLinkedSet from './LinkedSet'; +// import { hidden } from './decorators'; + +// const LEFT = 'left' as const; +// const RIGHT = 'right' as const; + +// type LNode = { head?: LNode; body: T; tree: TNode; tail?: LNode }; + +// type TNode = { left?: TNode; root?: TNode; leaf: LNode; right?: TNode }; + +// export type Sort>> = +// | ((a: T, b: T) => number) +// | ((a: T, b: T, s: S) => number); + +// const DEFAULT_SORT: Sort = (a: T, b: T) => (a < b ? -1 : a > b ? 1 : 0); + +// export class SortedSet = LNode> extends SizedLinkedSet { +// @hidden +// protected _tree?: TNode; + +// @hidden({ writable: false }) +// private readonly _cmp!: Sort; + +// public constructor( +// iterable?: IterableIterator | Array | Generator, +// compareFunction: Sort = DEFAULT_SORT +// ) { +// super(iterable, { _cmp: compareFunction }); +// } + +// /** Searches set using compare function to find first match +// * @param compareFunction Takes an item from the set and returns 0 if a match, -1 (<0) +// * if the desired match is lower in the sort order (closer to the front of the list), +// * or 1 (>0) if the desired match is higher (towards the end of the list) +// */ +// public search(compareFunction: (a: T) => number, node = this._tree): T | undefined { +// if (!node) return undefined; +// let cmp = compareFunction(node.leaf.body); + +// while (cmp < 0) { +// node = (node as TNode).left; +// cmp = node ? compareFunction(node.leaf.body) : 0; +// } +// while (cmp > 0) { +// node = (node as TNode).right; +// cmp = node ? compareFunction(node.leaf.body) : 0; +// } +// if (cmp === 0) { +// if (node) return node.leaf.body; +// else return undefined; +// } +// return this.search(compareFunction, node); +// } + +// /** Pops item from end of the set */ +// public pop() { +// if (this._tail) { +// const tnode = this._tail.tree; + +// if (tnode.root) tnode.root.right = tnode.left; +// else this._tree = tnode.left; +// } +// return super.pop(); +// } + +// /** Shifts item from the front of the set */ +// public shift() { +// if (this._head) { +// const tnode = this._head.tree; + +// if (tnode.root) tnode.root.left = tnode.right; +// else this._tree = tnode.right; +// } +// return super.shift(); +// } + +// /** Clears the set */ +// public clear() { +// this._tree = undefined; +// super.clear(); +// } + +// /** Inserts item into the front the set */ +// public insert(item: T) { +// return this.add(item); +// } + +// /** Appends item onto the end of the set */ +// public add(item: T) { +// const map = this._map; + +// if (!map.has(item)) { +// let lnode: Partial; +// let tnode: TNode; + +// if (!map.size) { +// lnode = { body: item } as Partial; +// tnode = { leaf: lnode as N }; +// lnode.tree = tnode; +// this._tree = tnode; +// this._head = this._tail = lnode as N; +// } else { +// const cmp = this._cmp; +// let nextNode: typeof LEFT | typeof RIGHT; +// let sibling: N; + +// tnode = this._tree as TNode; +// nextNode = cmp(item, tnode.leaf.body, this) < 0 ? LEFT : RIGHT; +// while (tnode[nextNode]) { +// tnode = tnode[nextNode] as TNode; +// nextNode = cmp(item, tnode.leaf.body, this) < 0 ? LEFT : RIGHT; +// } +// sibling = tnode.leaf as N; +// lnode = +// nextNode === LEFT +// ? ({ head: sibling.head, body: item, tail: sibling } as unknown as Partial) +// : ({ head: sibling, body: item, tail: sibling.tail } as unknown as Partial); +// if (lnode.head) lnode.head.tail = lnode as N; +// if (lnode.tail) lnode.tail.head = lnode as N; +// tnode[nextNode] = { leaf: lnode as N, root: tnode }; +// lnode.tree = tnode[nextNode]; +// if (nextNode === LEFT && sibling === this._head) this._head = lnode as N; +// else if (nextNode === RIGHT && sibling === this._tail) this._tail = lnode as N; +// } +// map.set(item, lnode as N); +// } +// return this; +// } + +// /** Deletes specified item from the set */ +// public delete(item: T) { +// const map = this._map; +// let cur = map.get(item); +// let t: TNode; + +// if (cur) { +// t = cur.tree; +// map.delete(item); +// if (this._head === cur) this._head = cur.tail as N; +// else if (this._tail === cur) this._tail = cur.head as N; +// else { +// if (cur.head) cur.head.tail = cur.tail; +// if (cur.tail) cur.tail.head = cur.head; +// } +// if (!t.left) { +// if (t.root) t.root[t === t.root.left ? LEFT : RIGHT] = t.right; +// else this._tree = t.right; +// } else if (!t.right) { +// if (t.root) t.root[t === t.root.left ? LEFT : RIGHT] = t.left; +// else this._tree = t.left; +// } else { +// let parent = t; +// let child = t.right; + +// while (child.left) { +// parent = child; +// child = child.left; +// } +// if (parent === t) { +// } else { +// parent.left = child.right; +// } +// if (t.root) t.root[t === t.root.left ? LEFT : RIGHT] = child; +// else this._tree = child; +// child.right = t.right; +// child.left = t.left; +// } +// return true; +// } +// return false; +// } +// } + +// export default SortedSet; diff --git a/src/wip/UniQueue.ts b/src/wip/UniQueue.ts new file mode 100644 index 0000000..1a595b1 --- /dev/null +++ b/src/wip/UniQueue.ts @@ -0,0 +1,50 @@ +// import { hidden } from './decorators'; +// import LinkedSet from './LinkedSet'; + +// export enum Type { +// LIFO = 'LIFO', +// FIFO = 'FIFO', +// } + +// export class UniQueue extends LinkedSet { +// public static Type = Type; + +// /** Static factory method as alias for class constructor */ +// static create( +// iterable?: IterableIterator | Array | Generator, +// type?: Type +// ) { +// return new this(iterable, type); +// } + +// /** Same as LinkedList.create() but requires constructor arg */ +// static from( +// iterable: IterableIterator | Array | Generator, +// type?: Type +// ) { +// return new this(iterable, type); +// } + +// @hidden +// protected readonly _type: Type; + +// public constructor( +// iterable?: IterableIterator | Array | Generator, +// type: Type = Type.FIFO +// ) { +// super(iterable); +// this._type = type; +// } + +// /** Append item to Queue */ +// public enqueue(item: T) { +// this.add(item); +// } + +// /** Shift item from front of front of Queue if type is FIFO, otherwise pop from end of Queue (LIFO) */ +// public dequeue() { +// return this._type === Type.LIFO ? this.pop() : this.shift(); +// } +// } + +// export default UniQueue; diff --git a/test/LinkedCollection.test.ts b/test/LinkedCollection.test.ts index d0536e3..6925d4c 100644 --- a/test/LinkedCollection.test.ts +++ b/test/LinkedCollection.test.ts @@ -6,7 +6,7 @@ class Obj { constructor(readonly id = count++) {} } -describe('LinkedCollection', () => { +describe('new LinkedCollection()', () => { it('should only allow elements with unique keys', () => { const a = new Obj(0); @@ -39,18 +39,18 @@ describe('LinkedCollection instance', () => { }); }); - // describe.skip('get()', () => { - // const list = new LinkedCollection('id', [{ id: 3 }, { id: 5 }, { id: 7 }, { id: 9 }]); + describe('select()', () => { + const list = new LinkedCollection('id', [{ id: 3 }, { id: 5 }, { id: 7 }, { id: 9 }]); - // it('should retrieve a collection item by key', () => { - // expect(list.get(7)).toEqual({ id: 7 }); - // expect(list.get(3)).toEqual({ id: 3 }); - // }); - // it('should return undefined when collection does not contain key', () => { - // expect(list.get(-1)).toBeUndefined(); - // expect(list.get(17)).toBeUndefined(); - // }); - // }); + it('should retrieve a collection item by key', () => { + expect(list.select(7)).toEqual({ id: 7 }); + expect(list.select(3)).toEqual({ id: 3 }); + }); + it('should return undefined when collection does not contain key', () => { + expect(list.select(-1)).toBeUndefined(); + expect(list.select(17)).toBeUndefined(); + }); + }); describe('keys()', () => { const list = new LinkedCollection('id', [{ id: 3 }, { id: 5 }, { id: 7 }, { id: 9 }]); @@ -282,7 +282,7 @@ describe('LinkedCollection instance', () => { expect(list.tail).toEqual({ id: a.id, data: 'bar' }); expect(list.uppend({ id: 5, data: 'foo' })).toBe(list); expect(addNode).not.toHaveBeenCalled(); - // expect(list.get(5)).toHaveProperty('data', 'foo'); + expect(list.select(5)).toHaveProperty('data', 'foo'); expect(list.size).toBe(5); }); }); diff --git a/test/LinkedList.test.ts b/test/LinkedList.test.ts index b56012e..f099fa2 100644 --- a/test/LinkedList.test.ts +++ b/test/LinkedList.test.ts @@ -1,30 +1,5 @@ import { LinkedList } from '../src'; -describe('LinkedList.create', () => { - it('should create a new empty instance of LinkedList without args', () => { - const list = new LinkedList(); - - expect(list).toBeInstanceOf(LinkedList); - expect(list.head).toBeUndefined(); - expect(list.tail).toBeUndefined(); - }); - it('should create a new instance of LinkedList with args', () => { - const list = LinkedList.create(['foo', 'bar', 'baz']); - - expect(list).toBeInstanceOf(LinkedList); - expect(list.head).toEqual('foo'); - expect(list.tail).toEqual('baz'); - }); -}); -describe('LinkedList.from', () => { - it('should create a new instance of LinkedList with args', () => { - const list = LinkedList.from(['foo', 'bar', 'baz']); - - expect(list).toBeInstanceOf(LinkedList); - expect(list.head).toEqual('foo'); - expect(list.tail).toEqual('baz'); - }); -}); describe('new LinkedList()', () => { it('should create a new empty instance of LinkedList without args', () => { const list = new LinkedList(); @@ -267,6 +242,16 @@ describe('LinkedList instance', () => { beforeEach(() => { list = new LinkedList([3, 5, 7, 9]); }); + it('should tail the node', () => { + // @ts-expect-error + expect(list.tailNode(list._head)).toBe(list); + expect(list.toArray()).toEqual([5, 7, 9, 3]); + // @ts-expect-error + list.tailNode(list._head.tail); + expect(list.toArray()).toEqual([5, 9, 3, 7]); + expect([...list.reverse()]).toEqual([7, 3, 9, 5]); + }); + it('should move the specified node to the tail of the list', () => { // @ts-expect-error const node = list._tail?.head; diff --git a/test/ObjectPool.test.ts b/test/ObjectPool.test.ts new file mode 100644 index 0000000..7462865 --- /dev/null +++ b/test/ObjectPool.test.ts @@ -0,0 +1,358 @@ +import { ObjectPool, LinkedList, PoolObject } from '../src'; + +class Obj extends PoolObject { + public foo: string = ''; + + public onInit({ foo }: { foo: string }) { + this.foo = foo; + } + + public onClean() { + this.foo = ''; + } +} + +describe('PoolObject', () => { + it('should be extendable and add pool state', () => { + const obj = new Obj(); + + expect(obj).toHaveProperty('poolState'); + expect(obj.poolState.pool).toBeUndefined(); + expect(obj.poolState.head).toBeUndefined(); + expect(obj.poolState.tail).toBeUndefined(); + expect(obj.poolState.body).toBe(obj); + expect(obj.poolState.inUse).toBe(false); + expect(obj.foo).toBe(''); + }); +}); + +describe('ObjectPool.create', () => { + it('should alias the constructor', () => { + expect(ObjectPool.create(Obj)).toEqual(new ObjectPool(Obj)); + expect(ObjectPool.create(Obj, 100)).toEqual(new ObjectPool(Obj, 100)); + }); +}); + +describe('new ObjectPool()', () => { + it('should instantiate with an empty pool', () => { + let pool: ObjectPool; + + expect(() => (pool = new ObjectPool(Obj))).not.toThrowError(); + expect(pool!.size).toBe(0); + }); + + it('should instantiate with a specified pool size', () => { + let pool: ObjectPool; + + expect(() => (pool = new ObjectPool(Obj, 200))).not.toThrowError(); + expect(pool!.size).toBe(200); + }); +}); + +describe('ObjectPool', () => { + describe('items()', () => { + it('should have nothing to iterate when empty', () => { + const pool = new ObjectPool(Obj); + + expect([...pool.items()]).toEqual([]); + }); + it('should have nothing to iterate when no objects are active', () => { + const pool = new ObjectPool(Obj, 10); + + expect([...pool.items()]).toEqual([]); + }); + it('should iterate spawned/active items', () => { + const pool = new ObjectPool(Obj, 10); + const a = pool.spawn({ foo: 'bar' })!; + const b = pool.spawn({ foo: 'baz' })!; + const c = pool.spawn({ foo: 'foobar' })!; + + expect([...pool.items()]).toEqual([c, b, a]); + pool.free(b); + expect([...pool.items()]).toEqual([c, a]); + }); + it('should iterate using the Symbol.iterator', () => { + const pool = new ObjectPool(Obj, 10); + const a = pool.spawn({ foo: 'bar' }); + const b = pool.spawn({ foo: 'baz' }); + const c = pool.spawn({ foo: 'foobar' }); + const res: Obj[] = []; + + for (const e of pool) { + res.push(e); + } + expect(res).toEqual([c, b, a]); + }); + }); + + describe('toString()', () => { + it('should provide a string represenation', () => { + expect(new ObjectPool(Obj).toString()).toEqual(`[object ObjectPool(0)]`); + expect(new ObjectPool(Obj, 42).toString()).toEqual(`[object ObjectPool(42)]`); + expect(`${new ObjectPool(Obj, 100)}`).toEqual(`[object ObjectPool(100)]`); + }); + }); + + describe('spawn()', () => { + it('should spawn an entity when the pool has space', () => { + const pool = new ObjectPool(Obj, 10); + const a = pool.spawn({ foo: 'bar' }); + const b = pool.spawn({ foo: 'baz' }); + const c = pool.spawn({ foo: 'foobar' }); + + expect(a).toEqual({ foo: 'bar' }); + expect(b).toEqual({ foo: 'baz' }); + expect(c).toEqual({ foo: 'foobar' }); + expect([...pool]).toEqual([c, b, a]); + }); + + it('should not spawn an entity when the pool has no space', () => { + const pool = new ObjectPool(Obj, 2); + const a = pool.spawn({ foo: 'bar' }); + const b = pool.spawn({ foo: 'baz' }); + const c = pool.spawn({ foo: 'foobar' }); + + expect(a).toEqual({ foo: 'bar' }); + expect(b).toEqual({ foo: 'baz' }); + expect(c).toBeUndefined(); + expect([...pool]).toEqual([b, a]); + }); + + it('should not spawn an entity when the pool is empty', () => { + const pool = new ObjectPool(Obj); + const a = pool.spawn({ foo: 'bar' }); + + expect(a).toBeUndefined(); + expect([...pool]).toEqual([]); + }); + }); + + describe('forceSpawn()', () => { + it('should spawn an item normally if pool is not full', () => { + const pool = new ObjectPool(Obj, 10); + const a = pool.forceSpawn({ foo: 'bar' }); + const b = pool.forceSpawn({ foo: 'baz' }); + const c = pool.forceSpawn({ foo: 'foobar' }); + + expect(a).toEqual({ foo: 'bar' }); + expect(b).toEqual({ foo: 'baz' }); + expect(c).toEqual({ foo: 'foobar' }); + expect([...pool]).toEqual([c, b, a]); + }); + it('should expand and spawn when pool is empty', () => { + const pool = new ObjectPool(Obj); + const a = pool.forceSpawn({ foo: 'bar' }); + + expect(pool.size).toBe(1); + expect(a).toEqual({ foo: 'bar' }); + expect(a.poolState.inUse).toBe(true); + // @ts-expect-error + expect(pool._list.tail).toBe(a); + + const b = pool.forceSpawn({ foo: 'baz' }); + + expect(pool.size).toBe(2); + expect(b).toEqual({ foo: 'baz' }); + expect([...pool]).toEqual([b, a]); + }); + it('should expand and spawn when pool is full', () => { + const pool = new ObjectPool(Obj, 3); + pool.spawn({ foo: 'a' }); + pool.spawn({ foo: 'b' }); + pool.spawn({ foo: 'c' }); + + expect(pool.size).toBe(3); + const a = pool.forceSpawn({ foo: 'bar' }); + + expect(pool.size).toBe(4); + expect(a).toEqual({ foo: 'bar' }); + + const b = pool.forceSpawn({ foo: 'baz' }); + + expect(pool.size).toBe(5); + expect(b).toEqual({ foo: 'baz' }); + expect([...pool]).toEqual([b, a, { foo: 'c' }, { foo: 'b' }, { foo: 'a' }]); + }); + }); + + describe('free()', () => { + it('should free up the specified object and move it to the end of the pool', () => { + const pool = new ObjectPool(Obj, 5); + const a = pool.spawn({ foo: 'a' })!; + const b = pool.spawn({ foo: 'b' })!; + const c = pool.spawn({ foo: 'c' })!; + + expect(pool.size).toBe(5); + expect([...pool]).toEqual([c, b, a]); + expect(pool.free(b)).toBe(pool); + expect(b).toEqual({ foo: '' }); + expect([...pool]).toEqual([c, a]); + // @ts-expect-error + expect(pool._list.tail).toBe(b); + expect(pool.free(a)).toBe(pool); + expect(a).toEqual(b); + expect([...pool]).toEqual([c]); + // @ts-expect-error + expect(pool._list.tail).toBe(a); + expect(pool.free(c)).toBe(pool); + expect(c).toEqual(b); + expect([...pool]).toEqual([]); + // @ts-expect-error + expect(pool._list.tail).toBe(c); + }); + }); + + describe('alloc()', () => { + it('should increase the pool size with empty objects', () => { + const pool = new ObjectPool(Obj, 5); + + expect(pool.size).toBe(5); + expect(pool.alloc(5)).toBe(pool); + expect(pool.size).toBe(10); + // @ts-expect-error + expect(pool._list.tail).toEqual({ foo: '' }); + expect(new ObjectPool(Obj).alloc().size).toBe(1); + }); + it('should not do anything when alloc size is <= 0', () => { + const pool = new ObjectPool(Obj, 5); + + expect(pool.size).toBe(5); + expect(pool.alloc(0)).toBe(pool); + expect(pool.size).toBe(5); + expect(pool.alloc(-100)).toBe(pool); + expect(pool.size).toBe(5); + }); + }); + + describe('reallocUnsafe()', () => { + it('should alloc if specified size is larger than current pool size', () => { + const pool = new ObjectPool(Obj, 5); + + expect(pool.size).toBe(5); + expect(pool.reallocUnsafe(10)).toBe(pool); + expect(pool.size).toBe(10); + // @ts-expect-error + expect(pool._list.tail).toEqual({ foo: '' }); + expect(new ObjectPool(Obj, 0).reallocUnsafe().size).toBe(1); + }); + it('should remove objects and clamp list when pool size larger than specified size', () => { + const pool = new ObjectPool(Obj, 10); + const items = Array(10) + .fill(0) + .map((_, i) => pool.spawn({ foo: `${i}` })); + + expect(pool.size).toBe(10); + expect(pool.reallocUnsafe(5)).toBe(pool); + expect(pool.size).toBe(5); + expect([...pool]).toEqual([ + { foo: '9' }, + { foo: '8' }, + { foo: '7' }, + { foo: '6' }, + { foo: '5' }, + ]); + expect(items[4]).toEqual({ foo: '' }); + expect(pool.reallocUnsafe().size).toBe(5); + }); + }); + + describe('realloc()', () => { + it('should alloc if specified size is larger than current pool size', () => { + const pool = new ObjectPool(Obj, 5); + + expect(pool.size).toBe(5); + expect(pool.realloc(10)).toBe(pool); + expect(pool.size).toBe(10); + // @ts-expect-error + expect(pool._list.tail).toEqual({ foo: '' }); + expect(new ObjectPool(Obj, 0).realloc().size).toBe(1); + }); + it('should do nothing if the new size is smaller than the current size', () => { + const pool = new ObjectPool(Obj, 10); + const items = Array(10) + .fill(0) + .map((_, i) => pool.spawn({ foo: `${i}` })); + + expect(pool.size).toBe(10); + expect(pool.realloc(5)).toBe(pool); + expect(pool.size).toBe(10); + expect([...pool]).toEqual(items.reverse()); + expect(pool.realloc().size).toBe(10); + }); + }); + + describe('dealloc()', () => { + it('should reduce max size and pool objects by specified amount', () => { + const pool = new ObjectPool(Obj, 10); + const items = Array(10) + .fill(0) + .map((_, i) => pool.spawn({ foo: `${i}` })); + + expect(pool.size).toBe(10); + expect(pool.dealloc(6)).toBe(pool); + expect(pool.size).toBe(4); + expect([...pool]).toEqual([{ foo: '9' }, { foo: '8' }, { foo: '7' }, { foo: '6' }]); + expect(items[5]).toEqual({ foo: '' }); + expect(pool.dealloc().size).toBe(3); + expect([...pool]).toEqual([{ foo: '9' }, { foo: '8' }, { foo: '7' }]); + expect(pool.dealloc(10).size).toBe(0); + expect([...pool]).toEqual([]); + }); + it('should do nothing if the specified amount is <= 0', () => { + const pool = new ObjectPool(Obj, 10); + + expect(pool.size).toBe(10); + expect(pool.dealloc(0)).toBe(pool); + expect(pool.size).toBe(10); + expect(pool.dealloc(-5)).toBe(pool); + expect(pool.size).toBe(10); + }); + it('should do nothing if the pool is empty', () => { + const pool = new ObjectPool(Obj); + + expect(pool.size).toBe(0); + expect(pool.dealloc(1)).toBe(pool); + expect(pool.size).toBe(0); + }); + }); + + describe('clear()', () => { + const pool = new ObjectPool(Obj, 10); + let dealloc: jest.SpyInstance; + + beforeEach(() => { + dealloc = jest.spyOn(pool, 'dealloc'); + }); + it('should call dealloc with the current pool size', () => { + expect(pool.clear()).toBe(pool); + expect(pool.size).toBe(0); + expect(dealloc).toHaveBeenCalledTimes(1); + expect(dealloc).toHaveBeenCalledWith(10); + expect(pool.clear()).toBe(pool); + expect(dealloc).toHaveBeenCalledTimes(2); + expect(dealloc).toHaveBeenCalledWith(0); + }); + }); + + describe('toJSON()', () => { + it('should return an array of active entities', () => { + const pool = new ObjectPool(Obj, 100); + + expect(JSON.stringify(pool)).toEqual('[]'); + pool.spawn({ foo: 'foo' }); + pool.spawn({ foo: 'bar' }); + expect(JSON.stringify(pool)).toEqual('[{"foo":"bar"},{"foo":"foo"}]'); + }); + }); + + describe('deallocateObject', () => { + it('should return false if no or bad object is provided', () => { + const pool = new ObjectPool(Obj, 10); + + // @ts-expect-error + expect(pool.deallocateObject(null)).toBe(false); + // @ts-expect-error + expect(pool.deallocateObject({ foo: 'foo' })).toBe(false); + }); + }); +}); diff --git a/test/decorators.test.ts b/test/decorators.test.ts new file mode 100644 index 0000000..965d3cf --- /dev/null +++ b/test/decorators.test.ts @@ -0,0 +1,66 @@ +import { decorators } from '../src'; + +describe('describe', () => { + it('should allow currying descriptors', () => { + const desc1 = decorators.describe({ configurable: false })({ writable: false }); + const desc2 = decorators.describe; + + class MyClass { + @desc1 + public readonly foo = 'bar'; + + @desc2() + public readonly bar = 10; + } + + const c = new MyClass(); + + expect(Object.getOwnPropertyDescriptor(c, 'foo')).toEqual({ + configurable: false, + writable: false, + enumerable: true, + value: 'bar', + }); + expect(Object.getOwnPropertyDescriptor(c, 'bar')).toEqual({ + configurable: true, + writable: true, + enumerable: true, + value: 10, + }); + }); +}); + +describe('forceInit', () => { + it('should allow value access during instantiation', () => { + class MyClass { + @decorators.forceInit(() => 'foobar') + public readonly baz!: string; + + constructor() { + expect(Object.getOwnPropertyDescriptor(this, 'baz')).toBeUndefined(); + expect(this.baz).toBe('foobar'); + expect(Object.getOwnPropertyDescriptor(this, 'baz')).toBeDefined(); + } + } + + const c = new MyClass(); + + expect(c.baz).toBe('foobar'); + }); + it('should allow setting descriptors', () => { + class MyClass { + @decorators.forceInit(() => 42, { writable: false, configurable: false, enumerable: false }) + public readonly baz!: number; + } + + const c = new MyClass(); + + expect(c.baz).toBe(42); + expect(Object.getOwnPropertyDescriptor(c, 'baz')).toEqual({ + configurable: false, + writable: false, + enumerable: false, + value: 42, + }); + }); +}); diff --git a/test/tsconfig.json b/test/tsconfig.json new file mode 100644 index 0000000..eff2ea8 --- /dev/null +++ b/test/tsconfig.json @@ -0,0 +1,7 @@ +{ + "extends": "../tsconfig.json", + "compilerOptions": { + "experimentalDecorators": true + }, + "include": ["./**/*.test.ts"] +}