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 patch class HashMap<K, V> { | 5 patch class HashMap<K, V> { |
6 final _HashMapTable<K, V> _hashTable = new _HashMapTable<K, V>(); | 6 final _HashMapTable<K, V> _hashTable = new _HashMapTable<K, V>(); |
7 | 7 |
8 /* patch */ HashMap() { | 8 /* patch */ HashMap() { |
9 _hashTable._container = this; | 9 _hashTable._container = this; |
10 } | 10 } |
(...skipping 76 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
87 _hashTable._clear(); | 87 _hashTable._clear(); |
88 } | 88 } |
89 | 89 |
90 /* patch */ void forEach(void action(K key, V value)) { | 90 /* patch */ void forEach(void action(K key, V value)) { |
91 int modificationCount = _hashTable._modificationCount; | 91 int modificationCount = _hashTable._modificationCount; |
92 List table = _hashTable._table; | 92 List table = _hashTable._table; |
93 int entrySize = _hashTable._entrySize; | 93 int entrySize = _hashTable._entrySize; |
94 for (int offset = 0; offset < table.length; offset += entrySize) { | 94 for (int offset = 0; offset < table.length; offset += entrySize) { |
95 Object entry = table[offset]; | 95 Object entry = table[offset]; |
96 if (!_hashTable._isFree(entry)) { | 96 if (!_hashTable._isFree(entry)) { |
97 K key = entry; | 97 K key = identical(entry, _NULL) ? null : entry; |
98 V value = _hashTable._value(offset); | 98 V value = _hashTable._value(offset); |
99 action(key, value); | 99 action(key, value); |
100 _hashTable._checkModification(modificationCount); | 100 _hashTable._checkModification(modificationCount); |
101 } | 101 } |
102 } | 102 } |
103 } | 103 } |
104 | 104 |
105 /* patch */ Iterable<K> get keys => new _HashTableKeyIterable<K>(_hashTable); | 105 /* patch */ Iterable<K> get keys => new _HashTableKeyIterable<K>(_hashTable); |
106 /* patch */ Iterable<V> get values => | 106 /* patch */ Iterable<V> get values => |
107 new _HashTableValueIterable<V>(_hashTable, _HashMapTable._VALUE_INDEX); | 107 new _HashTableValueIterable<V>(_hashTable, _HashMapTable._VALUE_INDEX); |
(...skipping 893 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
1001 | 1001 |
1002 _LinkedHashMapTable() : super(_INITIAL_CAPACITY); | 1002 _LinkedHashMapTable() : super(_INITIAL_CAPACITY); |
1003 | 1003 |
1004 V _value(int offset) => _table[offset + _VALUE_INDEX]; | 1004 V _value(int offset) => _table[offset + _VALUE_INDEX]; |
1005 void _setValue(int offset, V value) { _table[offset + _VALUE_INDEX] = value; } | 1005 void _setValue(int offset, V value) { _table[offset + _VALUE_INDEX] = value; } |
1006 | 1006 |
1007 _copyEntry(List oldTable, int fromOffset, int toOffset) { | 1007 _copyEntry(List oldTable, int fromOffset, int toOffset) { |
1008 _table[toOffset + _VALUE_INDEX] = oldTable[fromOffset + _VALUE_INDEX]; | 1008 _table[toOffset + _VALUE_INDEX] = oldTable[fromOffset + _VALUE_INDEX]; |
1009 } | 1009 } |
1010 } | 1010 } |
OLD | NEW |