1 if(!dojo._hasResource["dojox.collections._base"]){ //_hasResource checks added by build. Do not use _hasResource directly in your code.
2 dojo._hasResource["dojox.collections._base"] = true;
3 dojo.provide("dojox.collections._base");
5 dojox.collections.DictionaryEntry=function(/* string */k, /* object */v){
7 // return an object of type dojox.collections.DictionaryEntry
10 this.valueOf=function(){
11 return this.value; // object
13 this.toString=function(){
14 return String(this.value); // string
19 * The collections.Iterators (Iterator and DictionaryIterator) are built to
20 * work with the Collections included in this module. However, they *can*
21 * be used with arrays and objects, respectively, should one choose to do so.
23 dojox.collections.Iterator=function(/* array */arr){
25 // return an object of type dojox.collections.Iterator
28 this.element=a[position]||null;
29 this.atEnd=function(){
31 // Test to see if the internal cursor has reached the end of the internal collection.
32 return (position>=a.length); // bool
36 // Get the next member in the collection.
38 return null; // object
40 this.element=a[position++];
41 return this.element; // object
43 this.map=function(/* function */fn, /* object? */scope){
45 // Functional iteration with optional scope.
46 return dojo.map(a, fn, scope);
48 this.reset=function(){
50 // reset the internal cursor.
52 this.element=a[position];
57 * The DictionaryIterator no longer supports a key and value property;
58 * the reality is that you can use this to iterate over a JS object
59 * being used as a hashtable.
61 dojox.collections.DictionaryIterator=function(/* object */obj){
63 // return an object of type dojox.collections.DictionaryIterator
64 var a=[]; // Create an indexing array
68 a.push(obj[p]); // fill it up
72 this.element=a[position]||null;
73 this.atEnd=function(){
75 // Test to see if the internal cursor has reached the end of the internal collection.
76 return (position>=a.length); // bool
80 // Get the next member in the collection.
82 return null; // object
84 this.element=a[position++];
85 return this.element; // object
87 this.map=function(/* function */fn, /* object? */scope){
89 // Functional iteration with optional scope.
90 return dojo.map(a, fn, scope);
92 this.reset=function() {
94 // reset the internal cursor.
96 this.element=a[position];