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 import "dart:collection"; | 5 import "dart:collection"; |
6 import "dart:math" as math; | 6 import "dart:math" as math; |
7 | 7 |
8 import "typed_wrappers.dart"; | 8 import "typed_wrappers.dart"; |
9 import "unmodifiable_wrappers.dart"; | 9 import "unmodifiable_wrappers.dart"; |
10 | 10 |
(...skipping 341 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
352 /// This soundly converts a [Map] without generic types to a `Map<K, V>` by | 352 /// This soundly converts a [Map] without generic types to a `Map<K, V>` by |
353 /// asserting that its keys are instances of `E` and its values are instances | 353 /// asserting that its keys are instances of `E` and its values are instances |
354 /// of `V` whenever they're accessed. If they're not, it throws a [CastError]. | 354 /// of `V` whenever they're accessed. If they're not, it throws a [CastError]. |
355 /// Note that even if an operation throws a [CastError], it may still mutate | 355 /// Note that even if an operation throws a [CastError], it may still mutate |
356 /// the underlying collection. | 356 /// the underlying collection. |
357 /// | 357 /// |
358 /// This forwards all operations to [base], so any changes in [base] will be | 358 /// This forwards all operations to [base], so any changes in [base] will be |
359 /// reflected in [this]. If [base] is already a `Map<K, V>`, it's returned | 359 /// reflected in [this]. If [base] is already a `Map<K, V>`, it's returned |
360 /// unmodified. | 360 /// unmodified. |
361 static Map/*<K, V>*/ typed/*<K, V>*/(Map base) => | 361 static Map/*<K, V>*/ typed/*<K, V>*/(Map base) => |
362 base is Map<K, V> ? base : new TypeSafeMap<K, V>(base); | 362 base is Map/*<K, V>*/ ? base : new TypeSafeMap/*<K, V>*/(base); |
363 | 363 |
364 V operator [](Object key) => _base[key]; | 364 V operator [](Object key) => _base[key]; |
365 | 365 |
366 void operator []=(K key, V value) { | 366 void operator []=(K key, V value) { |
367 _base[key] = value; | 367 _base[key] = value; |
368 } | 368 } |
369 | 369 |
370 void addAll(Map<K, V> other) { | 370 void addAll(Map<K, V> other) { |
371 _base.addAll(other); | 371 _base.addAll(other); |
372 } | 372 } |
(...skipping 224 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
597 | 597 |
598 /// Returns a new set which contains all the elements of [this] and [other]. | 598 /// Returns a new set which contains all the elements of [this] and [other]. |
599 /// | 599 /// |
600 /// That is, the returned set contains all the elements of this [Set] and all | 600 /// That is, the returned set contains all the elements of this [Set] and all |
601 /// the elements of [other]. | 601 /// the elements of [other]. |
602 /// | 602 /// |
603 /// Note that the returned set will use the default equality operation, which | 603 /// Note that the returned set will use the default equality operation, which |
604 /// may be different than the equality operation [this] uses. | 604 /// may be different than the equality operation [this] uses. |
605 Set<V> union(Set<V> other) => toSet()..addAll(other); | 605 Set<V> union(Set<V> other) => toSet()..addAll(other); |
606 } | 606 } |
OLD | NEW |