aboutsummaryrefslogtreecommitdiff
path: root/lout/container.cc
diff options
context:
space:
mode:
authorSebastian Geerken <devnull@localhost>2013-04-15 10:23:58 +0200
committerSebastian Geerken <devnull@localhost>2013-04-15 10:23:58 +0200
commit92116e9be3fbca3c5614b661a2b8e99d466d3819 (patch)
tree22a58a4ff2e7a9d956ebc184427d123194069a10 /lout/container.cc
parent1790b0b654f49d11aefc1900442fe350415af77e (diff)
Container::bsearch with a variable range to search.
Diffstat (limited to 'lout/container.cc')
-rw-r--r--lout/container.cc7
1 files changed, 4 insertions, 3 deletions
diff --git a/lout/container.cc b/lout/container.cc
index 77f0e710..5f3be123 100644
--- a/lout/container.cc
+++ b/lout/container.cc
@@ -203,14 +203,15 @@ void Vector::sort(Comparator *comparator)
* size of the array. (This is the value which can be used for
* insertion; see insertSortet()).
*/
-int Vector::bsearch(Object *key, bool mustExist, Comparator *comparator)
+int Vector::bsearch(Object *key, bool mustExist, int start, int end,
+ Comparator *comparator)
{
// The case !mustExist is not handled by bsearch(3), so here is a
// new implementation.
- if (numElements == 0)
+ if (start >= end)
return mustExist ? -1 : 0;
- int high = numElements - 1, low = 0;
+ int low = start, high = end;
while (true) {
int index = (low + high) / 2;