aboutsummaryrefslogtreecommitdiffstats
path: root/src
diff options
context:
space:
mode:
authorMattias Andrée <maandree@operamail.com>2014-01-21 17:46:42 +0100
committerMattias Andrée <maandree@operamail.com>2014-01-21 17:46:42 +0100
commite733b6500296b5a5843d68a19cadc7495f304664 (patch)
tree261d19d96679c490d9691770290029a555f7db44 /src
parentwhich elem is found does not matter (diff)
downloadalgorithms-and-data-structures-e733b6500296b5a5843d68a19cadc7495f304664.tar.gz
algorithms-and-data-structures-e733b6500296b5a5843d68a19cadc7495f304664.tar.bz2
algorithms-and-data-structures-e733b6500296b5a5843d68a19cadc7495f304664.tar.xz
add support for index range search in multibin search
Signed-off-by: Mattias Andrée <maandree@operamail.com>
Diffstat (limited to 'src')
-rw-r--r--src/algorithms/searching/MultibinarySearch.java5
1 files changed, 2 insertions, 3 deletions
diff --git a/src/algorithms/searching/MultibinarySearch.java b/src/algorithms/searching/MultibinarySearch.java
index 0486af0..98ce3ff 100644
--- a/src/algorithms/searching/MultibinarySearch.java
+++ b/src/algorithms/searching/MultibinarySearch.java
@@ -150,9 +150,6 @@ public class MultibinarySearch
*/
public static £(fun "long[][]" indexOf "${T}[] items, ${Tarray} array, SortOrder order, SearchMode mode, int start, int end")
{
- if (mode == SearchMode.FIND_FIRST_AND_LAST)
- throw new Error("Mode not implemented"); /* TODO */
-
BinarySearch.SearchMode mode_ =
mode == SearchMode.FIND_ANY ? BinarySearch.SearchMode.FIND_ANY
: mode == SearchMode.FIND_FIRST ? BinarySearch.SearchMode.FIND_FIRST
@@ -203,6 +200,8 @@ public class MultibinarySearch
rc[1][rc_i++] = amax = (int)(£{bin_search});
if (amax < 0)
amax = ~amax;
+ else if (mode == SearchMode.FIND_FIRST_AND_LAST)
+ amax >>= 32L;
minomax[0][mm_i] = imax + 1;
minomax[1][mm_i] = lastimax;