Collections_wev8.js
1.83 KB
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
73
74
/*
Copyright (c) 2004-2005, The Dojo Foundation
All Rights Reserved.
Licensed under the Academic Free License version 2.1 or above OR the
modified BSD license. For more information on Dojo licensing, see:
http://dojotoolkit.org/community/licensing.shtml
*/
dojo.provide("dojo.collections.Collections");
dojo.collections = {Collections:true};
dojo.collections.DictionaryEntry = function(k,v){
this.key = k;
this.value = v;
this.valueOf = function(){ return this.value; };
this.toString = function(){ return this.value; };
}
dojo.collections.Iterator = function(a){
var obj = a;
var position = 0;
this.atEnd = (position>=obj.length-1);
this.current = obj[position];
this.moveNext = function(){
if(++position>=obj.length){
this.atEnd = true;
}
if(this.atEnd){
return false;
}
this.current=obj[position];
return true;
}
this.reset = function(){
position = 0;
this.atEnd = false;
this.current = obj[position];
}
}
dojo.collections.DictionaryIterator = function(obj){
var arr = [] ; // Create an indexing array
for (var p in obj) arr.push(obj[p]) ; // fill it up
var position = 0 ;
this.atEnd = (position>=arr.length-1);
this.current = arr[position]||null ;
this.entry = this.current||null ;
this.key = (this.entry)?this.entry.key:null ;
this.value = (this.entry)?this.entry.value:null ;
this.moveNext = function() {
if (++position>=arr.length) {
this.atEnd = true ;
}
if(this.atEnd){
return false;
}
this.entry = this.current = arr[position] ;
if (this.entry) {
this.key = this.entry.key ;
this.value = this.entry.value ;
}
return true;
} ;
this.reset = function() {
position = 0 ;
this.atEnd = false ;
this.current = arr[position]||null ;
this.entry = this.current||null ;
this.key = (this.entry)?this.entry.key:null ;
this.value = (this.entry)?this.entry.value:null ;
} ;
};