# Differences

This shows you the differences between two versions of the page.

 algorithm:queue_list-based [2014/07/12 22:25]will created algorithm:queue_list-based [2016/04/03 00:21] (current)will Updated tests. 2016/04/03 00:21 will Updated tests.2015/02/02 08:28 external edit2015/01/29 21:20 will 2015/01/29 09:37 will 2014/07/26 23:42 will 2014/07/12 22:26 will 2014/07/12 22:25 will created Next revision Previous revision 2016/04/03 00:21 will Updated tests.2015/02/02 08:28 external edit2015/01/29 21:20 will 2015/01/29 09:37 will 2014/07/26 23:42 will 2014/07/12 22:26 will 2014/07/12 22:25 will created Line 1: Line 1: - [algorithm Queue_list-based] + ======= λ Queue list-based ​====== - ====== Algorithm ====== + <​nowiki>​ + ======= Algorithm ​======= function Queue() { function Queue() { Line 34: Line 35: } } } } - return popped; + return popped? popped.data : null; } } - } + }​ - ​ + - ====== Support ====== + ======= Support ​======= // Initial starting queue. // Initial starting queue. Line 59: Line 59: ​ - ====== Options ====== + ======= Tests ======= + + function testA() { + var q = new Queue(); + q.enqueue(1);​ + q.enqueue(2);​ + q.enqueue(3);​ + + assert(q.dequeue() === 1); + assert(q.dequeue() === 2); + assert(q.dequeue() === 3); + assert(q.dequeue() === null, "End of queue."​);​ + } + + function testB() { + var q = new Queue(); + q.enqueue(1);​ + q.enqueue(2);​ + + assert(q.dequeue() === 1); + + q.enqueue(3);​ + q.enqueue(4);​ + + assert(q.dequeue() === 2); + + q.enqueue(5);​ + + assert(q.dequeue() === 3); + assert(q.dequeue() === 4); + assert(q.dequeue() === 5); + assert(q.dequeue() === null, "End of queue."​);​ + }​ + + ======= Options ​======= { { - "​height":​ "480px", + ​"​title":​ "Queue list-based",​ + ​"​height":​ "450px", "​preRunSource":​ true, "​preRunSource":​ true, "​persistentGlobals":​ ["​queue"​] "​persistentGlobals":​ ["​queue"​] Line 68: Line 103: ​ - ====== Visualisation ====== + ======= Visualisation ​======= <​html>​ <​html>​ <​head>​ <​head>​
algorithm/queue_list-based.1405229119.txt.gz · Last modified: 2015/02/02 08:23 (external edit)