aboutsummaryrefslogtreecommitdiffhomepage
path: root/src/SparseVector.h
diff options
context:
space:
mode:
authorNeil <nyamatongwe@gmail.com>2022-07-20 11:19:40 +1000
committerNeil <nyamatongwe@gmail.com>2022-07-20 11:19:40 +1000
commite12f8f179666ed70d03c99039565ba63c45f7c7a (patch)
tree8a3fe00257883c12710d6ab63e6fcc3797167d80 /src/SparseVector.h
parent5d0ebf7f0e4a815121d5a10f2134a5bec52d7ba0 (diff)
downloadscintilla-mirror-e12f8f179666ed70d03c99039565ba63c45f7c7a.tar.gz
Implement PositionNext to iterate. Simpler than IndexAfter for client code which
is not interested in SparseVector indices.
Diffstat (limited to 'src/SparseVector.h')
-rw-r--r--src/SparseVector.h7
1 files changed, 7 insertions, 0 deletions
diff --git a/src/SparseVector.h b/src/SparseVector.h
index 01d651f0d..ccee58df5 100644
--- a/src/SparseVector.h
+++ b/src/SparseVector.h
@@ -189,6 +189,13 @@ public:
}
Check();
}
+ Sci::Position PositionNext(Sci::Position start) const noexcept {
+ const Sci::Position element = ElementFromPosition(start);
+ if (element < Elements()) {
+ return PositionOfElement(element + 1);
+ }
+ return Length() + 1; // Out of bounds to terminate
+ }
Sci::Position IndexAfter(Sci::Position position) const noexcept {
assert(position < Length());
if (position < 0)