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

Unified Diff: pkg/analysis_server/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, 6 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 side-by-side diff with in-line comments
Download patch
Index: pkg/analysis_server/lib/src/index/store/collection.dart
diff --git a/pkg/analysis_server/lib/src/index/store/collection.dart b/pkg/analysis_server/lib/src/index/store/collection.dart
deleted file mode 100644
index 3c29445ca82e112a997d6b917085d67007d2d7b8..0000000000000000000000000000000000000000
--- a/pkg/analysis_server/lib/src/index/store/collection.dart
+++ /dev/null
@@ -1,116 +0,0 @@
-// Copyright (c) 2014, the Dart project authors. Please see the AUTHORS file
-// for details. All rights reserved. Use of this source code is governed by a
-// BSD-style license that can be found in the LICENSE file.
-
-library index.store.collection;
-
-import 'dart:collection';
-import 'dart:typed_data';
-
-
-/**
- * A hash map with `List<int>` keys and [int] values.
- */
-class IntArrayToIntMap {
- final Map<Int32List, int> map = new HashMap<Int32List, int>(equals:
- _intArrayEquals, hashCode: _intArrayHashCode);
-
- /**
- * Returns the value for the given [key] or null if [key] is not in the map.
- */
- int operator[](List<int> key) {
- Int32List typedKey = _getTypedKey(key);
- return map[typedKey];
- }
-
- /**
- * Associates the [key] with the given [value].
- *
- * If the key was already in the map, its associated value is changed.
- * Otherwise the key-value pair is added to the map.
- */
- void operator[]=(List<int> key, int value) {
- Int32List typedKey = _getTypedKey(key);
- map[typedKey] = value;
- }
-
- /**
- * Returns an [Int32List] version of the given `List<int>` key.
- */
- static Int32List _getTypedKey(List<int> key) {
- if (key is Int32List) {
- return key;
- }
- return new Int32List.fromList(key);
- }
-
- static bool _intArrayEquals(List<int> a, List<int> b) {
- int length = a.length;
- if (length != b.length) {
- return false;
- }
- for (int i = 0; i < length; i++) {
- if (a[i] != b[i]) {
- return false;
- }
- }
- return true;
- }
-
- static int _intArrayHashCode(List<int> key) {
- return key.fold(0, (int result, int item) {
- return 31 * result + item;
- });
- }
-}
-
-
-/**
- * A table mapping [int] keys to sets of [int]s.
- */
-class IntToIntSetMap {
- final Map<int, Int32List> _map = new HashMap<int, Int32List>();
-
- /**
- * The number of key-value pairs in the map.
- */
- int get length => _map.length;
-
- /**
- * Adds the [value] to the set associated with the given [value].
- */
- void add(int key, int value) {
- Int32List values = _map[key];
- if (values == null) {
- values = new Int32List(1);
- values[0] = value;
- _map[key] = values;
- }
- if (values.indexOf(value) == -1) {
- int length = values.length;
- Int32List newSet = new Int32List(length + 1);
- newSet.setRange(0, length, values);
- newSet[length] = value;
- _map[key] = newSet;
- }
- }
-
- /**
- * Removes all pairs from the map.
- */
- void clear() {
- _map.clear();
- }
-
- /**
- * Returns the set of [int]s for the given [key] or an empty list if [key] is
- * not in the map.
- */
- List<int> get(int key) {
- List<int> values = _map[key];
- if (values == null) {
- values = <int>[];
- }
- return values;
- }
-}

Powered by Google App Engine
This is Rietveld 408576698