Chromium Code Reviews| OLD | NEW |
|---|---|
| (Empty) | |
| 1 // Copyright (c) 2014, the Dart project authors. Please see the AUTHORS file | |
| 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. | |
| 4 | |
| 5 part of dart2js.helpers; | |
| 6 | |
| 7 typedef void DebugCallback(String methodName, var arg1, var arg2); | |
| 8 | |
| 9 class DebugMap<K, V> implements Map<K, V> { | |
| 10 final Map<K, V> map; | |
| 11 DebugCallback indexSetCallBack; | |
| 12 DebugCallback putIfAbsentCallBack; | |
| 13 | |
| 14 DebugMap(this.map, {DebugCallback addCallback}) { | |
| 15 if (addCallback != null) { | |
| 16 this.addCallback = addCallback; | |
| 17 } | |
| 18 } | |
| 19 | |
| 20 void set addCallback(DebugCallback value) { | |
| 21 indexSetCallBack = value; | |
| 22 putIfAbsentCallBack = value; | |
| 23 } | |
| 24 | |
| 25 bool containsValue(Object value) { | |
| 26 return map.containsValue(value); | |
| 27 } | |
| 28 | |
| 29 bool containsKey(Object key) => map.containsKey(key); | |
| 30 | |
| 31 V operator [](Object key) => map[key]; | |
| 32 | |
| 33 void operator []=(K key, V value) { | |
| 34 if (indexSetCallBack != null) { | |
| 35 indexSetCallBack('[]=', key, value); | |
| 36 } | |
| 37 map[key] = value; | |
| 38 } | |
| 39 | |
| 40 V putIfAbsent(K key, V ifAbsent()) { | |
| 41 return map.putIfAbsent(key, () { | |
| 42 V v = ifAbsent(); | |
|
karlklose
2014/03/25 14:22:18
Indentation is off.
Johnni Winther
2014/03/26 07:35:05
Done.
| |
| 43 if (putIfAbsentCallBack != null) { | |
| 44 putIfAbsentCallBack('putIfAbsent', key, v); | |
| 45 } | |
| 46 return v; | |
| 47 }); | |
| 48 } | |
| 49 | |
| 50 void addAll(Map<K, V> other) => map.addAll(other); | |
| 51 | |
| 52 V remove(Object key) => map.remove(key); | |
| 53 | |
| 54 void clear() => map.clear(); | |
| 55 | |
| 56 void forEach(void f(K key, V value)) => map.forEach(f); | |
| 57 | |
| 58 Iterable<K> get keys => map.keys; | |
| 59 | |
| 60 Iterable<V> get values => map.values; | |
| 61 | |
| 62 int get length => map.length; | |
| 63 | |
| 64 bool get isEmpty => map.isEmpty; | |
| 65 | |
| 66 bool get isNotEmpty => map.isNotEmpty; | |
| 67 } | |
| OLD | NEW |