OLD | NEW |
1 dart_library.library('collection/src/canonicalized_map', null, /* Imports */[ | 1 dart_library.library('collection/src/canonicalized_map', null, /* Imports */[ |
2 'dart/_runtime', | 2 'dart/_runtime', |
3 'dart/core', | 3 'dart/core', |
4 'collection/src/utils', | 4 'collection/src/utils', |
5 'dart/collection' | 5 'dart/collection' |
6 ], /* Lazy imports */[ | 6 ], /* Lazy imports */[ |
7 ], function(exports, dart, core, utils, collection) { | 7 ], function(exports, dart, core, utils, collection) { |
8 'use strict'; | 8 'use strict'; |
9 let dartx = dart.dartx; | 9 let dartx = dart.dartx; |
10 const _base = Symbol('_base'); | 10 const _base = Symbol('_base'); |
(...skipping 14 matching lines...) Expand all Loading... |
25 this[_canonicalize] = canonicalize; | 25 this[_canonicalize] = canonicalize; |
26 this[_isValidKeyFn] = isValidKey; | 26 this[_isValidKeyFn] = isValidKey; |
27 this.addAll(other); | 27 this.addAll(other); |
28 } | 28 } |
29 get(key) { | 29 get(key) { |
30 if (!dart.notNull(this[_isValidKey](key))) return null; | 30 if (!dart.notNull(this[_isValidKey](key))) return null; |
31 let pair = this[_base].get(dart.dcall(this[_canonicalize], key)); | 31 let pair = this[_base].get(dart.dcall(this[_canonicalize], key)); |
32 return pair == null ? null : pair.last; | 32 return pair == null ? null : pair.last; |
33 } | 33 } |
34 set(key, value) { | 34 set(key, value) { |
35 dart.as(key, K); | 35 (() => { |
36 dart.as(value, V); | 36 dart.as(key, K); |
37 this[_base].set(dart.as(dart.dcall(this[_canonicalize], key), C), new (u
tils.Pair$(K, V))(key, value)); | 37 dart.as(value, V); |
| 38 if (!dart.notNull(this[_isValidKey](key))) return; |
| 39 this[_base].set(dart.as(dart.dcall(this[_canonicalize], key), C), new
(utils.Pair$(K, V))(key, value)); |
| 40 })(); |
38 return value; | 41 return value; |
39 } | 42 } |
40 addAll(other) { | 43 addAll(other) { |
41 dart.as(other, core.Map$(K, V)); | 44 dart.as(other, core.Map$(K, V)); |
42 other.forEach(dart.fn((key, value) => this.set(key, value), V, [K, V])); | 45 other.forEach(dart.fn((key, value) => this.set(key, value), V, [K, V])); |
43 } | 46 } |
44 clear() { | 47 clear() { |
45 this[_base].clear(); | 48 this[_base].clear(); |
46 } | 49 } |
47 containsKey(key) { | 50 containsKey(key) { |
(...skipping 59 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
107 [_isValidKey]: [core.bool, [core.Object]] | 110 [_isValidKey]: [core.bool, [core.Object]] |
108 }) | 111 }) |
109 }); | 112 }); |
110 return CanonicalizedMap; | 113 return CanonicalizedMap; |
111 }); | 114 }); |
112 let CanonicalizedMap = CanonicalizedMap$(); | 115 let CanonicalizedMap = CanonicalizedMap$(); |
113 // Exports: | 116 // Exports: |
114 exports.CanonicalizedMap$ = CanonicalizedMap$; | 117 exports.CanonicalizedMap$ = CanonicalizedMap$; |
115 exports.CanonicalizedMap = CanonicalizedMap; | 118 exports.CanonicalizedMap = CanonicalizedMap; |
116 }); | 119 }); |
OLD | NEW |