16#ifndef ALICEO2_PACKER_H_
17#define ALICEO2_PACKER_H_
27template <
typename source_T>
36 mPackingWidth{
metrics.getDatasetProperties().alphabetRangeBits} {};
39 template <
typename source_IT>
40 Packer(source_IT srcBegin, source_IT srcEnd);
44 [[nodiscard]]
inline size_t getPackingWidth() const noexcept {
return mPackingWidth; };
46 template <
typename buffer_T>
49 template <
typename source_IT,
typename dst_T>
50 [[nodiscard]] dst_T*
pack(source_IT srcBegin, source_IT srcEnd, dst_T* dstBegin, dst_T* dstEnd)
const;
52 template <
typename dst_T>
53 [[nodiscard]] dst_T*
pack(
const source_T* __restrict srcBegin,
size_t extent, dst_T* dstBegin, dst_T* dstEnd)
const;
57 size_t mPackingWidth{};
60template <
typename source_T>
61template <
typename source_IT>
65 static_assert(rans::utils::isCompatibleIter_v<source_type, source_IT>);
66 if (srcBegin != srcEnd) {
68 const auto [
min,
max] = [&]() {
69 if constexpr (std::is_pointer_v<source_IT>) {
72 const auto [minIter, maxIter] = std::minmax_element(srcBegin, srcEnd);
73 return std::make_pair<source_type>(*minIter, *maxIter);
83template <
typename source_T>
84template <
typename buffer_T>
88 return rans::computePackingBufferSize<buffer_T>(messageLength, mPackingWidth);
94template <
typename source_T>
95template <
typename dst_T>
98 return pack(srcBegin, srcBegin + extent, dstBegin, dstEnd);
101template <
typename source_T>
102template <
typename source_IT,
typename dst_T>
105 static_assert(std::is_same_v<source_T, typename std::iterator_traits<source_IT>::value_type>);
106 size_t extent = std::distance(srcBegin, srcEnd);
source_type getOffset() const noexcept
dst_T * pack(const source_T *__restrict srcBegin, size_t extent, dst_T *dstBegin, dst_T *dstEnd) const
Packer(source_IT srcBegin, source_IT srcEnd)
size_t getPackingWidth() const noexcept
size_t getPackingBufferSize(size_t messageLength) const noexcept
Packer(rans::Metrics< source_type > &metrics)
dst_T * pack(source_IT srcBegin, source_IT srcEnd, dst_T *dstBegin, dst_T *dstEnd) const
constexpr T * toPtr() const noexcept
GLsizei GLenum const void GLuint GLsizei GLfloat * metrics
constexpr uint32_t getRangeBits(T min, T max) noexcept
void checkBounds(IT iteratorPosition, IT upperBound)
std::pair< source_T, source_T > minmax(gsl::span< const source_T > range)
constexpr BitPtr pack(const input_T *__restrict inputBegin, size_t extent, output_T *__restrict outputBegin, size_t packingWidth, input_T offset=static_cast< input_T >(0))