| 1 |
define(["dojo/_base/kernel", "dojo/_base/lang", "dojo/_base/array"], |
| 2 |
function(dojo, lang, arr){ |
| 3 |
var collections = lang.getObject("dojox.collections", true); |
| 4 |
|
| 5 |
collections.DictionaryEntry=function( k, v){ |
| 6 |
|
| 7 |
|
| 8 |
this.key=k; |
| 9 |
this.value=v; |
| 10 |
this.valueOf=function(){ |
| 11 |
return this.value; |
| 12 |
}; |
| 13 |
this.toString=function(){ |
| 14 |
return String(this.value); |
| 15 |
}; |
| 16 |
} |
| 17 |
|
| 18 |
|
| 19 |
|
| 20 |
|
| 21 |
|
| 22 |
|
| 23 |
collections.Iterator=function( a){ |
| 24 |
|
| 25 |
|
| 26 |
var position=0; |
| 27 |
this.element=a[position]||null; |
| 28 |
this.atEnd=function(){ |
| 29 |
|
| 30 |
|
| 31 |
return (position>=a.length); |
| 32 |
}; |
| 33 |
this.get=function(){ |
| 34 |
|
| 35 |
|
| 36 |
if(this.atEnd()){ |
| 37 |
return null; |
| 38 |
} |
| 39 |
this.element=a[position++]; |
| 40 |
return this.element; |
| 41 |
}; |
| 42 |
this.map=function( fn, scope){ |
| 43 |
|
| 44 |
|
| 45 |
return arr.map(a, fn, scope); |
| 46 |
}; |
| 47 |
this.reset=function(){ |
| 48 |
|
| 49 |
|
| 50 |
position=0; |
| 51 |
this.element=a[position]; |
| 52 |
}; |
| 53 |
} |
| 54 |
|
| 55 |
|
| 56 |
|
| 57 |
|
| 58 |
|
| 59 |
|
| 60 |
collections.DictionaryIterator=function( obj){ |
| 61 |
|
| 62 |
|
| 63 |
var a=[]; |
| 64 |
var testObject={}; |
| 65 |
for(var p in obj){ |
| 66 |
if(!testObject[p]){ |
| 67 |
a.push(obj[p]); |
| 68 |
} |
| 69 |
} |
| 70 |
var position=0; |
| 71 |
this.element=a[position]||null; |
| 72 |
this.atEnd=function(){ |
| 73 |
|
| 74 |
|
| 75 |
return (position>=a.length); |
| 76 |
}; |
| 77 |
this.get=function(){ |
| 78 |
|
| 79 |
|
| 80 |
if(this.atEnd()){ |
| 81 |
return null; |
| 82 |
} |
| 83 |
this.element=a[position++]; |
| 84 |
return this.element; |
| 85 |
}; |
| 86 |
this.map=function( fn, scope){ |
| 87 |
|
| 88 |
|
| 89 |
return arr.map(a, fn, scope); |
| 90 |
}; |
| 91 |
this.reset=function() { |
| 92 |
|
| 93 |
|
| 94 |
position=0; |
| 95 |
this.element=a[position]; |
| 96 |
}; |
| 97 |
}; |
| 98 |
|
| 99 |
return collections; |
| 100 |
}); |