| 1 |
define(["dojo/_base/kernel", "dojo/_base/array", "./_base"], function(dojo, darray, dxc){ |
| 2 |
|
| 3 |
dxc.Queue=function( arr){ |
| 4 |
|
| 5 |
|
| 6 |
var q=[]; |
| 7 |
if (arr){ |
| 8 |
q=q.concat(arr); |
| 9 |
} |
| 10 |
this.count=q.length; |
| 11 |
this.clear=function(){ |
| 12 |
|
| 13 |
|
| 14 |
q=[]; |
| 15 |
this.count=q.length; |
| 16 |
}; |
| 17 |
this.clone=function(){ |
| 18 |
|
| 19 |
|
| 20 |
return new dxc.Queue(q); |
| 21 |
}; |
| 22 |
this.contains=function( o){ |
| 23 |
|
| 24 |
|
| 25 |
for(var i=0; i<q.length; i++){ |
| 26 |
if (q[i]==o){ |
| 27 |
return true; |
| 28 |
} |
| 29 |
} |
| 30 |
return false; |
| 31 |
}; |
| 32 |
this.copyTo=function( arr, i){ |
| 33 |
|
| 34 |
|
| 35 |
arr.splice(i,0,q); |
| 36 |
}; |
| 37 |
this.dequeue=function(){ |
| 38 |
|
| 39 |
|
| 40 |
var r=q.shift(); |
| 41 |
this.count=q.length; |
| 42 |
return r; |
| 43 |
}; |
| 44 |
this.enqueue=function( o){ |
| 45 |
|
| 46 |
|
| 47 |
this.count=q.push(o); |
| 48 |
}; |
| 49 |
this.forEach=function( fn, scope){ |
| 50 |
|
| 51 |
|
| 52 |
dojo.forEach(q, fn, scope); |
| 53 |
}; |
| 54 |
this.getIterator=function(){ |
| 55 |
|
| 56 |
|
| 57 |
return new dxc.Iterator(q); |
| 58 |
}; |
| 59 |
this.peek=function(){ |
| 60 |
|
| 61 |
|
| 62 |
return q[0]; |
| 63 |
}; |
| 64 |
this.toArray=function(){ |
| 65 |
|
| 66 |
|
| 67 |
return [].concat(q); |
| 68 |
}; |
| 69 |
}; |
| 70 |
return dxc.Queue; |
| 71 |
}); |