January 2018
Intermediate to advanced
332 pages
7h 36m
English
To test this queue, you can simply instantiate it and add/remove some items to/from the queue:
var simpleQueue = new Queue();simpleQueue.add(10);simpleQueue.add(20);console.log(simpleQueue.items); // prints undefinedconsole.log(simpleQueue.size()); // prints 2console.log(simpleQueue.remove()); // prints 10console.log(simpleQueue.size()); // prints 1simpleQueue.clear();console.log(simpleQueue.size()); // prints 0
As you can note from the preceding code, all elements are treated the same. Irrespective of the data that they contain, elements are always treated in a FIFO fashion. Although that is a good approach, sometimes we may need something more: the ability to prioritize elements that are coming in and leaving the queue ...
Read now
Unlock full access