Dictionary_wev8.js
1.55 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
75
76
/*
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.Dictionary");
dojo.require("dojo.collections.Collections");
dojo.collections.Dictionary = function(dictionary){
var items = {};
this.count = 0;
this.add = function(k,v){
items[k] = new dojo.collections.DictionaryEntry(k,v);
this.count++;
};
this.clear = function(){
items = {};
this.count = 0;
};
this.clone = function(){
return new dojo.collections.Dictionary(this);
};
this.contains = this.containsKey = function(k){
return (items[k] != null);
};
this.containsValue = function(v){
var e = this.getIterator();
while (!e.atEnd) {
if (e.value == v) return true;
e.moveNext();
}
return false;
};
this.getKeyList = function(){
var arr = [];
var e = this.getIterator();
while (!e.atEnd) {
arr.push(e.key);
e.moveNext();
}
return arr;
};
this.getValueList = function(){
var arr = [];
var e = this.getIterator();
while (!e.atEnd) {
arr.push(e.value);
e.moveNext();
}
return arr;
};
this.item = function(k){
return items[k];
};
this.getIterator = function(){
return new dojo.collections.DictionaryIterator(items);
};
this.remove = function(k){
delete items[k];
this.count--;
};
if (dictionary){
var e = dictionary.getIterator();
while (!e.atEnd) {
this.add(e.key, e.value);
e.moveNext();
}
}
};