From 85a7b2ac6d7ceaa1b8d7a71bedf59d80d66fc471 Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?Felix=20G=C3=BCndling?= Date: Mon, 16 Dec 2024 13:48:45 +0100 Subject: [PATCH] paged_vecvec::insert, generic vecvec::view --- include/cista/containers/paged_vecvec.h | 10 ++++++++++ include/cista/containers/vecvec.h | 12 ++++++------ 2 files changed, 16 insertions(+), 6 deletions(-) diff --git a/include/cista/containers/paged_vecvec.h b/include/cista/containers/paged_vecvec.h index 33dd4309..53ab9181 100644 --- a/include/cista/containers/paged_vecvec.h +++ b/include/cista/containers/paged_vecvec.h @@ -323,6 +323,16 @@ struct paged_vecvec { return emplace_back(std::string_view{s}); } + template ().begin()), data_value_type>>> + void insert(Key const& k, Container&& bucket) { + auto p = paged_.create_page( + static_cast(bucket.size())); + paged_.copy(p, std::begin(bucket), std::end(bucket)); + idx_.insert(idx_.begin() + to_idx(k), p); + } + void resize(size_type const size) { for (auto i = size; i < idx_.size(); ++i) { paged_.free_page(idx_[i]); diff --git a/include/cista/containers/vecvec.h b/include/cista/containers/vecvec.h index 3a56b3dd..ae4bd9ef 100644 --- a/include/cista/containers/vecvec.h +++ b/include/cista/containers/vecvec.h @@ -34,9 +34,9 @@ struct basic_vecvec { data_value_type const* data() const { return empty() ? nullptr : &front(); } template , - typename Traits = std::char_traits> - std::basic_string_view view() const { - return std::basic_string_view{begin(), size()}; + typename = std::enable_if_t>> + std::basic_string_view view() const { + return {begin(), size()}; } value_type& front() { @@ -191,9 +191,9 @@ struct basic_vecvec { data_value_type const* data() const { return empty() ? nullptr : &front(); } template , - typename = std::enable_if_t>> - std::string_view view() const { - return std::string_view{begin(), size()}; + typename = std::enable_if_t>> + std::basic_string_view view() const { + return {begin(), size()}; } value_type const& front() const {