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 24 matching lines...) Expand all Loading... |
35 (() => { | 35 (() => { |
36 dart.as(key, K); | 36 dart.as(key, K); |
37 dart.as(value, V); | 37 dart.as(value, V); |
38 if (!dart.notNull(this[_isValidKey](key))) return; | 38 if (!dart.notNull(this[_isValidKey](key))) return; |
39 this[_base][dartx.set](dart.as(dart.dcall(this[_canonicalize], key), C
), new (utils.Pair$(K, V))(key, value)); | 39 this[_base][dartx.set](dart.as(dart.dcall(this[_canonicalize], key), C
), new (utils.Pair$(K, V))(key, value)); |
40 })(); | 40 })(); |
41 return value; | 41 return value; |
42 } | 42 } |
43 addAll(other) { | 43 addAll(other) { |
44 dart.as(other, core.Map$(K, V)); | 44 dart.as(other, core.Map$(K, V)); |
45 other[dartx.forEach](dart.fn((key, value) => this.set(key, value), V, [K
, V])); | 45 other[dartx.forEach](dart.fn((key, value) => { |
| 46 dart.as(key, K); |
| 47 dart.as(value, V); |
| 48 return this.set(key, value); |
| 49 }, V, [K, V])); |
46 } | 50 } |
47 clear() { | 51 clear() { |
48 this[_base][dartx.clear](); | 52 this[_base][dartx.clear](); |
49 } | 53 } |
50 containsKey(key) { | 54 containsKey(key) { |
51 if (!dart.notNull(this[_isValidKey](key))) return false; | 55 if (!dart.notNull(this[_isValidKey](key))) return false; |
52 return this[_base][dartx.containsKey](dart.dcall(this[_canonicalize], ke
y)); | 56 return this[_base][dartx.containsKey](dart.dcall(this[_canonicalize], ke
y)); |
53 } | 57 } |
54 containsValue(value) { | 58 containsValue(value) { |
55 return this[_base][dartx.values][dartx.any](dart.fn(pair => dart.equals(
pair.last, value), core.bool, [utils.Pair$(K, V)])); | 59 return this[_base][dartx.values][dartx.any](dart.fn(pair => { |
| 60 dart.as(pair, utils.Pair$(K, V)); |
| 61 return dart.equals(pair.last, value); |
| 62 }, core.bool, [utils.Pair$(K, V)])); |
56 } | 63 } |
57 forEach(f) { | 64 forEach(f) { |
58 dart.as(f, dart.functionType(dart.void, [K, V])); | 65 dart.as(f, dart.functionType(dart.void, [K, V])); |
59 this[_base][dartx.forEach](dart.fn((key, pair) => f(pair.first, pair.las
t), dart.void, [C, utils.Pair$(K, V)])); | 66 this[_base][dartx.forEach](dart.fn((key, pair) => { |
| 67 dart.as(key, C); |
| 68 dart.as(pair, utils.Pair$(K, V)); |
| 69 return f(pair.first, pair.last); |
| 70 }, dart.void, [C, utils.Pair$(K, V)])); |
60 } | 71 } |
61 get isEmpty() { | 72 get isEmpty() { |
62 return this[_base][dartx.isEmpty]; | 73 return this[_base][dartx.isEmpty]; |
63 } | 74 } |
64 get isNotEmpty() { | 75 get isNotEmpty() { |
65 return this[_base][dartx.isNotEmpty]; | 76 return this[_base][dartx.isNotEmpty]; |
66 } | 77 } |
67 get keys() { | 78 get keys() { |
68 return this[_base][dartx.values][dartx.map](dart.fn(pair => pair.first,
K, [utils.Pair$(K, V)])); | 79 return this[_base][dartx.values][dartx.map](dart.fn(pair => { |
| 80 dart.as(pair, utils.Pair$(K, V)); |
| 81 return pair.first; |
| 82 }, K, [utils.Pair$(K, V)])); |
69 } | 83 } |
70 get length() { | 84 get length() { |
71 return this[_base][dartx.length]; | 85 return this[_base][dartx.length]; |
72 } | 86 } |
73 putIfAbsent(key, ifAbsent) { | 87 putIfAbsent(key, ifAbsent) { |
74 dart.as(key, K); | 88 dart.as(key, K); |
75 dart.as(ifAbsent, dart.functionType(V, [])); | 89 dart.as(ifAbsent, dart.functionType(V, [])); |
76 return this[_base][dartx.putIfAbsent](dart.as(dart.dcall(this[_canonical
ize], key), C), dart.fn(() => new (utils.Pair$(K, V))(key, ifAbsent()), utils.Pa
ir$(K, V), [])).last; | 90 return this[_base][dartx.putIfAbsent](dart.as(dart.dcall(this[_canonical
ize], key), C), dart.fn(() => new (utils.Pair$(K, V))(key, ifAbsent()), utils.Pa
ir$(K, V), [])).last; |
77 } | 91 } |
78 remove(key) { | 92 remove(key) { |
79 if (!dart.notNull(this[_isValidKey](key))) return null; | 93 if (!dart.notNull(this[_isValidKey](key))) return null; |
80 let pair = this[_base][dartx.remove](dart.dcall(this[_canonicalize], key
)); | 94 let pair = this[_base][dartx.remove](dart.dcall(this[_canonicalize], key
)); |
81 return pair == null ? null : pair.last; | 95 return pair == null ? null : pair.last; |
82 } | 96 } |
83 get values() { | 97 get values() { |
84 return this[_base][dartx.values][dartx.map](dart.fn(pair => pair.last, V
, [utils.Pair$(K, V)])); | 98 return this[_base][dartx.values][dartx.map](dart.fn(pair => { |
| 99 dart.as(pair, utils.Pair$(K, V)); |
| 100 return pair.last; |
| 101 }, V, [utils.Pair$(K, V)])); |
85 } | 102 } |
86 toString() { | 103 toString() { |
87 return collection.Maps.mapToString(this); | 104 return collection.Maps.mapToString(this); |
88 } | 105 } |
89 [_isValidKey](key) { | 106 [_isValidKey](key) { |
90 return (key == null || dart.is(key, K)) && (this[_isValidKeyFn] == null
|| dart.notNull(dart.as(dart.dcall(this[_isValidKeyFn], key), core.bool))); | 107 return (key == null || dart.is(key, K)) && (this[_isValidKeyFn] == null
|| dart.notNull(dart.as(dart.dcall(this[_isValidKeyFn], key), core.bool))); |
91 } | 108 } |
92 } | 109 } |
93 CanonicalizedMap[dart.implements] = () => [core.Map$(K, V)]; | 110 CanonicalizedMap[dart.implements] = () => [core.Map$(K, V)]; |
94 dart.defineNamedConstructor(CanonicalizedMap, 'from'); | 111 dart.defineNamedConstructor(CanonicalizedMap, 'from'); |
(...skipping 31 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
126 'length', | 143 'length', |
127 'values' | 144 'values' |
128 ]); | 145 ]); |
129 return CanonicalizedMap; | 146 return CanonicalizedMap; |
130 }); | 147 }); |
131 let CanonicalizedMap = CanonicalizedMap$(); | 148 let CanonicalizedMap = CanonicalizedMap$(); |
132 // Exports: | 149 // Exports: |
133 exports.CanonicalizedMap$ = CanonicalizedMap$; | 150 exports.CanonicalizedMap$ = CanonicalizedMap$; |
134 exports.CanonicalizedMap = CanonicalizedMap; | 151 exports.CanonicalizedMap = CanonicalizedMap; |
135 }); | 152 }); |
OLD | NEW |