ScQueryCellIteratorBase::BinarySearch

Winfried Donkers winfried.libreoffice at gmail.com
Tue Nov 1 07:02:59 UTC 2022


Hi,

To implement the function XLOOKUP in Calc (tdf127293) I need to change 
ScQueryCellIteratorBase::BinarySearch().

In BinarySearch() at each iteration a check is performed to see whether 
the range really is sorted; if not orderBroken gets the value true.

The current check is not reliable. If orderBroken gets the value true, 
the order is broken. But if orderBroken is false, we don't know if the 
order is broken. BinarySearch only uses log(n)/log(2) of the elements 
(n) in the range in its search.



Is BinarySearch the proper place to check if the range is sorted correctly?

Shouldn't this happen either at the end of the sorting routine or be 
left to the user (i.e. if the user states that the range is sorted in 
the relevant XLOOKUP argument, why should we check that)?

With the information I have now, I would like to remove the orderBroken 
variable from BinarySearch(), but possibly I am overlooking something.



Winfried



More information about the LibreOffice mailing list