1 if(!dojo._hasResource["dojox.collections.Stack"]){ //_hasResource checks added by build. Do not use _hasResource directly in your code.
2 dojo._hasResource["dojox.collections.Stack"] = true;
3 dojo.provide("dojox.collections.Stack");
4 dojo.require("dojox.collections._base");
6 dojox.collections.Stack=function(/* array? */arr){
8 // returns an object of type dojox.collections.Stack
10 if (arr) q=q.concat(arr);
12 this.clear=function(){
14 // Clear the internal array and reset the count
18 this.clone=function(){
20 // Create and return a clone of this Stack
21 return new dojox.collections.Stack(q);
23 this.contains=function(/* object */o){
25 // check to see if the stack contains object o
26 for (var i=0; i<q.length; i++){
33 this.copyTo=function(/* array */ arr, /* int */ i){
35 // copy the stack into array arr at index i
38 this.forEach=function(/* function */ fn, /* object? */ scope){
40 // functional iterator, following the mozilla spec.
41 dojo.forEach(q, fn, scope);
43 this.getIterator=function(){
45 // get an iterator for this collection
46 return new dojox.collections.Iterator(q); // dojox.collections.Iterator
50 // Return the next item without altering the stack itself.
51 return q[(q.length-1)]; // object
55 // pop and return the next item on the stack
60 this.push=function(/* object */ o){
62 // Push object o onto the stack
65 this.toArray=function(){
67 // create and return an array based on the internal collection
68 return [].concat(q); // array