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