2 * Jalview - A Sequence Alignment Editor and Viewer ($$Version-Rel$$)
3 * Copyright (C) $$Year-Rel$$ The Jalview Authors
5 * This file is part of Jalview.
7 * Jalview is free software: you can redistribute it and/or
8 * modify it under the terms of the GNU General Public License
9 * as published by the Free Software Foundation, either version 3
10 * of the License, or (at your option) any later version.
12 * Jalview is distributed in the hope that it will be useful, but
13 * WITHOUT ANY WARRANTY; without even the implied warranty
14 * of MERCHANTABILITY or FITNESS FOR A PARTICULAR
15 * PURPOSE. See the GNU General Public License for more details.
17 * You should have received a copy of the GNU General Public License
18 * along with Jalview. If not, see <http://www.gnu.org/licenses/>.
19 * The Jalview Authors are detailed in the 'AUTHORS' file.
21 package jalview.ext.android;
24 * Copyright (C) 2013 The Android Open Source Project
26 * Licensed under the Apache License, Version 2.0 (the "License");
27 * you may not use this file except in compliance with the License.
28 * You may obtain a copy of the License at
30 * http://www.apache.org/licenses/LICENSE-2.0
32 * Unless required by applicable law or agreed to in writing, software
33 * distributed under the License is distributed on an "AS IS" BASIS,
34 * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
35 * See the License for the specific language governing permissions and
36 * limitations under the License.
40 * Copied to Jalview September 2016.
41 * Only the members of this class required for SparseIntArray were copied.
43 * Sep 2016: Method binarySearch(short[] array, int size, short value) added to support
45 * Jan 2017: EMPTY_DOUBLES added
47 class ContainerHelpers
49 static final boolean[] EMPTY_BOOLEANS = new boolean[0];
51 static final int[] EMPTY_INTS = new int[0];
53 static final double[] EMPTY_DOUBLES = new double[0];
55 static final long[] EMPTY_LONGS = new long[0];
57 static final Object[] EMPTY_OBJECTS = new Object[0];
59 // This is Arrays.binarySearch(), but doesn't do any argument validation.
60 static int binarySearch(int[] array, int size, int value)
66 final int mid = (lo + hi) >>> 1;
67 final int midVal = array[mid];
72 else if (midVal > value)
78 return mid; // value found
81 return ~lo; // value not present
84 static int binarySearch(long[] array, int size, long value)
90 final int mid = (lo + hi) >>> 1;
91 final long midVal = array[mid];
96 else if (midVal > value)
102 return mid; // value found
105 return ~lo; // value not present
108 // This is Arrays.binarySearch(), but doesn't do any argument validation.
109 static int binarySearch(short[] array, int size, short value)
115 final int mid = (lo + hi) >>> 1;
116 final short midVal = array[mid];
121 else if (midVal > value)
127 return mid; // value found
130 return ~lo; // value not present