OLD | NEW |
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 /** Unique marker object for the head of a linked list of entries. */ | 7 /** Unique marker object for the head of a linked list of entries. */ |
8 class _LinkedHashTableHeadMarker { | 8 class _LinkedHashTableHeadMarker { |
9 const _LinkedHashTableHeadMarker(); | 9 const _LinkedHashTableHeadMarker(); |
10 } | 10 } |
11 | 11 |
12 const _LinkedHashTableHeadMarker _HEAD_MARKER = | 12 const _LinkedHashTableHeadMarker _HEAD_MARKER = |
13 const _LinkedHashTableHeadMarker(); | 13 const _LinkedHashTableHeadMarker(); |
14 | 14 |
15 class _LinkedHashTable<K> extends _HashTable<K> { | 15 class _LinkedHashTable<K> extends _HashTable<K> { |
16 static const _NEXT_INDEX = 1; | 16 static const _NEXT_INDEX = 1; |
17 static const _PREV_INDEX = 2; | 17 static const _PREV_INDEX = 2; |
18 static const _HEAD_OFFSET = 0; | 18 static const _HEAD_OFFSET = 0; |
19 | 19 |
20 _LinkedHashTable(int initialCapacity) : super(initialCapacity); | 20 _LinkedHashTable(int initialCapacity) : super(initialCapacity); |
21 | 21 |
22 int get _entrySize => 3; | 22 int get _entrySize => 3; |
23 | 23 |
24 List _createTable(int capacity) { | 24 List _createTable(int capacity) { |
25 List result = new List.fixedLength(capacity * _entrySize); | 25 List result = new List(capacity * _entrySize); |
26 result[_HEAD_OFFSET] = _HEAD_MARKER; | 26 result[_HEAD_OFFSET] = _HEAD_MARKER; |
27 result[_HEAD_OFFSET + _NEXT_INDEX] = _HEAD_OFFSET; | 27 result[_HEAD_OFFSET + _NEXT_INDEX] = _HEAD_OFFSET; |
28 result[_HEAD_OFFSET + _PREV_INDEX] = _HEAD_OFFSET; | 28 result[_HEAD_OFFSET + _PREV_INDEX] = _HEAD_OFFSET; |
29 return result; | 29 return result; |
30 } | 30 } |
31 | 31 |
32 int _next(int offset) => _table[offset + _NEXT_INDEX]; | 32 int _next(int offset) => _table[offset + _NEXT_INDEX]; |
33 void _setNext(int offset, int to) { _table[offset + _NEXT_INDEX] = to; } | 33 void _setNext(int offset, int to) { _table[offset + _NEXT_INDEX] = to; } |
34 | 34 |
35 int _prev(int offset) => _table[offset + _PREV_INDEX]; | 35 int _prev(int offset) => _table[offset + _PREV_INDEX]; |
(...skipping 120 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
156 } | 156 } |
157 _current = _getCurrent(_offset); | 157 _current = _getCurrent(_offset); |
158 _offset = _hashTable._next(_offset); | 158 _offset = _hashTable._next(_offset); |
159 return true; | 159 return true; |
160 } | 160 } |
161 | 161 |
162 T _getCurrent(int offset); | 162 T _getCurrent(int offset); |
163 | 163 |
164 T get current => _current; | 164 T get current => _current; |
165 } | 165 } |
OLD | NEW |