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

Side by Side Diff: runtime/lib/collection_patch.dart

Issue 14022007: Move Iterable implementation to collection. (Closed) Base URL: https://dart.googlecode.com/svn/branches/bleeding_edge/dart
Patch Set: Address comments. Merge to head. Created 7 years, 8 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/unittest/test/matchers_test.dart ('k') | runtime/lib/immutable_map.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) 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 682 matching lines...) Expand 10 before | Expand all | Expand 10 after
693 assert(!_isFree(_table[offset])); 693 assert(!_isFree(_table[offset]));
694 _setKey(offset, _TOMBSTONE); 694 _setKey(offset, _TOMBSTONE);
695 _deletedCount++; 695 _deletedCount++;
696 _recordModification(); 696 _recordModification();
697 } 697 }
698 } 698 }
699 699
700 /** 700 /**
701 * Generic iterable based on a [_HashTable]. 701 * Generic iterable based on a [_HashTable].
702 */ 702 */
703 abstract class _HashTableIterable<E> extends Iterable<E> { 703 abstract class _HashTableIterable<E> extends IterableBase<E> {
704 final _HashTable _hashTable; 704 final _HashTable _hashTable;
705 _HashTableIterable(this._hashTable); 705 _HashTableIterable(this._hashTable);
706 706
707 Iterator<E> get iterator; 707 Iterator<E> get iterator;
708 708
709 /** 709 /**
710 * Return the iterated value for a given entry. 710 * Return the iterated value for a given entry.
711 */ 711 */
712 E _valueAt(int offset, Object key); 712 E _valueAt(int offset, Object key);
713 713
(...skipping 203 matching lines...) Expand 10 before | Expand all | Expand 10 after
917 } 917 }
918 918
919 void _deleteEntry(int offset) { 919 void _deleteEntry(int offset) {
920 _unlink(offset); 920 _unlink(offset);
921 _setKey(offset, _TOMBSTONE); 921 _setKey(offset, _TOMBSTONE);
922 _deletedCount++; 922 _deletedCount++;
923 _recordModification(); 923 _recordModification();
924 } 924 }
925 } 925 }
926 926
927 class _LinkedHashTableKeyIterable<K> extends Iterable<K> { 927 class _LinkedHashTableKeyIterable<K> extends IterableBase<K> {
928 final _LinkedHashTable<K> _table; 928 final _LinkedHashTable<K> _table;
929 _LinkedHashTableKeyIterable(this._table); 929 _LinkedHashTableKeyIterable(this._table);
930 Iterator<K> get iterator => new _LinkedHashTableKeyIterator<K>(_table); 930 Iterator<K> get iterator => new _LinkedHashTableKeyIterator<K>(_table);
931 931
932 bool contains(Object value) => _table._get(value) >= 0; 932 bool contains(Object value) => _table._get(value) >= 0;
933 933
934 int get length => _table._elementCount; 934 int get length => _table._elementCount;
935 } 935 }
936 936
937 class _LinkedHashTableKeyIterator<K> extends _LinkedHashTableIterator<K> { 937 class _LinkedHashTableKeyIterator<K> extends _LinkedHashTableIterator<K> {
938 _LinkedHashTableKeyIterator(_LinkedHashTable<K> hashTable): super(hashTable); 938 _LinkedHashTableKeyIterator(_LinkedHashTable<K> hashTable): super(hashTable);
939 939
940 K _getCurrent(int offset) => _hashTable._key(offset); 940 K _getCurrent(int offset) => _hashTable._key(offset);
941 } 941 }
942 942
943 class _LinkedHashTableValueIterable<V> extends Iterable<V> { 943 class _LinkedHashTableValueIterable<V> extends IterableBase<V> {
944 final _LinkedHashTable _hashTable; 944 final _LinkedHashTable _hashTable;
945 final int _valueIndex; 945 final int _valueIndex;
946 _LinkedHashTableValueIterable(this._hashTable, this._valueIndex); 946 _LinkedHashTableValueIterable(this._hashTable, this._valueIndex);
947 Iterator<V> get iterator => 947 Iterator<V> get iterator =>
948 new _LinkedHashTableValueIterator<V>(_hashTable, _valueIndex); 948 new _LinkedHashTableValueIterator<V>(_hashTable, _valueIndex);
949 int get length => _hashTable._elementCount; 949 int get length => _hashTable._elementCount;
950 } 950 }
951 951
952 class _LinkedHashTableValueIterator<V> extends _LinkedHashTableIterator<V> { 952 class _LinkedHashTableValueIterator<V> extends _LinkedHashTableIterator<V> {
953 final int _valueIndex; 953 final int _valueIndex;
(...skipping 39 matching lines...) Expand 10 before | Expand all | Expand 10 after
993 993
994 _LinkedHashMapTable() : super(_INITIAL_CAPACITY); 994 _LinkedHashMapTable() : super(_INITIAL_CAPACITY);
995 995
996 V _value(int offset) => _table[offset + _VALUE_INDEX]; 996 V _value(int offset) => _table[offset + _VALUE_INDEX];
997 void _setValue(int offset, V value) { _table[offset + _VALUE_INDEX] = value; } 997 void _setValue(int offset, V value) { _table[offset + _VALUE_INDEX] = value; }
998 998
999 _copyEntry(List oldTable, int fromOffset, int toOffset) { 999 _copyEntry(List oldTable, int fromOffset, int toOffset) {
1000 _table[toOffset + _VALUE_INDEX] = oldTable[fromOffset + _VALUE_INDEX]; 1000 _table[toOffset + _VALUE_INDEX] = oldTable[fromOffset + _VALUE_INDEX];
1001 } 1001 }
1002 } 1002 }
OLDNEW
« no previous file with comments | « pkg/unittest/test/matchers_test.dart ('k') | runtime/lib/immutable_map.dart » ('j') | no next file with comments »

Powered by Google App Engine
This is Rietveld 408576698