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

Side by Side Diff: sdk/lib/collection/hash_map.dart

Issue 13913005: Implement JS version of LinkedHashSet and move the various HashTable implementations to the VM coll… (Closed) Base URL: https://dart.googlecode.com/svn/branches/bleeding_edge/dart
Patch Set: Map -> set. 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 | « sdk/lib/collection/collection_sources.gypi ('k') | sdk/lib/collection/hash_set.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 part of dart.collection; 5 part of dart.collection;
6 6
7 class _HashMapTable<K, V> extends _HashTable<K> {
8 static const int _INITIAL_CAPACITY = 8;
9 static const int _VALUE_INDEX = 1;
10
11 _HashMapTable() : super(_INITIAL_CAPACITY);
12
13 int get _entrySize => 2;
14
15 V _value(int offset) => _table[offset + _VALUE_INDEX];
16 void _setValue(int offset, V value) { _table[offset + _VALUE_INDEX] = value; }
17
18 _copyEntry(List fromTable, int fromOffset, int toOffset) {
19 _table[toOffset + _VALUE_INDEX] = fromTable[fromOffset + _VALUE_INDEX];
20 }
21 }
22
23 class HashMap<K, V> implements Map<K, V> { 7 class HashMap<K, V> implements Map<K, V> {
24 external HashMap(); 8 external HashMap();
25 9
26 factory HashMap.from(Map<K, V> other) { 10 factory HashMap.from(Map<K, V> other) {
27 return new HashMap<K, V>()..addAll(other); 11 return new HashMap<K, V>()..addAll(other);
28 } 12 }
29 13
30 external int get length; 14 external int get length;
31 external bool get isEmpty; 15 external bool get isEmpty;
32 16
(...skipping 10 matching lines...) Expand all
43 27
44 external V putIfAbsent(K key, V ifAbsent()); 28 external V putIfAbsent(K key, V ifAbsent());
45 29
46 external V remove(K key); 30 external V remove(K key);
47 external void clear(); 31 external void clear();
48 32
49 external void forEach(void action(K key, V value)); 33 external void forEach(void action(K key, V value));
50 34
51 String toString() => Maps.mapToString(this); 35 String toString() => Maps.mapToString(this);
52 } 36 }
OLDNEW
« no previous file with comments | « sdk/lib/collection/collection_sources.gypi ('k') | sdk/lib/collection/hash_set.dart » ('j') | no next file with comments »

Powered by Google App Engine
This is Rietveld 408576698