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 21 matching lines...) Expand all Loading... |
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 dart.as(key, K); |
36 dart.as(value, V); | 36 dart.as(value, V); |
37 this[_base].set(dart.as(dart.dcall(this[_canonicalize], key), C), new (u
tils.Pair$(K, V))(key, value)); | 37 this[_base].set(dart.as(dart.dcall(this[_canonicalize], key), C), new (u
tils.Pair$(K, V))(key, value)); |
38 return value; | 38 return value; |
39 } | 39 } |
40 addAll(other) { | 40 addAll(other) { |
41 dart.as(other, core.Map$(K, V)); | 41 dart.as(other, core.Map$(K, V)); |
42 other.forEach(dart.fn((key, value) => this.set(dart.as(key, K), dart.as(
value, V)))); | 42 other.forEach(dart.fn((key, value) => this.set(key, value), V, [K, V])); |
43 } | 43 } |
44 clear() { | 44 clear() { |
45 this[_base].clear(); | 45 this[_base].clear(); |
46 } | 46 } |
47 containsKey(key) { | 47 containsKey(key) { |
48 if (!dart.notNull(this[_isValidKey](key))) return false; | 48 if (!dart.notNull(this[_isValidKey](key))) return false; |
49 return this[_base].containsKey(dart.dcall(this[_canonicalize], key)); | 49 return this[_base].containsKey(dart.dcall(this[_canonicalize], key)); |
50 } | 50 } |
51 containsValue(value) { | 51 containsValue(value) { |
52 return this[_base].values[dartx.any](dart.fn(pair => dart.equals(dart.dl
oad(pair, 'last'), value), core.bool, [dart.dynamic])); | 52 return this[_base].values[dartx.any](dart.fn(pair => dart.equals(pair.la
st, value), core.bool, [utils.Pair$(K, V)])); |
53 } | 53 } |
54 forEach(f) { | 54 forEach(f) { |
55 dart.as(f, dart.functionType(dart.void, [K, V])); | 55 dart.as(f, dart.functionType(dart.void, [K, V])); |
56 this[_base].forEach(dart.fn((key, pair) => f(dart.as(dart.dload(pair, 'f
irst'), K), dart.as(dart.dload(pair, 'last'), V)), dart.void, [dart.dynamic, dar
t.dynamic])); | 56 this[_base].forEach(dart.fn((key, pair) => f(pair.first, pair.last), dar
t.void, [C, utils.Pair$(K, V)])); |
57 } | 57 } |
58 get isEmpty() { | 58 get isEmpty() { |
59 return this[_base].isEmpty; | 59 return this[_base].isEmpty; |
60 } | 60 } |
61 get isNotEmpty() { | 61 get isNotEmpty() { |
62 return this[_base].isNotEmpty; | 62 return this[_base].isNotEmpty; |
63 } | 63 } |
64 get keys() { | 64 get keys() { |
65 return dart.as(this[_base].values[dartx.map](dart.fn(pair => dart.dload(
pair, 'first'))), core.Iterable$(K)); | 65 return this[_base].values[dartx.map](dart.fn(pair => pair.first, K, [uti
ls.Pair$(K, V)])); |
66 } | 66 } |
67 get length() { | 67 get length() { |
68 return this[_base].length; | 68 return this[_base].length; |
69 } | 69 } |
70 putIfAbsent(key, ifAbsent) { | 70 putIfAbsent(key, ifAbsent) { |
71 dart.as(key, K); | 71 dart.as(key, K); |
72 dart.as(ifAbsent, dart.functionType(V, [])); | 72 dart.as(ifAbsent, dart.functionType(V, [])); |
73 return this[_base].putIfAbsent(dart.as(dart.dcall(this[_canonicalize], k
ey), C), dart.fn(() => new (utils.Pair$(K, V))(key, ifAbsent()), utils.Pair$(K,
V), [])).last; | 73 return this[_base].putIfAbsent(dart.as(dart.dcall(this[_canonicalize], k
ey), C), dart.fn(() => new (utils.Pair$(K, V))(key, ifAbsent()), utils.Pair$(K,
V), [])).last; |
74 } | 74 } |
75 remove(key) { | 75 remove(key) { |
76 if (!dart.notNull(this[_isValidKey](key))) return null; | 76 if (!dart.notNull(this[_isValidKey](key))) return null; |
77 let pair = this[_base].remove(dart.dcall(this[_canonicalize], key)); | 77 let pair = this[_base].remove(dart.dcall(this[_canonicalize], key)); |
78 return pair == null ? null : pair.last; | 78 return pair == null ? null : pair.last; |
79 } | 79 } |
80 get values() { | 80 get values() { |
81 return dart.as(this[_base].values[dartx.map](dart.fn(pair => dart.dload(
pair, 'last'))), core.Iterable$(V)); | 81 return this[_base].values[dartx.map](dart.fn(pair => pair.last, V, [util
s.Pair$(K, V)])); |
82 } | 82 } |
83 toString() { | 83 toString() { |
84 return collection.Maps.mapToString(this); | 84 return collection.Maps.mapToString(this); |
85 } | 85 } |
86 [_isValidKey](key) { | 86 [_isValidKey](key) { |
87 return (key == null || dart.is(key, K)) && (this[_isValidKeyFn] == null
|| dart.notNull(dart.as(dart.dcall(this[_isValidKeyFn], key), core.bool))); | 87 return (key == null || dart.is(key, K)) && (this[_isValidKeyFn] == null
|| dart.notNull(dart.as(dart.dcall(this[_isValidKeyFn], key), core.bool))); |
88 } | 88 } |
89 } | 89 } |
90 CanonicalizedMap[dart.implements] = () => [core.Map$(K, V)]; | 90 CanonicalizedMap[dart.implements] = () => [core.Map$(K, V)]; |
91 dart.defineNamedConstructor(CanonicalizedMap, 'from'); | 91 dart.defineNamedConstructor(CanonicalizedMap, 'from'); |
(...skipping 15 matching lines...) Expand all Loading... |
107 [_isValidKey]: [core.bool, [core.Object]] | 107 [_isValidKey]: [core.bool, [core.Object]] |
108 }) | 108 }) |
109 }); | 109 }); |
110 return CanonicalizedMap; | 110 return CanonicalizedMap; |
111 }); | 111 }); |
112 let CanonicalizedMap = CanonicalizedMap$(); | 112 let CanonicalizedMap = CanonicalizedMap$(); |
113 // Exports: | 113 // Exports: |
114 exports.CanonicalizedMap$ = CanonicalizedMap$; | 114 exports.CanonicalizedMap$ = CanonicalizedMap$; |
115 exports.CanonicalizedMap = CanonicalizedMap; | 115 exports.CanonicalizedMap = CanonicalizedMap; |
116 }); | 116 }); |
OLD | NEW |