summaryrefslogtreecommitdiff
path: root/sc/inc/queryiter.hxx
diff options
context:
space:
mode:
authorLuboš Luňák <l.lunak@collabora.com>2022-05-06 11:53:09 +0200
committerLuboš Luňák <l.lunak@collabora.com>2022-05-10 16:25:21 +0200
commit1d8c31ea2555b339d5a4bc5449d40d546045435b (patch)
treef04bd1be69a33eb0461ee240f2b7bc50216b1bb1 /sc/inc/queryiter.hxx
parente2f8e5cf7cf9c7b2812ffbcd48ec21dc994339d6 (diff)
sort out query iterator's BinarySearch() corner cases handling
If the code detects the range is not actually properly sorted, set position to the first row and return false to force linear search. If the searched for value belongs before the first item, do the same, in which case the linear search should see that it is this case (before this case nRow was set to the first row regardless of where the searched for value belonged). Change-Id: I8ff346783d93d74ff409b19aea394e202885647d Reviewed-on: https://gerrit.libreoffice.org/c/core/+/134100 Tested-by: Jenkins Reviewed-by: Luboš Luňák <l.lunak@collabora.com>
Diffstat (limited to 'sc/inc/queryiter.hxx')
-rw-r--r--sc/inc/queryiter.hxx10
1 files changed, 7 insertions, 3 deletions
diff --git a/sc/inc/queryiter.hxx b/sc/inc/queryiter.hxx
index 847241124a2e..f151bba90ab6 100644
--- a/sc/inc/queryiter.hxx
+++ b/sc/inc/queryiter.hxx
@@ -141,9 +141,13 @@ protected:
/* Only works if no regular expression is involved, only searches for rows in one column,
and only the first query entry is considered with simple conditions SC_LESS,SC_LESS_EQUAL,
- SC_EQUAL (sorted ascending) or SC_GREATER,SC_GREATER_EQUAL (sorted descending). Delivers
- a starting point, continue with e.g. GetThis() and GetNext() afterwards. Introduced
- for FindEqualOrSortedLastInRange(). */
+ SC_EQUAL (sorted ascending) or SC_GREATER,SC_GREATER_EQUAL (sorted descending). It
+ delivers a starting point set to nRow, i.e. the last row that either matches the searched
+ for value, or the last row that matches the condition. Continue with e.g. GetThis() and
+ GetNext() afterwards. Returns false if the searched for value is not in the search range
+ or if the range is not properly sorted, with nRow in that case set to the first row or after
+ the last row. In that case use GetFirst().
+ */
bool BinarySearch();
public: