| 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 // This code was auto-generated, is not intended to be edited, and is subject to | 5 // This code was auto-generated, is not intended to be edited, and is subject to |
| 6 // significant change. Please see the README file for more information. | 6 // significant change. Please see the README file for more information. |
| 7 | 7 |
| 8 library engine.utilities.collection; | 8 library engine.utilities.collection; |
| 9 | 9 |
| 10 import 'java_core.dart'; | 10 import 'java_core.dart'; |
| 11 import 'scanner.dart' show Token; | 11 import 'scanner.dart' show Token; |
| 12 | 12 |
| 13 /** | 13 /** |
| 14 * The class `BooleanArray` defines methods for operating on integers as if they
were arrays | 14 * The class `BooleanArray` defines methods for operating on integers as if they
were arrays |
| 15 * of booleans. These arrays can be indexed by either integers or by enumeration
constants. | 15 * of booleans. These arrays can be indexed by either integers or by enumeration
constants. |
| 16 */ | 16 */ |
| 17 class BooleanArray { | 17 class BooleanArray { |
| 18 /** | 18 /** |
| 19 * Return the value of the element at the given index. | 19 * Return the value of the element at the given index. |
| 20 * | 20 * |
| 21 * @param array the array being accessed | 21 * @param array the array being accessed |
| 22 * @param index the index of the element being accessed | 22 * @param index the index of the element being accessed |
| 23 * @return the value of the element at the given index | 23 * @return the value of the element at the given index |
| 24 * @throws IndexOutOfBoundsException if the index is not between zero (0) and
31, inclusive | 24 * @throws IndexOutOfBoundsException if the index is not between zero (0) and
31, inclusive |
| 25 */ | 25 */ |
| 26 static bool get(int array, int index) { | 26 static bool get(int array, int index) { |
| 27 checkIndex(index); | 27 _checkIndex(index); |
| 28 return (array & (1 << index)) > 0; | 28 return (array & (1 << index)) > 0; |
| 29 } | 29 } |
| 30 | 30 |
| 31 /** | 31 /** |
| 32 * Return the value of the element at the given index. | 32 * Return the value of the element at the given index. |
| 33 * | 33 * |
| 34 * @param array the array being accessed | 34 * @param array the array being accessed |
| 35 * @param index the index of the element being accessed | 35 * @param index the index of the element being accessed |
| 36 * @return the value of the element at the given index | 36 * @return the value of the element at the given index |
| 37 * @throws IndexOutOfBoundsException if the index is not between zero (0) and
31, inclusive | 37 * @throws IndexOutOfBoundsException if the index is not between zero (0) and
31, inclusive |
| 38 */ | 38 */ |
| 39 static bool getEnum(int array, Enum index) => get(array, index.ordinal); | 39 static bool getEnum(int array, Enum index) => get(array, index.ordinal); |
| 40 | 40 |
| 41 /** | 41 /** |
| 42 * Set the value of the element at the given index to the given value. | 42 * Set the value of the element at the given index to the given value. |
| 43 * | 43 * |
| 44 * @param array the array being modified | 44 * @param array the array being modified |
| 45 * @param index the index of the element being set | 45 * @param index the index of the element being set |
| 46 * @param value the value to be assigned to the element | 46 * @param value the value to be assigned to the element |
| 47 * @return the updated value of the array | 47 * @return the updated value of the array |
| 48 * @throws IndexOutOfBoundsException if the index is not between zero (0) and
31, inclusive | 48 * @throws IndexOutOfBoundsException if the index is not between zero (0) and
31, inclusive |
| 49 */ | 49 */ |
| 50 static int set(int array, int index, bool value) { | 50 static int set(int array, int index, bool value) { |
| 51 checkIndex(index); | 51 _checkIndex(index); |
| 52 if (value) { | 52 if (value) { |
| 53 return array | (1 << index); | 53 return array | (1 << index); |
| 54 } else { | 54 } else { |
| 55 return array & ~(1 << index); | 55 return array & ~(1 << index); |
| 56 } | 56 } |
| 57 } | 57 } |
| 58 | 58 |
| 59 /** | 59 /** |
| 60 * Set the value of the element at the given index to the given value. | 60 * Set the value of the element at the given index to the given value. |
| 61 * | 61 * |
| 62 * @param array the array being modified | 62 * @param array the array being modified |
| 63 * @param index the index of the element being set | 63 * @param index the index of the element being set |
| 64 * @param value the value to be assigned to the element | 64 * @param value the value to be assigned to the element |
| 65 * @return the updated value of the array | 65 * @return the updated value of the array |
| 66 * @throws IndexOutOfBoundsException if the index is not between zero (0) and
31, inclusive | 66 * @throws IndexOutOfBoundsException if the index is not between zero (0) and
31, inclusive |
| 67 */ | 67 */ |
| 68 static int setEnum(int array, Enum index, bool value) => set(array, index.ordi
nal, value); | 68 static int setEnum(int array, Enum index, bool value) => set(array, index.ordi
nal, value); |
| 69 | 69 |
| 70 /** | 70 /** |
| 71 * Throw an exception if the index is not within the bounds allowed for an int
eger-encoded array | 71 * Throw an exception if the index is not within the bounds allowed for an int
eger-encoded array |
| 72 * of boolean values. | 72 * of boolean values. |
| 73 * | 73 * |
| 74 * @throws IndexOutOfBoundsException if the index is not between zero (0) and
31, inclusive | 74 * @throws IndexOutOfBoundsException if the index is not between zero (0) and
31, inclusive |
| 75 */ | 75 */ |
| 76 static void checkIndex(int index) { | 76 static void _checkIndex(int index) { |
| 77 if (index < 0 || index > 30) { | 77 if (index < 0 || index > 30) { |
| 78 throw new RangeError("Index not between 0 and 30: ${index}"); | 78 throw new RangeError("Index not between 0 and 30: ${index}"); |
| 79 } | 79 } |
| 80 } | 80 } |
| 81 } | 81 } |
| 82 | 82 |
| 83 /** | 83 /** |
| 84 * Instances of the class `TokenMap` map one set of tokens to another set of tok
ens. | 84 * Instances of the class `TokenMap` map one set of tokens to another set of tok
ens. |
| 85 */ | 85 */ |
| 86 class TokenMap { | 86 class TokenMap { |
| (...skipping 35 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 122 * @param list the list to which the elements are to be added | 122 * @param list the list to which the elements are to be added |
| 123 * @param elements the elements to be added to the list | 123 * @param elements the elements to be added to the list |
| 124 */ | 124 */ |
| 125 static void addAll(List list, List<Object> elements) { | 125 static void addAll(List list, List<Object> elements) { |
| 126 int count = elements.length; | 126 int count = elements.length; |
| 127 for (int i = 0; i < count; i++) { | 127 for (int i = 0; i < count; i++) { |
| 128 list.add(elements[i]); | 128 list.add(elements[i]); |
| 129 } | 129 } |
| 130 } | 130 } |
| 131 } | 131 } |
| OLD | NEW |