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

Side by Side Diff: pkg/analyzer/lib/src/index/store/collection.dart

Issue 365193004: Move Index and IndexStore implementations into Engine. (Closed) Base URL: https://dart.googlecode.com/svn/branches/bleeding_edge/dart
Patch Set: Created 6 years, 5 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
OLDNEW
1 // Copyright (c) 2014, the Dart project authors. Please see the AUTHORS file 1 // Copyright (c) 2014, 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 library index.store.collection; 5 library engine.src.index.store.collection;
6 6
7 import 'dart:collection'; 7 import 'dart:collection';
8 import 'dart:typed_data'; 8 import 'dart:typed_data';
9 9
10 10
11 /** 11 /**
12 * A hash map with `List<int>` keys and [int] values. 12 * A hash map with `List<int>` keys and [int] values.
13 */ 13 */
14 class IntArrayToIntMap { 14 class IntArrayToIntMap {
15 final Map<Int32List, int> map = new HashMap<Int32List, int>(equals: 15 final Map<Int32List, int> map = new HashMap<Int32List, int>(equals:
16 _intArrayEquals, hashCode: _intArrayHashCode); 16 _intArrayEquals, hashCode: _intArrayHashCode);
17 17
18 /** 18 /**
19 * Returns the value for the given [key] or null if [key] is not in the map. 19 * Returns the value for the given [key] or null if [key] is not in the map.
20 */ 20 */
21 int operator[](List<int> key) { 21 int operator [](List<int> key) {
22 Int32List typedKey = _getTypedKey(key); 22 Int32List typedKey = _getTypedKey(key);
23 return map[typedKey]; 23 return map[typedKey];
24 } 24 }
25 25
26 /** 26 /**
27 * Associates the [key] with the given [value]. 27 * Associates the [key] with the given [value].
28 * 28 *
29 * If the key was already in the map, its associated value is changed. 29 * If the key was already in the map, its associated value is changed.
30 * Otherwise the key-value pair is added to the map. 30 * Otherwise the key-value pair is added to the map.
31 */ 31 */
32 void operator[]=(List<int> key, int value) { 32 void operator []=(List<int> key, int value) {
33 Int32List typedKey = _getTypedKey(key); 33 Int32List typedKey = _getTypedKey(key);
34 map[typedKey] = value; 34 map[typedKey] = value;
35 } 35 }
36 36
37 /** 37 /**
38 * Returns an [Int32List] version of the given `List<int>` key. 38 * Returns an [Int32List] version of the given `List<int>` key.
39 */ 39 */
40 static Int32List _getTypedKey(List<int> key) { 40 static Int32List _getTypedKey(List<int> key) {
41 if (key is Int32List) { 41 if (key is Int32List) {
42 return key; 42 return key;
(...skipping 64 matching lines...) Expand 10 before | Expand all | Expand 10 after
107 * not in the map. 107 * not in the map.
108 */ 108 */
109 List<int> get(int key) { 109 List<int> get(int key) {
110 List<int> values = _map[key]; 110 List<int> values = _map[key];
111 if (values == null) { 111 if (values == null) {
112 values = <int>[]; 112 values = <int>[];
113 } 113 }
114 return values; 114 return values;
115 } 115 }
116 } 116 }
OLDNEW

Powered by Google App Engine
This is Rietveld 408576698