Subversion Repositories Applications.papyrus

Rev

Go to most recent revision | Details | Last modification | View Log | RSS feed

Rev Author Line No. Line
1318 alexandre_ 1
/*
2
	Copyright (c) 2004-2006, The Dojo Foundation
3
	All Rights Reserved.
4
 
5
	Licensed under the Academic Free License version 2.1 or above OR the
6
	modified BSD license. For more information on Dojo licensing, see:
7
 
8
		http://dojotoolkit.org/community/licensing.shtml
9
*/
10
 
11
dojo.provide("dojo.collections.Stack");
12
dojo.require("dojo.collections.Collections");
13
dojo.collections.Stack = function (arr) {
14
	var q = [];
15
	if (arr) {
16
		q = q.concat(arr);
17
	}
18
	this.count = q.length;
19
	this.clear = function () {
20
		q = [];
21
		this.count = q.length;
22
	};
23
	this.clone = function () {
24
		return new dojo.collections.Stack(q);
25
	};
26
	this.contains = function (o) {
27
		for (var i = 0; i < q.length; i++) {
28
			if (q[i] == o) {
29
				return true;
30
			}
31
		}
32
		return false;
33
	};
34
	this.copyTo = function (arr, i) {
35
		arr.splice(i, 0, q);
36
	};
37
	this.forEach = function (fn, scope) {
38
		var s = scope || dj_global;
39
		if (Array.forEach) {
40
			Array.forEach(q, fn, s);
41
		} else {
42
			for (var i = 0; i < q.length; i++) {
43
				fn.call(s, q[i], i, q);
44
			}
45
		}
46
	};
47
	this.getIterator = function () {
48
		return new dojo.collections.Iterator(q);
49
	};
50
	this.peek = function () {
51
		return q[(q.length - 1)];
52
	};
53
	this.pop = function () {
54
		var r = q.pop();
55
		this.count = q.length;
56
		return r;
57
	};
58
	this.push = function (o) {
59
		this.count = q.push(o);
60
	};
61
	this.toArray = function () {
62
		return [].concat(q);
63
	};
64
};
65