| OLD | NEW |
| 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 analyzer.src.generated.utilities_collection; | 5 library analyzer.src.generated.utilities_collection; |
| 6 | 6 |
| 7 import 'dart:collection'; | 7 import 'dart:collection'; |
| 8 import "dart:math" as math; | 8 import "dart:math" as math; |
| 9 | 9 |
| 10 import 'package:analyzer/dart/ast/token.dart'; | 10 import 'package:analyzer/dart/ast/token.dart'; |
| (...skipping 32 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 43 */ | 43 */ |
| 44 static bool get(int array, int index) { | 44 static bool get(int array, int index) { |
| 45 _checkIndex(index); | 45 _checkIndex(index); |
| 46 return (array & (1 << index)) > 0; | 46 return (array & (1 << index)) > 0; |
| 47 } | 47 } |
| 48 | 48 |
| 49 /** | 49 /** |
| 50 * Return the value of the element at the given index. | 50 * Return the value of the element at the given index. |
| 51 */ | 51 */ |
| 52 @deprecated | 52 @deprecated |
| 53 static bool getEnum(int array, Enum index) => get(array, index.ordinal); | 53 static bool getEnum<E extends Enum<E>>(int array, Enum<E> index) => get( |
| 54 array, index.ordinal); |
| 54 | 55 |
| 55 /** | 56 /** |
| 56 * Set the value of the element of the given [array] at the given [index] to | 57 * Set the value of the element of the given [array] at the given [index] to |
| 57 * the given [value]. | 58 * the given [value]. |
| 58 */ | 59 */ |
| 59 static int set(int array, int index, bool value) { | 60 static int set(int array, int index, bool value) { |
| 60 _checkIndex(index); | 61 _checkIndex(index); |
| 61 if (value) { | 62 if (value) { |
| 62 return array | (1 << index); | 63 return array | (1 << index); |
| 63 } else { | 64 } else { |
| 64 return array & ~(1 << index); | 65 return array & ~(1 << index); |
| 65 } | 66 } |
| 66 } | 67 } |
| 67 | 68 |
| 68 /** | 69 /** |
| 69 * Set the value of the element at the given index to the given value. | 70 * Set the value of the element at the given index to the given value. |
| 70 */ | 71 */ |
| 71 @deprecated | 72 @deprecated |
| 72 static int setEnum(int array, Enum index, bool value) => | 73 static int setEnum<E extends Enum<E>>(int array, Enum<E> index, bool value) => |
| 73 set(array, index.ordinal, value); | 74 set(array, index.ordinal, value); |
| 74 | 75 |
| 75 /** | 76 /** |
| 76 * Throw an exception if the index is not within the bounds allowed for an | 77 * Throw an exception if the index is not within the bounds allowed for an |
| 77 * integer-encoded array of boolean values. | 78 * integer-encoded array of boolean values. |
| 78 */ | 79 */ |
| 79 static void _checkIndex(int index) { | 80 static void _checkIndex(int index) { |
| 80 if (index < 0 || index > 30) { | 81 if (index < 0 || index > 30) { |
| 81 throw new RangeError("Index not between 0 and 30: $index"); | 82 throw new RangeError("Index not between 0 and 30: $index"); |
| 82 } | 83 } |
| (...skipping 634 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 717 /** | 718 /** |
| 718 * Map the key to the value. | 719 * Map the key to the value. |
| 719 * | 720 * |
| 720 * @param key the token being mapped to the value | 721 * @param key the token being mapped to the value |
| 721 * @param value the token to which the key will be mapped | 722 * @param value the token to which the key will be mapped |
| 722 */ | 723 */ |
| 723 void put(Token key, Token value) { | 724 void put(Token key, Token value) { |
| 724 _map[key] = value; | 725 _map[key] = value; |
| 725 } | 726 } |
| 726 } | 727 } |
| OLD | NEW |