Chromium Code Reviews| OLD | NEW |
|---|---|
| (Empty) | |
| 1 // Copyright (c) 2012, 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 class $CLASSNAME$EXTENDS$IMPLEMENTS$NATIVESPEC { | |
| 6 | |
| 7 // TODO(nweiz): update this when maps support lazy iteration | |
| 8 bool containsValue(String value) => getValues().some((e) => e == value); | |
| 9 | |
| 10 bool containsKey(String key) => getItem(key) != null; | |
|
Jacob
2012/04/02 21:06:41
you should make getItem private
by adding it to th
nweiz
2012/04/02 22:32:14
Done.
| |
| 11 | |
| 12 String operator [](String key) => getItem(key); | |
| 13 | |
| 14 void operator []=(String key, String value) => setItem(key, value); | |
| 15 | |
| 16 String putIfAbsent(String key, String ifAbsent()) { | |
| 17 if (!containsKey(key)) this[key] = ifAbsent(); | |
| 18 return this[key]; | |
| 19 } | |
| 20 | |
| 21 String remove(String key) { | |
| 22 final value = this[key]; | |
| 23 removeItem(key); | |
| 24 return value; | |
| 25 } | |
| 26 | |
| 27 void forEach(void f(String key, String value)) { | |
| 28 for (var i = 0; true; i++) { | |
| 29 final key = key(i); | |
| 30 if (key == null) return; | |
| 31 | |
| 32 f(key, this[key]); | |
| 33 } | |
| 34 } | |
| 35 | |
| 36 Collection<String> getKeys() { | |
| 37 final keys = []; | |
| 38 forEach((k, v) => keys.add(k)); | |
| 39 return keys; | |
| 40 } | |
| 41 | |
| 42 Collection<String> getValues() { | |
| 43 final values = []; | |
| 44 forEach((k, v) => values.add(v)); | |
| 45 return values; | |
| 46 } | |
| 47 | |
| 48 bool isEmpty() => key(0) == null; | |
| 49 $!MEMBERS | |
| 50 } | |
| OLD | NEW |