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

Side by Side Diff: pkg/serialization/lib/src/serialization_helpers.dart

Issue 11664006: Make Map.keys/values Iterables. (Closed) Base URL: https://dart.googlecode.com/svn/experimental/lib_v2/dart
Patch Set: Add TODO that map.keys should return a Set. Created 7 years, 11 months 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 | « pkg/intl/lib/date_format.dart ('k') | pkg/serialization/lib/src/serialization_rule.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 /** 5 /**
6 * This contains extra functions and classes useful for implementing 6 * This contains extra functions and classes useful for implementing
7 * serialiation. Some or all of these will be removed once the functionality is 7 * serialiation. Some or all of these will be removed once the functionality is
8 * available in the core library. 8 * available in the core library.
9 */ 9 */
10 library serialization_helpers; 10 library serialization_helpers;
(...skipping 11 matching lines...) Expand all
22 if (a == null) { 22 if (a == null) {
23 return (b == null) ? [] : new List.from(b); 23 return (b == null) ? [] : new List.from(b);
24 } 24 }
25 if (b == null) return new List.from(a); 25 if (b == null) return new List.from(a);
26 var result = new List.from(a); 26 var result = new List.from(a);
27 result.addAll(b); 27 result.addAll(b);
28 return result; 28 return result;
29 } 29 }
30 30
31 /** 31 /**
32 * Return a sorted version of [aCollection], using the default sort criterion. 32 * Return a sorted version of [anIterable], using the default sort criterion.
33 * Always returns a List, regardless of the type of [aCollection]. 33 * Always returns a List, regardless of the type of [anIterable].
34 */ 34 */
35 List sorted(aCollection) { 35 List sorted(anIterable) {
36 var result = new List.from(aCollection); 36 var result = new List.from(anIterable);
37 result.sort(); 37 result.sort();
38 return result; 38 return result;
39 } 39 }
40 40
41 /** Helper function for PrimitiveRule to tell which objects it applies to. */ 41 /** Helper function for PrimitiveRule to tell which objects it applies to. */
42 bool isPrimitive(object) { 42 bool isPrimitive(object) {
43 return identical(object, null) || object is num || object is String || 43 return identical(object, null) || object is num || object is String ||
44 identical(object, true) || identical(object, false); 44 identical(object, true) || identical(object, false);
45 } 45 }
46 46
(...skipping 198 matching lines...) Expand 10 before | Expand all | Expand 10 after
245 int get length => keys.length; 245 int get length => keys.length;
246 void clear() { 246 void clear() {
247 keys.clear(); 247 keys.clear();
248 values.clear(); 248 values.clear();
249 } 249 }
250 bool get isEmpty => keys.isEmpty; 250 bool get isEmpty => keys.isEmpty;
251 251
252 // Note that this is doing an equality comparison. 252 // Note that this is doing an equality comparison.
253 bool containsValue(x) => values.contains(x); 253 bool containsValue(x) => values.contains(x);
254 } 254 }
OLDNEW
« no previous file with comments | « pkg/intl/lib/date_format.dart ('k') | pkg/serialization/lib/src/serialization_rule.dart » ('j') | no next file with comments »

Powered by Google App Engine
This is Rietveld 408576698