| OLD | NEW |
| 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 // Immutable map class for compiler generated map literals. | 4 // Immutable map class for compiler generated map literals. |
| 5 | 5 |
| 6 class ImmutableMap<K, V> implements Map<K, V> { | 6 class ImmutableMap<K, V> implements Map<K, V> { |
| 7 final _ImmutableArray kvPairs_; | 7 final _ImmutableArray kvPairs_; |
| 8 | 8 |
| 9 const ImmutableMap._create(_ImmutableArray keyValuePairs) | 9 const ImmutableMap._create(_ImmutableArray keyValuePairs) |
| 10 : kvPairs_ = keyValuePairs; | 10 : kvPairs_ = keyValuePairs; |
| (...skipping 64 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 75 | 75 |
| 76 V remove(K key) { | 76 V remove(K key) { |
| 77 throw new UnsupportedError("Cannot remove from unmodifiable Map"); | 77 throw new UnsupportedError("Cannot remove from unmodifiable Map"); |
| 78 } | 78 } |
| 79 | 79 |
| 80 String toString() { | 80 String toString() { |
| 81 return Maps.mapToString(this); | 81 return Maps.mapToString(this); |
| 82 } | 82 } |
| 83 } | 83 } |
| 84 | 84 |
| 85 class _ImmutableMapKeyIterable<E> extends Iterable<E> { | 85 class _ImmutableMapKeyIterable<E> extends IterableBase<E> { |
| 86 final ImmutableMap _map; | 86 final ImmutableMap _map; |
| 87 _ImmutableMapKeyIterable(this._map); | 87 _ImmutableMapKeyIterable(this._map); |
| 88 | 88 |
| 89 Iterator<E> get iterator { | 89 Iterator<E> get iterator { |
| 90 return new _ImmutableMapKeyIterator<E>(_map); | 90 return new _ImmutableMapKeyIterator<E>(_map); |
| 91 } | 91 } |
| 92 } | 92 } |
| 93 | 93 |
| 94 class _ImmutableMapValueIterable<E> extends Iterable<E> { | 94 class _ImmutableMapValueIterable<E> extends IterableBase<E> { |
| 95 final ImmutableMap _map; | 95 final ImmutableMap _map; |
| 96 _ImmutableMapValueIterable(this._map); | 96 _ImmutableMapValueIterable(this._map); |
| 97 | 97 |
| 98 Iterator<E> get iterator { | 98 Iterator<E> get iterator { |
| 99 return new _ImmutableMapValueIterator<E>(_map); | 99 return new _ImmutableMapValueIterator<E>(_map); |
| 100 } | 100 } |
| 101 } | 101 } |
| 102 | 102 |
| 103 class _ImmutableMapKeyIterator<E> implements Iterator<E> { | 103 class _ImmutableMapKeyIterator<E> implements Iterator<E> { |
| 104 ImmutableMap _map; | 104 ImmutableMap _map; |
| (...skipping 31 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 136 _current = _map.kvPairs_[newIndex * 2 + 1]; | 136 _current = _map.kvPairs_[newIndex * 2 + 1]; |
| 137 return true; | 137 return true; |
| 138 } | 138 } |
| 139 _current = null; | 139 _current = null; |
| 140 _index = _map.length; | 140 _index = _map.length; |
| 141 return false; | 141 return false; |
| 142 } | 142 } |
| 143 | 143 |
| 144 E get current => _current; | 144 E get current => _current; |
| 145 } | 145 } |
| OLD | NEW |