From e9f310d4043e58739c9e661159a35847a7ba5df5 Mon Sep 17 00:00:00 2001 From: Neil Date: Mon, 2 Dec 2019 08:34:47 +1100 Subject: Backport: Add SparseVector::IndexAfter for efficiently finding elements in a range. Backport of changeset 7779:67b7e8f152a9. --- src/SparseVector.h | 7 +++++++ 1 file changed, 7 insertions(+) (limited to 'src/SparseVector.h') diff --git a/src/SparseVector.h b/src/SparseVector.h index 6dd02ba8b..86d631c3f 100644 --- a/src/SparseVector.h +++ b/src/SparseVector.h @@ -154,6 +154,13 @@ public: starts->InsertText(partition, -1); Check(); } + Sci::Position IndexAfter(Sci::Position position) const noexcept { + assert(position < Length()); + if (position < 0) + return 0; + const Sci::Position partition = starts->PartitionFromPosition(position); + return partition + 1; + } void Check() const { #ifdef CHECK_CORRECTNESS starts->Check(); -- cgit v1.2.3