Subversion Repositories Applications.papyrus

Rev

Rev 1318 | Only display areas with differences | Ignore whitespace | Details | Blame | Last modification | View Log | RSS feed

Rev 1318 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.Collections");
13
dojo.provide("dojo.collections.Collections");
12
dojo.collections.DictionaryEntry = function (k, v) {
14
dojo.collections.DictionaryEntry = function (k, v) {
13
	this.key = k;
15
	this.key = k;
14
	this.value = v;
16
	this.value = v;
15
	this.valueOf = function () {
17
	this.valueOf = function () {
16
		return this.value;
18
		return this.value;
17
	};
19
	};
18
	this.toString = function () {
20
	this.toString = function () {
19
		return String(this.value);
21
		return String(this.value);
20
	};
22
	};
21
};
23
};
22
dojo.collections.Iterator = function (arr) {
24
dojo.collections.Iterator = function (arr) {
23
	var a = arr;
25
	var a = arr;
24
	var position = 0;
26
	var position = 0;
25
	this.element = a[position] || null;
27
	this.element = a[position] || null;
26
	this.atEnd = function () {
28
	this.atEnd = function () {
27
		return (position >= a.length);
29
		return (position >= a.length);
28
	};
30
	};
29
	this.get = function () {
31
	this.get = function () {
30
		if (this.atEnd()) {
32
		if (this.atEnd()) {
31
			return null;
33
			return null;
32
		}
34
		}
33
		this.element = a[position++];
35
		this.element = a[position++];
34
		return this.element;
36
		return this.element;
35
	};
37
	};
36
	this.map = function (fn, scope) {
38
	this.map = function (fn, scope) {
37
		var s = scope || dj_global;
39
		var s = scope || dj_global;
38
		if (Array.map) {
40
		if (Array.map) {
39
			return Array.map(a, fn, s);
41
			return Array.map(a, fn, s);
40
		} else {
42
		} else {
41
			var arr = [];
43
			var arr = [];
42
			for (var i = 0; i < a.length; i++) {
44
			for (var i = 0; i < a.length; i++) {
43
				arr.push(fn.call(s, a[i]));
45
				arr.push(fn.call(s, a[i]));
44
			}
46
			}
45
			return arr;
47
			return arr;
46
		}
48
		}
47
	};
49
	};
48
	this.reset = function () {
50
	this.reset = function () {
49
		position = 0;
51
		position = 0;
50
		this.element = a[position];
52
		this.element = a[position];
51
	};
53
	};
52
};
54
};
53
dojo.collections.DictionaryIterator = function (obj) {
55
dojo.collections.DictionaryIterator = function (obj) {
54
	var a = [];
56
	var a = [];
55
	var testObject = {};
57
	var testObject = {};
56
	for (var p in obj) {
58
	for (var p in obj) {
57
		if (!testObject[p]) {
59
		if (!testObject[p]) {
58
			a.push(obj[p]);
60
			a.push(obj[p]);
59
		}
61
		}
60
	}
62
	}
61
	var position = 0;
63
	var position = 0;
62
	this.element = a[position] || null;
64
	this.element = a[position] || null;
63
	this.atEnd = function () {
65
	this.atEnd = function () {
64
		return (position >= a.length);
66
		return (position >= a.length);
65
	};
67
	};
66
	this.get = function () {
68
	this.get = function () {
67
		if (this.atEnd()) {
69
		if (this.atEnd()) {
68
			return null;
70
			return null;
69
		}
71
		}
70
		this.element = a[position++];
72
		this.element = a[position++];
71
		return this.element;
73
		return this.element;
72
	};
74
	};
73
	this.map = function (fn, scope) {
75
	this.map = function (fn, scope) {
74
		var s = scope || dj_global;
76
		var s = scope || dj_global;
75
		if (Array.map) {
77
		if (Array.map) {
76
			return Array.map(a, fn, s);
78
			return Array.map(a, fn, s);
77
		} else {
79
		} else {
78
			var arr = [];
80
			var arr = [];
79
			for (var i = 0; i < a.length; i++) {
81
			for (var i = 0; i < a.length; i++) {
80
				arr.push(fn.call(s, a[i]));
82
				arr.push(fn.call(s, a[i]));
81
			}
83
			}
82
			return arr;
84
			return arr;
83
		}
85
		}
84
	};
86
	};
85
	this.reset = function () {
87
	this.reset = function () {
86
		position = 0;
88
		position = 0;
87
		this.element = a[position];
89
		this.element = a[position];
88
	};
90
	};
89
};
91
};
90
 
92