Skip to content

Commit

Permalink
IfQueue
Browse files Browse the repository at this point in the history
  • Loading branch information
make-github-pseudonymous-again committed May 2, 2015
1 parent 72b1553 commit adc2ba4
Show file tree
Hide file tree
Showing 6 changed files with 155 additions and 6 deletions.
88 changes: 85 additions & 3 deletions js/dist/fifo.js
Original file line number Diff line number Diff line change
@@ -1,6 +1,8 @@
(function(exports, undefined){
( function ( ) {

'use strict';
'use strict' ;

var definition = function ( exports , undefined ) {


/* js/src/DllNode.js */
Expand Down Expand Up @@ -76,6 +78,74 @@ DllQueue.prototype.shift = function ( ) {

exports.DllQueue = DllQueue ;

/* js/src/IfQueue.js */

/**
* IfQueue#peek only valid if IfQueue#empty is false.
* IfQueue#shift only valid if IfQueue#empty is false.
*/

var IfQueue = function ( ) {

this.front = null ;
this.back = null ;

} ;

IfQueue.prototype.empty = function ( ) {

return this.front === null ;

} ;

/**
* Only valid if IfQueue#empty is false.
*/

IfQueue.prototype.peek = function ( ) {

return this.front.value ;

} ;

IfQueue.prototype.push = function ( value ) {

if ( this.front === null ) {

this.front = this.back = new Node( value , null ) ;

}

else {

this.back = this.back.next = new Node( value , null ) ;

}

} ;

/**
* Only valid if IfQueue#empty is false.
*/

IfQueue.prototype.shift = function ( ) {

var node ;

node = this.front ;

this.front = node.next ;

// necessary for garbage collector

if ( this.back === node ) this.back = null ;

return node.value ;

} ;

exports.IfQueue = IfQueue ;

/* js/src/Node.js */

var Node = function ( value , next ) {
Expand Down Expand Up @@ -143,4 +213,16 @@ NodeQueue.prototype.shift = function ( ) {

exports.NodeQueue = NodeQueue ;

})(typeof exports === 'undefined' ? this['fifo'] = {} : exports);
return exports ;
} ;
if ( typeof exports === "object" ) {
definition( exports ) ;
}
else if ( typeof define === "function" && define.amd ) {
define( "aureooms-js-fifo" , [ ] , function ( ) { return definition( { } ) ; } ) ;
}
else if ( typeof window === "object" && typeof window.document === "object" ) {
definition( window["fifo"] = { } ) ;
}
else console.error( "unable to detect type of module to define for aureooms-js-fifo") ;
} )( ) ;
2 changes: 1 addition & 1 deletion js/dist/fifo.js.map

Some generated files are not rendered by default. Learn more about how customized files appear on GitHub.

2 changes: 1 addition & 1 deletion js/dist/fifo.min.js

Some generated files are not rendered by default. Learn more about how customized files appear on GitHub.

66 changes: 66 additions & 0 deletions js/src/IfQueue.js
Original file line number Diff line number Diff line change
@@ -0,0 +1,66 @@

/**
* IfQueue#peek only valid if IfQueue#empty is false.
* IfQueue#shift only valid if IfQueue#empty is false.
*/

var IfQueue = function ( ) {

this.front = null ;
this.back = null ;

} ;

IfQueue.prototype.empty = function ( ) {

return this.front === null ;

} ;

/**
* Only valid if IfQueue#empty is false.
*/

IfQueue.prototype.peek = function ( ) {

return this.front.value ;

} ;

IfQueue.prototype.push = function ( value ) {

if ( this.front === null ) {

this.front = this.back = new Node( value , null ) ;

}

else {

this.back = this.back.next = new Node( value , null ) ;

}

} ;

/**
* Only valid if IfQueue#empty is false.
*/

IfQueue.prototype.shift = function ( ) {

var node ;

node = this.front ;

this.front = node.next ;

// necessary for garbage collector

if ( this.back === node ) this.back = null ;

return node.value ;

} ;

exports.IfQueue = IfQueue ;
2 changes: 1 addition & 1 deletion package.json
Original file line number Diff line number Diff line change
Expand Up @@ -15,7 +15,7 @@
"name": "aureooms-js-fifo",
"version": "1.0.0",
"devDependencies": {
"aureooms-node-package": "^4.1.0"
"aureooms-node-package": "^4.2.3"
},
"dependencies": {},
"license": "AGPL-3.0",
Expand Down
1 change: 1 addition & 0 deletions test/js/src/base.js
Original file line number Diff line number Diff line change
Expand Up @@ -46,3 +46,4 @@ var n = 2500 ;

t( "NodeQueue" , new fifo.NodeQueue( ) , n ) ;
t( "DllQueue" , new fifo.DllQueue( ) , n ) ;
t( "IfQueue" , new fifo.IfQueue( ) , n ) ;

0 comments on commit adc2ba4

Please sign in to comment.