Chromium Code Reviews
chromiumcodereview-hr@appspot.gserviceaccount.com (chromiumcodereview-hr) | Please choose your nickname with Settings | Help | Chromium Project | Gerrit Changes | Sign out
(223)

Side by Side Diff: lib/html/templates/html/impl/impl_Storage.darttemplate

Issue 11267018: Make getKeys, getValues getters (keys, values). (Closed) Base URL: https://dart.googlecode.com/svn/branches/bleeding_edge/dart
Patch Set: Update status files with co19 issue number. Created 8 years, 1 month ago
Use n/p to move between diff chunks; N/P to move between comments. Draft comments are only viewable by you.
Jump to:
View unified diff | Download patch | Annotate | Revision Log
« no previous file with comments | « lib/html/templates/html/impl/impl_Element.darttemplate ('k') | pkg/args/lib/args.dart » ('j') | no next file with comments »
Toggle Intra-line Diffs ('i') | Expand Comments ('e') | Collapse Comments ('c') | Show Comments Hide Comments ('s')
OLDNEW
1 // Copyright (c) 2012, the Dart project authors. Please see the AUTHORS file 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 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 class $CLASSNAME$EXTENDS$IMPLEMENTS$NATIVESPEC { 5 class $CLASSNAME$EXTENDS$IMPLEMENTS$NATIVESPEC {
6 6
7 // TODO(nweiz): update this when maps support lazy iteration 7 // TODO(nweiz): update this when maps support lazy iteration
8 bool containsValue(String value) => getValues().some((e) => e == value); 8 bool containsValue(String value) => values.some((e) => e == value);
9 9
10 bool containsKey(String key) => $dom_getItem(key) != null; 10 bool containsKey(String key) => $dom_getItem(key) != null;
11 11
12 String operator [](String key) => $dom_getItem(key); 12 String operator [](String key) => $dom_getItem(key);
13 13
14 void operator []=(String key, String value) => $dom_setItem(key, value); 14 void operator []=(String key, String value) => $dom_setItem(key, value);
15 15
16 String putIfAbsent(String key, String ifAbsent()) { 16 String putIfAbsent(String key, String ifAbsent()) {
17 if (!containsKey(key)) this[key] = ifAbsent(); 17 if (!containsKey(key)) this[key] = ifAbsent();
18 return this[key]; 18 return this[key];
19 } 19 }
20 20
21 String remove(String key) { 21 String remove(String key) {
22 final value = this[key]; 22 final value = this[key];
23 $dom_removeItem(key); 23 $dom_removeItem(key);
24 return value; 24 return value;
25 } 25 }
26 26
27 void clear() => $dom_clear(); 27 void clear() => $dom_clear();
28 28
29 void forEach(void f(String key, String value)) { 29 void forEach(void f(String key, String value)) {
30 for (var i = 0; true; i++) { 30 for (var i = 0; true; i++) {
31 final key = $dom_key(i); 31 final key = $dom_key(i);
32 if (key == null) return; 32 if (key == null) return;
33 33
34 f(key, this[key]); 34 f(key, this[key]);
35 } 35 }
36 } 36 }
37 37
38 Collection<String> getKeys() { 38 Collection<String> get keys {
39 final keys = []; 39 final keys = [];
40 forEach((k, v) => keys.add(k)); 40 forEach((k, v) => keys.add(k));
41 return keys; 41 return keys;
42 } 42 }
43 43
44 Collection<String> getValues() { 44 Collection<String> get values {
45 final values = []; 45 final values = [];
46 forEach((k, v) => values.add(v)); 46 forEach((k, v) => values.add(v));
47 return values; 47 return values;
48 } 48 }
49 49
50 int get length => $dom_length; 50 int get length => $dom_length;
51 51
52 bool get isEmpty => $dom_key(0) == null; 52 bool get isEmpty => $dom_key(0) == null;
53 $!MEMBERS 53 $!MEMBERS
54 } 54 }
OLDNEW
« no previous file with comments | « lib/html/templates/html/impl/impl_Element.darttemplate ('k') | pkg/args/lib/args.dart » ('j') | no next file with comments »

Powered by Google App Engine
This is Rietveld 408576698