aboutsummaryrefslogtreecommitdiff
path: root/src/trace_processor/containers/sparse_vector.h
diff options
context:
space:
mode:
Diffstat (limited to 'src/trace_processor/containers/sparse_vector.h')
-rw-r--r--src/trace_processor/containers/sparse_vector.h16
1 files changed, 12 insertions, 4 deletions
diff --git a/src/trace_processor/containers/sparse_vector.h b/src/trace_processor/containers/sparse_vector.h
index 5c803d3fb..d90fb8910 100644
--- a/src/trace_processor/containers/sparse_vector.h
+++ b/src/trace_processor/containers/sparse_vector.h
@@ -28,6 +28,13 @@
namespace perfetto {
namespace trace_processor {
+// Base class for SparseVector which allows type erasure to be implemented (e.g.
+// allows for std::unique_ptr<SparseVectorBase>).
+class SparseVectorBase {
+ public:
+ virtual ~SparseVectorBase();
+};
+
// A data structure which compactly stores a list of possibly nullable data.
//
// Internally, this class is implemented using a combination of a std::deque
@@ -36,10 +43,14 @@ namespace trace_processor {
// a slight cost (searching the BitVector to find the index into the std::deque)
// when looking up the data.
template <typename T>
-class SparseVector {
+class SparseVector : public SparseVectorBase {
public:
// Creates an empty SparseVector.
SparseVector() = default;
+ ~SparseVector() override = default;
+
+ SparseVector(SparseVector&&) = default;
+ SparseVector& operator=(SparseVector&&) noexcept = default;
// Returns the optional value at |idx| or base::nullopt if the value is null.
base::Optional<T> Get(uint32_t idx) const {
@@ -104,9 +115,6 @@ class SparseVector {
explicit SparseVector(const SparseVector&) = delete;
SparseVector& operator=(const SparseVector&) = delete;
- SparseVector(SparseVector&&) = delete;
- SparseVector& operator=(SparseVector&&) noexcept = delete;
-
std::deque<T> data_;
RowMap valid_;
uint32_t size_ = 0;