Project

General

Profile

Statistics
| Revision:

root / trunk / web / dojo / dojox / collections / Dictionary.js @ 10

History | View | Annotate | Download (1.63 KB)

1 9 andrej.cim
/*
2
        Copyright (c) 2004-2010, The Dojo Foundation All Rights Reserved.
3
        Available via Academic Free License >= 2.1 OR the modified BSD license.
4
        see: http://dojotoolkit.org/license for details
5
*/
6
7
8
if(!dojo._hasResource["dojox.collections.Dictionary"]){
9
dojo._hasResource["dojox.collections.Dictionary"]=true;
10
dojo.provide("dojox.collections.Dictionary");
11
dojo.require("dojox.collections._base");
12
dojox.collections.Dictionary=function(_1){
13
var _2={};
14
this.count=0;
15
var _3={};
16
this.add=function(k,v){
17
var b=(k in _2);
18
_2[k]=new dojox.collections.DictionaryEntry(k,v);
19
if(!b){
20
this.count++;
21
}
22
};
23
this.clear=function(){
24
_2={};
25
this.count=0;
26
};
27
this.clone=function(){
28
return new dojox.collections.Dictionary(this);
29
};
30
this.contains=this.containsKey=function(k){
31
if(_3[k]){
32
return false;
33
}
34
return (_2[k]!=null);
35
};
36
this.containsValue=function(v){
37
var e=this.getIterator();
38
while(e.get()){
39
if(e.element.value==v){
40
return true;
41
}
42
}
43
return false;
44
};
45
this.entry=function(k){
46
return _2[k];
47
};
48
this.forEach=function(fn,_4){
49
var a=[];
50
for(var p in _2){
51
if(!_3[p]){
52
a.push(_2[p]);
53
}
54
}
55
dojo.forEach(a,fn,_4);
56
};
57
this.getKeyList=function(){
58
return (this.getIterator()).map(function(_5){
59
return _5.key;
60
});
61
};
62
this.getValueList=function(){
63
return (this.getIterator()).map(function(_6){
64
return _6.value;
65
});
66
};
67
this.item=function(k){
68
if(k in _2){
69
return _2[k].valueOf();
70
}
71
return undefined;
72
};
73
this.getIterator=function(){
74
return new dojox.collections.DictionaryIterator(_2);
75
};
76
this.remove=function(k){
77
if(k in _2&&!_3[k]){
78
delete _2[k];
79
this.count--;
80
return true;
81
}
82
return false;
83
};
84
if(_1){
85
var e=_1.getIterator();
86
while(e.get()){
87
this.add(e.element.key,e.element.value);
88
}
89
}
90
};
91
}