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

Side by Side Diff: lib/coreimpl/hash_map_set.dart

Issue 11238035: Make isEmpty a getter. (Closed) Base URL: https://dart.googlecode.com/svn/branches/bleeding_edge/dart
Patch Set: Update status file with co19 issue number. Created 8 years, 2 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 | « lib/core/string_buffer.dart ('k') | lib/coreimpl/linked_hash_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) 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 // Hash map implementation with open addressing and quadratic probing. 5 // Hash map implementation with open addressing and quadratic probing.
6 class HashMapImplementation<K, V> implements HashMap<K, V> { 6 class HashMapImplementation<K, V> implements HashMap<K, V> {
7 7
8 // The [_keys] list contains the keys inserted in the map. 8 // The [_keys] list contains the keys inserted in the map.
9 // The [_keys] list must be a raw list because it 9 // The [_keys] list must be a raw list because it
10 // will contain both elements of type K, and the [_DELETED_KEY] of type 10 // will contain both elements of type K, and the [_DELETED_KEY] of type
(...skipping 201 matching lines...) Expand 10 before | Expand all | Expand 10 after
212 V value = _values[index]; 212 V value = _values[index];
213 _values[index] = null; 213 _values[index] = null;
214 // Set the key to the sentinel to not break the probing chain. 214 // Set the key to the sentinel to not break the probing chain.
215 _keys[index] = _DELETED_KEY; 215 _keys[index] = _DELETED_KEY;
216 _numberOfDeleted++; 216 _numberOfDeleted++;
217 return value; 217 return value;
218 } 218 }
219 return null; 219 return null;
220 } 220 }
221 221
222 bool isEmpty() { 222 bool get isEmpty {
223 return _numberOfEntries == 0; 223 return _numberOfEntries == 0;
224 } 224 }
225 225
226 int get length { 226 int get length {
227 return _numberOfEntries; 227 return _numberOfEntries;
228 } 228 }
229 229
230 void forEach(void f(K key, V value)) { 230 void forEach(void f(K key, V value)) {
231 int length = _keys.length; 231 int length = _keys.length;
232 for (int i = 0; i < length; i++) { 232 for (int i = 0; i < length; i++) {
(...skipping 135 matching lines...) Expand 10 before | Expand all | Expand 10 after
368 bool every(bool f(E element)) { 368 bool every(bool f(E element)) {
369 Collection<E> keys = _backingMap.getKeys(); 369 Collection<E> keys = _backingMap.getKeys();
370 return keys.every(f); 370 return keys.every(f);
371 } 371 }
372 372
373 bool some(bool f(E element)) { 373 bool some(bool f(E element)) {
374 Collection<E> keys = _backingMap.getKeys(); 374 Collection<E> keys = _backingMap.getKeys();
375 return keys.some(f); 375 return keys.some(f);
376 } 376 }
377 377
378 bool isEmpty() { 378 bool get isEmpty {
379 return _backingMap.isEmpty(); 379 return _backingMap.isEmpty;
380 } 380 }
381 381
382 int get length { 382 int get length {
383 return _backingMap.length; 383 return _backingMap.length;
384 } 384 }
385 385
386 Iterator<E> iterator() { 386 Iterator<E> iterator() {
387 return new HashSetIterator<E>(this); 387 return new HashSetIterator<E>(this);
388 } 388 }
389 389
(...skipping 57 matching lines...) Expand 10 before | Expand all | Expand 10 after
447 447
448 /** 448 /**
449 * A singleton sentinel used to represent when a key is deleted from the map. 449 * A singleton sentinel used to represent when a key is deleted from the map.
450 * We can't use [: const Object() :] as a sentinel because it would end up 450 * We can't use [: const Object() :] as a sentinel because it would end up
451 * canonicalized and then we cannot distinguish the deleted key from the 451 * canonicalized and then we cannot distinguish the deleted key from the
452 * canonicalized [: Object() :]. 452 * canonicalized [: Object() :].
453 */ 453 */
454 class _DeletedKeySentinel { 454 class _DeletedKeySentinel {
455 const _DeletedKeySentinel(); 455 const _DeletedKeySentinel();
456 } 456 }
OLDNEW
« no previous file with comments | « lib/core/string_buffer.dart ('k') | lib/coreimpl/linked_hash_map.dart » ('j') | no next file with comments »

Powered by Google App Engine
This is Rietveld 408576698