| 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 part of observe; | 5 part of observe; |
| 6 | 6 |
| 7 // TODO(jmesserly): this needs to be faster. We currently require multiple | 7 // TODO(jmesserly): this needs to be faster. We currently require multiple |
| 8 // lookups per key to get the old value. | 8 // lookups per key to get the old value. |
| 9 // TODO(jmesserly): this doesn't implement the precise interfaces like | 9 // TODO(jmesserly): this doesn't implement the precise interfaces like |
| 10 // LinkedHashMap, SplayTreeMap or HashMap. However it can use them for the | 10 // LinkedHashMap, SplayTreeMap or HashMap. However it can use them for the |
| (...skipping 21 matching lines...) Expand all Loading... |
| 32 | 32 |
| 33 MapChangeRecord(this.key, this.oldValue, this.newValue) | 33 MapChangeRecord(this.key, this.oldValue, this.newValue) |
| 34 : isInsert = false, isRemove = false; | 34 : isInsert = false, isRemove = false; |
| 35 | 35 |
| 36 MapChangeRecord.insert(this.key, this.newValue) | 36 MapChangeRecord.insert(this.key, this.newValue) |
| 37 : isInsert = true, isRemove = false; | 37 : isInsert = true, isRemove = false; |
| 38 | 38 |
| 39 MapChangeRecord.remove(this.key, this.oldValue) | 39 MapChangeRecord.remove(this.key, this.oldValue) |
| 40 : isInsert = false, isRemove = true; | 40 : isInsert = false, isRemove = true; |
| 41 | 41 |
| 42 /// *Deprecated* compare [key]s instead. | |
| 43 @deprecated | |
| 44 bool changes(otherKey) => key == otherKey; | |
| 45 | |
| 46 String toString() { | 42 String toString() { |
| 47 var kind = isInsert ? 'insert' : isRemove ? 'remove' : 'set'; | 43 var kind = isInsert ? 'insert' : isRemove ? 'remove' : 'set'; |
| 48 return '#<MapChangeRecord $kind $key from: $oldValue to: $newValue>'; | 44 return '#<MapChangeRecord $kind $key from: $oldValue to: $newValue>'; |
| 49 } | 45 } |
| 50 } | 46 } |
| 51 | 47 |
| 52 /** | 48 /** |
| 53 * Represents an observable map of model values. If any items are added, | 49 * Represents an observable map of model values. If any items are added, |
| 54 * removed, or replaced, then observers that are listening to [changes] | 50 * removed, or replaced, then observers that are listening to [changes] |
| 55 * will be notified. | 51 * will be notified. |
| (...skipping 97 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 153 }); | 149 }); |
| 154 notifyPropertyChange(#length, len, 0); | 150 notifyPropertyChange(#length, len, 0); |
| 155 } | 151 } |
| 156 _map.clear(); | 152 _map.clear(); |
| 157 } | 153 } |
| 158 | 154 |
| 159 void forEach(void f(K key, V value)) => _map.forEach(f); | 155 void forEach(void f(K key, V value)) => _map.forEach(f); |
| 160 | 156 |
| 161 String toString() => Maps.mapToString(this); | 157 String toString() => Maps.mapToString(this); |
| 162 } | 158 } |
| OLD | NEW |