Pixie
Loading...
Searching...
No Matches
pixie::BasicPackedIntegerVector< Storage, Value > Class Template Reference

Immutable runtime-width packed integer vector over configurable storage. More...

#include <packed.h>

Inheritance diagram for pixie::BasicPackedIntegerVector< Storage, Value >:
pixie::IntegerVectorBase< BasicPackedIntegerVector< Storage, std::uint64_t >, std::uint64_t > pixie::SerializationBase< BasicPackedIntegerVector< Storage, std::uint64_t > >

Public Types

using value_type = Value
 Stored unsigned integer type.
 
using size_type = std::size_t
 Type used for element counts, widths, and positions.
 
- Public Types inherited from pixie::IntegerVectorBase< BasicPackedIntegerVector< Storage, std::uint64_t >, std::uint64_t >
using value_type
 Stored integer type.
 
using size_type
 Type used for element counts and zero-based positions.
 

Public Member Functions

 BasicPackedIntegerVector ()=default
 Construct an empty width-zero vector.
 
 BasicPackedIntegerVector (std::span< const value_type > values)
 Pack values using their minimum required width.
 
 BasicPackedIntegerVector (std::span< const value_type > values, size_type width)
 Pack values after validating an explicit maximum width.
 
size_type width () const
 Return the logical runtime width in bits, in [0, digits(Value)].
 
size_type size_impl () const
 Return the logical number of elements.
 
value_type value_at_impl (size_type position) const
 Read one valid zero-based position without bounds checking.
 
void copy_to_impl (size_type begin, std::span< value_type > output) const
 Copy a range already validated by the public facade.
 
size_type memory_usage_bytes_impl () const
 Return inline bytes plus owned storage capacity.
 
void serialize_impl (BinaryWriter &writer) const
 Write a version-1 canonical little-endian packed-vector artifact.
 
- Public Member Functions inherited from pixie::IntegerVectorBase< BasicPackedIntegerVector< Storage, std::uint64_t >, std::uint64_t >
size_type size () const
 Return the logical number of elements.
 
bool empty () const
 Return whether the vector has no elements.
 
value_type operator[] (size_type position) const
 Read the element at zero-based position without bounds checking.
 
value_type at (size_type position) const
 Read the element at zero-based position with bounds checking.
 
void copy_to (size_type begin, std::span< value_type > output) const
 Copy a checked contiguous source range into output.
 
size_type memory_usage_bytes () const
 Return total memory owned by this vector when supported.
 
- Public Member Functions inherited from pixie::SerializationBase< BasicPackedIntegerVector< Storage, std::uint64_t > >
void serialize (BinaryWriter &writer) const
 Serialize this value through its concrete implementation.
 

Static Public Member Functions

static BasicPackedIntegerVector deserialize_impl (BinaryReader &reader, DeserializationValidation validation=DeserializationValidation::kQuick)
 Restore one packed-vector artifact and advance reader on success.
 
- Static Public Member Functions inherited from pixie::SerializationBase< BasicPackedIntegerVector< Storage, std::uint64_t > >
static BasicPackedIntegerVector< Storage, std::uint64_t > deserialize (BinaryReader &reader, Context &&... context)
 Restore exactly Derived and advance reader on success.
 
static BasicPackedIntegerVector< Storage, std::uint64_t > deserialize (std::span< const std::byte > &data, Context &&... context)
 Restore exactly Derived and advance a mutable byte span.
 

Detailed Description

template<StorageImplementation Storage, IntegerVectorValue Value = std::uint64_t>
requires (std::same_as<Storage, AlignedStorage> || std::same_as<Storage, ReadOnlyStorageView>)
class pixie::BasicPackedIntegerVector< Storage, Value >

Immutable runtime-width packed integer vector over configurable storage.

Template Parameters
StorageAlignedStorage for an owner or ReadOnlyStorageView for a zero-copy view.
ValueUnsigned element type other than bool, no wider than 64 bits.

Values are packed LSB-first into 64-bit words. An owning vector stores cache-line-padded allocation internally, but only logical packed words are serialized. A view borrows its serialized payload; the backing bytes must remain alive, immutable, and aligned for the view's lifetime.

Constructor & Destructor Documentation

◆ BasicPackedIntegerVector() [1/2]

template<StorageImplementation Storage, IntegerVectorValue Value = std::uint64_t>
pixie::BasicPackedIntegerVector< Storage, Value >::BasicPackedIntegerVector ( std::span< const value_type > values)
inlineexplicit

Pack values using their minimum required width.

Empty and all-zero inputs use width zero and no payload.

Exceptions
std::length_errorif the packed dimensions overflow size_t.

◆ BasicPackedIntegerVector() [2/2]

template<StorageImplementation Storage, IntegerVectorValue Value = std::uint64_t>
pixie::BasicPackedIntegerVector< Storage, Value >::BasicPackedIntegerVector ( std::span< const value_type > values,
size_type width )
inline

Pack values after validating an explicit maximum width.

Width must be in [0, digits(value_type)]. Every value must fit; values are never truncated. Empty and all-zero inputs are normalized to canonical width zero.

Exceptions
std::invalid_argumentif the width is invalid or a value does not fit.
std::length_errorif the packed dimensions overflow size_t.

Member Function Documentation

◆ deserialize_impl()

template<StorageImplementation Storage, IntegerVectorValue Value = std::uint64_t>
static BasicPackedIntegerVector pixie::BasicPackedIntegerVector< Storage, Value >::deserialize_impl ( BinaryReader & reader,
DeserializationValidation validation = DeserializationValidation::kQuick )
inlinestatic

Restore one packed-vector artifact and advance reader on success.

Owner restoration decodes canonical words into independent aligned storage. View restoration retains an exact span into the reader's backing bytes, which must remain alive and immutable. Views require native little-endian word order and eight-byte-aligned payload bytes. Quick mode validates complete framing and safe dimensions; full mode also requires unused high bits in the final logical word to be zero. Failure leaves reader unchanged.

Exceptions
std::invalid_argumentfor malformed, incompatible, unaligned, or noncanonical input.
std::length_errorfor unrepresentable dimensions.

◆ memory_usage_bytes_impl()

template<StorageImplementation Storage, IntegerVectorValue Value = std::uint64_t>
size_type pixie::BasicPackedIntegerVector< Storage, Value >::memory_usage_bytes_impl ( ) const
inline

Return inline bytes plus owned storage capacity.

A read-only view excludes all borrowed backing bytes.

◆ serialize_impl()

template<StorageImplementation Storage, IntegerVectorValue Value = std::uint64_t>
void pixie::BasicPackedIntegerVector< Storage, Value >::serialize_impl ( BinaryWriter & writer) const
inline

Write a version-1 canonical little-endian packed-vector artifact.

Exactly ceil(size() * width() / 64) logical words are written; owner allocation padding is excluded. The artifact can later be restored as either an independent owner or a zero-copy read-only view.

Exceptions
std::invalid_argumentif the artifact would not begin at an eight-byte-aligned writer offset.

The documentation for this class was generated from the following file: