root / trunk / web / dojo / dojox / collections / Stack.js @ 12
History | View | Annotate | Download (1.07 KB)
1 | 9 | andrej.cim | /*
|
---|---|---|---|
2 | Copyright (c) 2004-2010, The Dojo Foundation All Rights Reserved.
|
||
3 | Available via Academic Free License >= 2.1 OR the modified BSD license.
|
||
4 | see: http://dojotoolkit.org/license for details
|
||
5 | */
|
||
6 | |||
7 | |||
8 | if(!dojo._hasResource["dojox.collections.Stack"]){ |
||
9 | dojo._hasResource["dojox.collections.Stack"]=true; |
||
10 | dojo.provide("dojox.collections.Stack");
|
||
11 | dojo.require("dojox.collections._base");
|
||
12 | dojox.collections.Stack=function(_1){ |
||
13 | var q=[];
|
||
14 | if(_1){
|
||
15 | q=q.concat(_1); |
||
16 | } |
||
17 | this.count=q.length;
|
||
18 | this.clear=function(){ |
||
19 | q=[]; |
||
20 | this.count=q.length;
|
||
21 | }; |
||
22 | this.clone=function(){ |
||
23 | return new dojox.collections.Stack(q); |
||
24 | }; |
||
25 | this.contains=function(o){ |
||
26 | for(var i=0;i<q.length;i++){ |
||
27 | if(q[i]==o){
|
||
28 | return true; |
||
29 | } |
||
30 | } |
||
31 | return false; |
||
32 | }; |
||
33 | this.copyTo=function(_2,i){ |
||
34 | _2.splice(i,0,q);
|
||
35 | }; |
||
36 | this.forEach=function(fn,_3){ |
||
37 | dojo.forEach(q,fn,_3); |
||
38 | }; |
||
39 | this.getIterator=function(){ |
||
40 | return new dojox.collections.Iterator(q); |
||
41 | }; |
||
42 | this.peek=function(){ |
||
43 | return q[(q.length-1)]; |
||
44 | }; |
||
45 | this.pop=function(){ |
||
46 | var r=q.pop();
|
||
47 | this.count=q.length;
|
||
48 | return r;
|
||
49 | }; |
||
50 | this.push=function(o){ |
||
51 | this.count=q.push(o);
|
||
52 | }; |
||
53 | this.toArray=function(){ |
||
54 | return [].concat(q);
|
||
55 | }; |
||
56 | }; |
||
57 | } |