Clover icon

Coverage Report

  1. Project Clover database Fri Dec 6 2024 13:47:14 GMT
  2. Package jalview.ext.android

File ContainerHelpers.java

 

Coverage histogram

../../../img/srcFileCovDistChart7.png
29% of files have more coverage

Code metrics

18
33
3
1
132
78
12
0.36
11
3
4

Classes

Class Line # Actions
ContainerHelpers 47 33 12
0.666666766.7%
 

Contributing tests

This file is covered by 45 tests. .

Source view

1    /*
2    * Jalview - A Sequence Alignment Editor and Viewer ($$Version-Rel$$)
3    * Copyright (C) $$Year-Rel$$ The Jalview Authors
4    *
5    * This file is part of Jalview.
6    *
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.
11    *
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.
16    *
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.
20    */
21    package jalview.ext.android;
22   
23    /*
24    * Copyright (C) 2013 The Android Open Source Project
25    *
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
29    *
30    * http://www.apache.org/licenses/LICENSE-2.0
31    *
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.
37    */
38   
39    /*
40    * Copied to Jalview September 2016.
41    * Only the members of this class required for SparseIntArray were copied.
42    * Change Log:
43    * Sep 2016: Method binarySearch(short[] array, int size, short value) added to support
44    * SparseShortArray.
45    * Jan 2017: EMPTY_DOUBLES added
46    */
 
47    class ContainerHelpers
48    {
49    static final boolean[] EMPTY_BOOLEANS = new boolean[0];
50   
51    static final int[] EMPTY_INTS = new int[0];
52   
53    static final double[] EMPTY_DOUBLES = new double[0];
54   
55    static final long[] EMPTY_LONGS = new long[0];
56   
57    static final Object[] EMPTY_OBJECTS = new Object[0];
58   
59    // This is Arrays.binarySearch(), but doesn't do any argument validation.
 
60  9667 toggle static int binarySearch(int[] array, int size, int value)
61    {
62  9667 int lo = 0;
63  9667 int hi = size - 1;
64  26164 while (lo <= hi)
65    {
66  23965 final int mid = (lo + hi) >>> 1;
67  23965 final int midVal = array[mid];
68  23965 if (midVal < value)
69    {
70  10917 lo = mid + 1;
71    }
72  13048 else if (midVal > value)
73    {
74  5580 hi = mid - 1;
75    }
76    else
77    {
78  7468 return mid; // value found
79    }
80    }
81  2199 return ~lo; // value not present
82    }
83   
 
84  0 toggle static int binarySearch(long[] array, int size, long value)
85    {
86  0 int lo = 0;
87  0 int hi = size - 1;
88  0 while (lo <= hi)
89    {
90  0 final int mid = (lo + hi) >>> 1;
91  0 final long midVal = array[mid];
92  0 if (midVal < value)
93    {
94  0 lo = mid + 1;
95    }
96  0 else if (midVal > value)
97    {
98  0 hi = mid - 1;
99    }
100    else
101    {
102  0 return mid; // value found
103    }
104    }
105  0 return ~lo; // value not present
106    }
107   
108    // This is Arrays.binarySearch(), but doesn't do any argument validation.
 
109  9376 toggle static int binarySearch(short[] array, int size, short value)
110    {
111  9376 int lo = 0;
112  9376 int hi = size - 1;
113  11282 while (lo <= hi)
114    {
115  10682 final int mid = (lo + hi) >>> 1;
116  10682 final short midVal = array[mid];
117  10682 if (midVal < value)
118    {
119  1814 lo = mid + 1;
120    }
121  8868 else if (midVal > value)
122    {
123  92 hi = mid - 1;
124    }
125    else
126    {
127  8776 return mid; // value found
128    }
129    }
130  600 return ~lo; // value not present
131    }
132    }