From 5d0ebf7f0e4a815121d5a10f2134a5bec52d7ba0 Mon Sep 17 00:00:00 2001 From: Neil Date: Wed, 20 Jul 2022 11:08:49 +1000 Subject: Add DeleteAll method as quick way to clear everything. Improves similarity to RunStyles. --- src/SparseVector.h | 5 +++++ test/unit/testSparseVector.cxx | 3 +++ 2 files changed, 8 insertions(+) diff --git a/src/SparseVector.h b/src/SparseVector.h index cfd9db02e..01d651f0d 100644 --- a/src/SparseVector.h +++ b/src/SparseVector.h @@ -147,6 +147,11 @@ public: starts->InsertText(partition, -1); Check(); } + void DeleteAll() { + starts = std::make_unique>(8); + values = std::make_unique>(); + values->InsertEmpty(0, 2); + } void DeleteRange(Sci::Position position, Sci::Position deleteLength) { // For now, delete elements in range - may want to leave value at start // or combine onto position. diff --git a/test/unit/testSparseVector.cxx b/test/unit/testSparseVector.cxx index 288f671c1..5b50d24e4 100644 --- a/test/unit/testSparseVector.cxx +++ b/test/unit/testSparseVector.cxx @@ -210,6 +210,9 @@ TEST_CASE("SparseVector") { st.SetValueAt(3, UniqueStringCopy("3")); REQUIRE(5 == st.Elements()); REQUIRE("---34--7-9-" == Representation(st)); + st.DeleteAll(); + REQUIRE(1 == st.Elements()); + REQUIRE("-" == Representation(st)); st.Check(); } -- cgit v1.2.3