Subversion Repositories Applications.papyrus

Rev

Rev 1372 | Go to most recent revision | Only display areas with differences | Ignore whitespace | Details | Blame | Last modification | View Log | RSS feed

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