Code coverage report for lib/dataStructures/stackQueue.js

Statements: 86.36% (19 / 22)      Branches: 75% (3 / 4)      Functions: 83.33% (5 / 6)      Lines: 90.48% (19 / 21)      Ignored: none     

All files » lib/dataStructures/ » stackQueue.js
1 2 3 4 5 6 7 8 9 10 11 12 13 14 15 16 17 18 19 20 21 22 23 24 25 26 27 28 29 30 31 32 33 34 35 361   1 74 74     1 163 163     1 114   114   114 114 114     1 289     1         1 142     1
var linkedList = require("./linkedList.js");
 
var stackQueue = function(){
	this.list = new linkedList();
	this.length = 0;
};
 
stackQueue.prototype.push = function(data) {
	this.list.add(data);
	this.length++;
};
 
stackQueue.prototype.pop = function() {
	Iif(this.isEmpty()) throw "The stack/queue is empty"
 
	var results = this.peek()
 
	this.list.remove(results);
	this.length--;
	return results;
};
 
stackQueue.prototype.isEmpty = function() {
    return this.length === 0;
}
 
stackQueue.prototype.clear = function() {
	this.list = new linkedList();
	this.length = 0;
}
 
stackQueue.prototype.peek = function() {
    return this.isEmpty() ? null : this.getNext();
}
 
module.exports = stackQueue;