Added get method to the queue helper JS

This commit is contained in:
Aktanusa
2016-03-27 22:59:43 -04:00
parent b7666cca6d
commit f44d03c4c7

View File

@@ -67,4 +67,16 @@ function Queue(){
return (queue.length > 0 ? queue[offset] : undefined); return (queue.length > 0 ? queue[offset] : undefined);
} }
/* Returns the item at the spot specified by place in the queue (without
* dequeuing it). If the queue is emprty or the requested place is outside
* the queue length then undefined is returned.
*/
this.get = function(place){
var item = undefined;
if (queue.length > 0 && place < (queue.length - offset)) {
item = queue[(offset + place)];
}
return item;
}
} }