Java Code Examples for cern.colt.list.DoubleArrayList#binarySearch()
The following examples show how to use
cern.colt.list.DoubleArrayList#binarySearch() .
You can vote up the ones you like or vote down the ones you don't like,
and go to the original project or source file by following the links above each example. You may check out the related API usage on the sidebar.
Example 1
Source File: QuantileFinderTest.java From database with GNU General Public License v2.0 | 5 votes |
/** * Finds the first and last indexes of a specific element within a sorted list. * @return int[] * @param list cern.colt.list.DoubleArrayList * @param element the element to search for */ protected static IntArrayList binaryMultiSearch(DoubleArrayList list, double element) { int index = list.binarySearch(element); if (index<0) return null; //not found int from = index-1; while (from>=0 && list.get(from)==element) from--; from++; int to = index+1; while (to<list.size() && list.get(to)==element) to++; to--; return new IntArrayList(new int[] {from,to}); }
Example 2
Source File: QuantileFinderTest.java From jAudioGIT with GNU Lesser General Public License v2.1 | 5 votes |
/** * Finds the first and last indexes of a specific element within a sorted list. * @return int[] * @param list cern.colt.list.DoubleArrayList * @param element the element to search for */ protected static IntArrayList binaryMultiSearch(DoubleArrayList list, double element) { int index = list.binarySearch(element); if (index<0) return null; //not found int from = index-1; while (from>=0 && list.get(from)==element) from--; from++; int to = index+1; while (to<list.size() && list.get(to)==element) to++; to--; return new IntArrayList(new int[] {from,to}); }