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 44 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
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(pair.first, pair.last), dar
t.void, [C, utils.Pair$(K, V)])); | 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 => pair.first,
K, [utils.Pair$(K, V)])), 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 => pair.last,
V, [utils.Pair$(K, V)])), 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 |