@practicaljs/priority-queue
Advanced tools
+6
-1
| { | ||
| "name": "@practicaljs/priority-queue", | ||
| "version": "1.0.0", | ||
| "version": "1.1.0", | ||
| "license": "MIT", | ||
| "type": "module", | ||
| "author": { | ||
| "name": "Harlen Alvarez", | ||
| "email": "halvarez18@msn.com", | ||
| "url": "https://github.com/harlenalvarez" | ||
| }, | ||
| "description": "Javascript / Typescript priority queue ( max / min heap )", | ||
@@ -7,0 +12,0 @@ "exports": { |
+25
-1
@@ -121,2 +121,26 @@ <a name="readme-top"></a> | ||
| //[{ name: 'Special - House Music', time: 22 }, { name: 'Special - Live Music', time: 23 }, { name: 'breakfast', time: 7}...] | ||
| ``` | ||
| ``` | ||
| You can also check and remove specific items if you provide a key to track | ||
| ```ts | ||
| const foodLikes = [ | ||
| { name: 'sushi', rating: 4 }, | ||
| { name: 'chicken', rating: 4 }, | ||
| { name: 'beef', rating: 5 }, | ||
| { name: 'pork', rating: 1 } | ||
| ]; | ||
| // we'll track our objects by name ( this makes name unique ) | ||
| const queue = new PriorityQueue<typeof foodLikes[0]>( | ||
| (a, b) => a.rating - b.rating, | ||
| // Method takes the item and must return a string | ||
| (item) => item.name | ||
| ); | ||
| for (let food of foodLikes) { | ||
| queue.enqueue(food); | ||
| } | ||
| // you can check if an item exists ( only if the key method was provided ) | ||
| if(queue.hasItem(foodLikes[3])) | ||
| const pork = queue.dequeueItem(foodLikes[3]); | ||
| ``` | ||
| > If you provide a key to track it will also check for uniqueness when enqueing items and ignore if the item you are adding already exists and it's comparison value is the same |
No contributors or author data
MaintenancePackage does not specify a list of contributors or an author in package.json.
Found 1 instance in 1 package
10474
11.15%1
-50%145
19.83%