aboutsummaryrefslogtreecommitdiff
path: root/lout/container.cc
diff options
context:
space:
mode:
Diffstat (limited to 'lout/container.cc')
-rw-r--r--lout/container.cc10
1 files changed, 6 insertions, 4 deletions
diff --git a/lout/container.cc b/lout/container.cc
index de36a6f7..77f0e710 100644
--- a/lout/container.cc
+++ b/lout/container.cc
@@ -188,9 +188,10 @@ void Vector::remove(int pos)
/**
* Sort the elements in the vector. Assumes that all elements are Comparable's.
*/
-void Vector::sort()
+void Vector::sort(Comparator *comparator)
{
- qsort (array, numElements, sizeof(Object*), Comparable::compareFun);
+ Comparator::compareFunComparator = comparator;
+ qsort (array, numElements, sizeof(Object*), Comparator::compareFun);
}
/**
@@ -202,7 +203,7 @@ void Vector::sort()
* size of the array. (This is the value which can be used for
* insertion; see insertSortet()).
*/
-int Vector::bsearch(Object *key, bool mustExist)
+int Vector::bsearch(Object *key, bool mustExist, Comparator *comparator)
{
// The case !mustExist is not handled by bsearch(3), so here is a
// new implementation.
@@ -213,7 +214,7 @@ int Vector::bsearch(Object *key, bool mustExist)
while (true) {
int index = (low + high) / 2;
- int c = ((Comparable*) key)->compareTo ((Comparable*)array[index]);
+ int c = comparator->compare (key, array[index]);
if (c == 0)
return index;
else {
@@ -233,6 +234,7 @@ int Vector::bsearch(Object *key, bool mustExist)
/*
+ Comparator::compareFunComparator = comparator;
void *result = ::bsearch (&key, array, numElements, sizeof (Object*),
Comparable::compareFun);
if (result)