From 65ea703cfbf8d5660c59e8b1ab756ed7ddde50a9 Mon Sep 17 00:00:00 2001 From: Neil Date: Thu, 15 Jul 2021 14:04:44 +1000 Subject: Feature [feature-requests:#1381] Move SplitView to header so it can be used more widely. Ensure that case where all text is after the gap is as efficient as when all text is before the gap. --- src/SplitVector.h | 10 ++++++++++ 1 file changed, 10 insertions(+) (limited to 'src/SplitVector.h') diff --git a/src/SplitVector.h b/src/SplitVector.h index 2b4aed4be..885055bd1 100644 --- a/src/SplitVector.h +++ b/src/SplitVector.h @@ -328,6 +328,16 @@ public: } } + /// Return a pointer to a single element. + /// Does not rearrange the buffer. + const T *ElementPointer(ptrdiff_t position) const noexcept { + if (position < part1Length) { + return body.data() + position; + } else { + return body.data() + position + gapLength; + } + } + /// Return the position of the gap within the buffer. ptrdiff_t GapPosition() const noexcept { return part1Length; -- cgit v1.2.3