OLD | NEW |
---|---|
1 // Copyright (c) 2013, the Dart project authors. Please see the AUTHORS file | 1 // Copyright (c) 2013, the Dart project authors. Please see the AUTHORS file |
2 // for details. All rights reserved. Use of this source code is governed by a | 2 // for details. All rights reserved. Use of this source code is governed by a |
3 // BSD-style license that can be found in the LICENSE file. | 3 // BSD-style license that can be found in the LICENSE file. |
4 | 4 |
5 library web_ui.observe.map; | 5 library web_ui.observe.map; |
6 | 6 |
7 import 'dart:collection'; | 7 import 'dart:collection'; |
8 import 'observable.dart'; | 8 import 'observable.dart'; |
9 | 9 |
10 typedef Map<K, V> MapFactory<K, V>(); | 10 typedef Map<K, V> MapFactory<K, V>(); |
(...skipping 25 matching lines...) Expand all Loading... | |
36 // TODO(jmesserly): removed type annotation to workaround: | 36 // TODO(jmesserly): removed type annotation to workaround: |
37 // https://code.google.com/p/dart/issues/detail?id=11540 | 37 // https://code.google.com/p/dart/issues/detail?id=11540 |
38 ObservableMap.linked() : this(createMap: () => new LinkedHashMap/*<K, V>*/()); | 38 ObservableMap.linked() : this(createMap: () => new LinkedHashMap/*<K, V>*/()); |
39 | 39 |
40 /** Creates a new observable map using a [SplayTreeMap]. */ | 40 /** Creates a new observable map using a [SplayTreeMap]. */ |
41 ObservableMap.sorted() : this(createMap: () => new SplayTreeMap/*<K, V>*/()); | 41 ObservableMap.sorted() : this(createMap: () => new SplayTreeMap/*<K, V>*/()); |
42 | 42 |
43 /** | 43 /** |
44 * Creates an observable map that contains all key value pairs of [other]. | 44 * Creates an observable map that contains all key value pairs of [other]. |
45 */ | 45 */ |
46 factory ObservableMap.from(Map<K, V> other, {MapFactory<K, V> createMap}) { | 46 factory ObservableMap.from(Map/*<K, V>*/ other, {MapFactory/*<K, V>*/ createMa p}) { |
Siggi Cherem (dart-lang)
2013/08/05 22:02:06
80 col
Jennifer Messerly
2013/08/06 16:35:33
Done.
| |
47 var result = new ObservableMap<K, V>(createMap: createMap); | 47 var result = new ObservableMap/*<K, V>*/(createMap: createMap); |
48 other.forEach((K key, V value) { result[key] = value; }); | 48 other.forEach((/*K*/ key, /*V*/value) { result[key] = value; }); |
49 return result; | 49 return result; |
50 } | 50 } |
51 | 51 |
52 | 52 |
53 Iterable<K> get keys => _keys; | 53 Iterable<K> get keys => _keys; |
54 | 54 |
55 Iterable<V> get values => _values; | 55 Iterable<V> get values => _values; |
56 | 56 |
57 int get length { | 57 int get length { |
58 if (observeReads) notifyRead(this, ChangeRecord.FIELD, 'length'); | 58 if (observeReads) notifyRead(this, ChangeRecord.FIELD, 'length'); |
(...skipping 142 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... | |
201 throw new StateError('keys and values should be the same length'); | 201 throw new StateError('keys and values should be the same length'); |
202 } | 202 } |
203 return _hasNext = moreValues; | 203 return _hasNext = moreValues; |
204 } | 204 } |
205 | 205 |
206 V get current { | 206 V get current { |
207 if (observeReads && _hasNext) _map._notifyReadKey(_keys.current); | 207 if (observeReads && _hasNext) _map._notifyReadKey(_keys.current); |
208 return _values.current; | 208 return _values.current; |
209 } | 209 } |
210 } | 210 } |
OLD | NEW |