1 package jalview.ext.android;
4 * Copyright (C) 2013 The Android Open Source Project
6 * Licensed under the Apache License, Version 2.0 (the "License");
7 * you may not use this file except in compliance with the License.
8 * You may obtain a copy of the License at
10 * http://www.apache.org/licenses/LICENSE-2.0
12 * Unless required by applicable law or agreed to in writing, software
13 * distributed under the License is distributed on an "AS IS" BASIS,
14 * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
15 * See the License for the specific language governing permissions and
16 * limitations under the License.
20 * Copied to Jalview September 2016.
21 * Only the members of this class required for SparseIntArray were copied.
22 * Method binarySearch(short[] array, int size, short value) added to support
25 class ContainerHelpers
27 static final boolean[] EMPTY_BOOLEANS = new boolean[0];
29 static final int[] EMPTY_INTS = new int[0];
31 static final long[] EMPTY_LONGS = new long[0];
33 static final Object[] EMPTY_OBJECTS = new Object[0];
35 // This is Arrays.binarySearch(), but doesn't do any argument validation.
36 static int binarySearch(int[] array, int size, int value)
42 final int mid = (lo + hi) >>> 1;
43 final int midVal = array[mid];
48 else if (midVal > value)
54 return mid; // value found
57 return ~lo; // value not present
60 static int binarySearch(long[] array, int size, long value)
66 final int mid = (lo + hi) >>> 1;
67 final long midVal = array[mid];
72 else if (midVal > value)
78 return mid; // value found
81 return ~lo; // value not present
84 // This is Arrays.binarySearch(), but doesn't do any argument validation.
85 static int binarySearch(short[] array, int size, short value)
91 final int mid = (lo + hi) >>> 1;
92 final short midVal = array[mid];
97 else if (midVal > value)
103 return mid; // value found
106 return ~lo; // value not present