From 926cb6f7d228b347db16a45e1f2632da475da1f0 Mon Sep 17 00:00:00 2001 From: Neil Date: Sun, 31 Jul 2022 15:51:53 +1000 Subject: Added change history which can display document changes (modified, saved, ...) in the margin or in the text. --- src/SparseVector.h | 16 ++++++++++++++++ 1 file changed, 16 insertions(+) (limited to 'src/SparseVector.h') diff --git a/src/SparseVector.h b/src/SparseVector.h index f8c35fdc5..09eb1f98d 100644 --- a/src/SparseVector.h +++ b/src/SparseVector.h @@ -57,6 +57,22 @@ public: return empty; } } + T Extract(Sci::Position position) { + // Move value currently at position; clear and remove position; return value. + // Doesn't remove position at start or end. + assert(position <= Length()); + const Sci::Position partition = ElementFromPosition(position); + assert(partition >= 0); + assert(partition <= starts.Partitions()); + assert(starts.PositionFromPartition(partition) == position); + T value = std::move(values.operator[](partition)); + if ((partition > 0) && (partition < starts.Partitions())) { + starts.RemovePartition(partition); + values.Delete(partition); + } + Check(); + return value; + } template void SetValueAt(Sci::Position position, ParamType &&value) { assert(position <= Length()); -- cgit v1.2.3