4#ifndef CBM_ALGO_BASE_PARTITIONED_SPAN_H
5#define CBM_ALGO_BASE_PARTITIONED_SPAN_H
17 template<
typename T,
typename Allocator>
18 class PartitionedVector;
22 template<
typename U,
typename T>
23 using EnableOnConst = std::enable_if_t<std::is_const_v<T> && std::is_same_v<U, std::remove_cv_t<T>>>;
25 template<
typename U,
typename T>
26 using EnableOnNonConst = std::enable_if_t<!std::is_const_v<T> && std::is_same_v<U, std::remove_cv_t<T>>>;
37 template<
typename Allocator>
38 PartitionedSpan(std::vector<T, Allocator>& container, gsl::span<const size_t> offsets,
39 gsl::span<const u32> addresses)
48 template<
typename Allocator>
49 PartitionedSpan(
const std::vector<T, Allocator>& container, gsl::span<const size_t> offsets,
50 gsl::span<const u32> addresses)
59 PartitionedSpan(std::array<T, N>& container, gsl::span<const size_t> offsets, gsl::span<const u32> addresses)
69 PartitionedSpan(
const std::array<T, N>& container, gsl::span<const size_t> offsets, gsl::span<const u32> addresses)
78 PartitionedSpan(gsl::span<T> data, gsl::span<const size_t> offsets, gsl::span<const u32> addresses)
86 template<
typename U,
typename Allocator,
typename = detail::EnableOnConst<U, T>>
95 template<
typename U,
typename Allocator,
typename = detail::EnableOnNonConst<U, T>>
104 template<
typename U,
typename = detail::EnableOnConst<U, T>>
159 throw std::runtime_error(
"PartitionedSpan: fOffsets.size() != fAdresses.size()");
161 if (
fOffsets.front() != 0)
throw std::runtime_error(
"PartitionedSpan: fOffsets.front() != 0");
163 throw std::runtime_error(
"PartitionedSpan: fOffsets.back() != fData.size()");
169 if (i >=
fAdresses.size())
throw std::out_of_range(
"PartitionedSpan: index out of bounds");
178 template<
typename T,
template<
typename>
class Container>
181 template<
typename T,
template<
typename>
class Container>
184 template<
typename T,
typename Allocator>
187 template<
typename T,
typename Allocator>
gsl::span< const size_t > Offsets() const
PartitionedSpan(PartitionedSpan< U > other)
std::pair< gsl::span< T >, u32 > Partition(size_t i) const
PartitionedSpan(PartitionedVector< U, Allocator > &container)
PartitionedSpan(std::vector< T, Allocator > &container, gsl::span< const size_t > offsets, gsl::span< const u32 > addresses)
PartitionedSpan(const PartitionedVector< U, Allocator > &container)
PartitionedSpan(const std::array< T, N > &container, gsl::span< const size_t > offsets, gsl::span< const u32 > addresses)
gsl::span< T > operator[](size_t i) const
PartitionedSpan(std::array< T, N > &container, gsl::span< const size_t > offsets, gsl::span< const u32 > addresses)
u32 Address(size_t i) const
void EnsureDimensions() const
gsl::span< T > Data() const
void EnsureBounds(size_t i) const
gsl::span< T > UnsafePartitionSpan(size_t i) const
gsl::span< const u32 > Addresses() const
size_t NPartitions() const
gsl::span< const size_t > fOffsets
PartitionedSpan(const std::vector< T, Allocator > &container, gsl::span< const size_t > offsets, gsl::span< const u32 > addresses)
size_t Size(size_t i) const
PartitionedSpan(gsl::span< T > data, gsl::span< const size_t > offsets, gsl::span< const u32 > addresses)
static constexpr size_t NullOffset[1]
gsl::span< const u32 > fAdresses
size_t UnsafeSize(size_t i) const
A vector that is partitioned into multiple subvectors.
std::enable_if_t<!std::is_const_v< T > &&std::is_same_v< U, std::remove_cv_t< T > > > EnableOnNonConst
std::enable_if_t< std::is_const_v< T > &&std::is_same_v< U, std::remove_cv_t< T > > > EnableOnConst
PartitionedSpan(Container< T > &, gsl::span< const size_t >, gsl::span< const u32 >) -> PartitionedSpan< T >