Clover icon

jalviewX

  1. Project Clover database Wed Oct 31 2018 15:13:58 GMT
  2. Package jalview.ext.android

File ContainerHelpers.java

 

Coverage histogram

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

Code metrics

18
33
3
1
112
78
12
0.36
11
3
4

Classes

Class Line # Actions
ContainerHelpers 27 33 12 18
0.666666766.7%
 

Contributing tests

No tests hitting this source file were found.

Source view

1    package jalview.ext.android;
2   
3    /*
4    * Copyright (C) 2013 The Android Open Source Project
5    *
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
9    *
10    * http://www.apache.org/licenses/LICENSE-2.0
11    *
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.
17    */
18   
19    /*
20    * Copied to Jalview September 2016.
21    * Only the members of this class required for SparseIntArray were copied.
22    * Change Log:
23    * Sep 2016: Method binarySearch(short[] array, int size, short value) added to support
24    * SparseShortArray.
25    * Jan 2017: EMPTY_DOUBLES added
26    */
 
27    class ContainerHelpers
28    {
29    static final boolean[] EMPTY_BOOLEANS = new boolean[0];
30   
31    static final int[] EMPTY_INTS = new int[0];
32   
33    static final double[] EMPTY_DOUBLES = new double[0];
34   
35    static final long[] EMPTY_LONGS = new long[0];
36   
37    static final Object[] EMPTY_OBJECTS = new Object[0];
38   
39    // This is Arrays.binarySearch(), but doesn't do any argument validation.
 
40  9667 toggle static int binarySearch(int[] array, int size, int value)
41    {
42  9667 int lo = 0;
43  9667 int hi = size - 1;
44  26164 while (lo <= hi)
45    {
46  23965 final int mid = (lo + hi) >>> 1;
47  23965 final int midVal = array[mid];
48  23965 if (midVal < value)
49    {
50  10917 lo = mid + 1;
51    }
52  13048 else if (midVal > value)
53    {
54  5580 hi = mid - 1;
55    }
56    else
57    {
58  7468 return mid; // value found
59    }
60    }
61  2199 return ~lo; // value not present
62    }
63   
 
64  0 toggle static int binarySearch(long[] array, int size, long value)
65    {
66  0 int lo = 0;
67  0 int hi = size - 1;
68  0 while (lo <= hi)
69    {
70  0 final int mid = (lo + hi) >>> 1;
71  0 final long midVal = array[mid];
72  0 if (midVal < value)
73    {
74  0 lo = mid + 1;
75    }
76  0 else if (midVal > value)
77    {
78  0 hi = mid - 1;
79    }
80    else
81    {
82  0 return mid; // value found
83    }
84    }
85  0 return ~lo; // value not present
86    }
87   
88    // This is Arrays.binarySearch(), but doesn't do any argument validation.
 
89  119 toggle static int binarySearch(short[] array, int size, short value)
90    {
91  119 int lo = 0;
92  119 int hi = size - 1;
93  141 while (lo <= hi)
94    {
95  62 final int mid = (lo + hi) >>> 1;
96  62 final short midVal = array[mid];
97  62 if (midVal < value)
98    {
99  18 lo = mid + 1;
100    }
101  44 else if (midVal > value)
102    {
103  4 hi = mid - 1;
104    }
105    else
106    {
107  40 return mid; // value found
108    }
109    }
110  79 return ~lo; // value not present
111    }
112    }