HikoGUI
A low latency retained GUI
Loading...
Searching...
No Matches
Public Types | Public Member Functions | Static Public Attributes | Friends
v1::packed_int_array< BitsPerInteger, N > Class Template Reference

#include <hikogui/packed_int_array.hpp>

Public Types

using value_type
 The value type of the unsigned integers that are stored in the array.
 

Public Member Functions

template<std::integral... Args>
constexpr packed_int_array (Args... args) noexcept
 Constructor of the array.
 
constexpr size_t size () const noexcept
 The number of integers stored in the array.
 
constexpr value_type operator[] (size_t i) const noexcept
 Get the integer at an index.
 

Static Public Attributes

static constexpr size_t bits_per_integer = BitsPerInteger
 Number of bits of the unsigned integer.
 
static constexpr size_t store_size = ceil(bits_per_integer + CHAR_BIT - 1, size_t{CHAR_BIT}) / size_t{CHAR_BIT}
 Number of bytes required to hold the number of bits.
 

Friends

template<size_t I>
constexpr value_type get (packed_int_array const &rhs) noexcept
 Get the integer at an index.
 

Detailed Description

template<size_t BitsPerInteger, size_t N>
class v1::packed_int_array< BitsPerInteger, N >

An array of integers.

The integers in the array are tightly packed without padding bits.

Template Parameters
BitsPerIntegerNumber of bits of each integer, between 0 and 57.
NThe number of integers to store.

Member Typedef Documentation

◆ value_type

template<size_t BitsPerInteger, size_t N>
using v1::packed_int_array< BitsPerInteger, N >::value_type
Initial value:
std::conditional_t<sizeof(unsigned char) >= store_size, unsigned char,
std::conditional_t<sizeof(unsigned short) >= store_size, unsigned short,
std::conditional_t<sizeof(unsigned int) >= store_size, unsigned int,
std::conditional_t<sizeof(unsigned long) >= store_size, unsigned long,
unsigned long long>>>>
constexpr Out narrow_cast(In rhs) noexcept
Cast numeric values without loss of precision.
Definition cast.hpp:158
static constexpr size_t store_size
Number of bytes required to hold the number of bits.
Definition packed_int_array.hpp:35

The value type of the unsigned integers that are stored in the array.

The size of the unsigned integer type is automatically selected to be the smallest type that can hold BitsPerInteger and can also be aligned/adjusted by up to 7 bits.

Constructor & Destructor Documentation

◆ packed_int_array()

template<size_t BitsPerInteger, size_t N>
template<std::integral... Args>
constexpr v1::packed_int_array< BitsPerInteger, N >::packed_int_array ( Args... args)
inlineconstexprnoexcept

Constructor of the array.

Parameters
argsA list of integers.

Member Function Documentation

◆ operator[]()

template<size_t BitsPerInteger, size_t N>
constexpr value_type v1::packed_int_array< BitsPerInteger, N >::operator[] ( size_t i) const
inlineconstexprnoexcept

Get the integer at an index.

If possible this function will use load() to do an efficient unaligned load from memory.

Note
It is undefined behavior if @i is out-of-bound.
Parameters
iAn index into the array.
Returns
The unsigned integer retrieved from the array.

◆ size()

template<size_t BitsPerInteger, size_t N>
constexpr size_t v1::packed_int_array< BitsPerInteger, N >::size ( ) const
inlineconstexprnoexcept

The number of integers stored in the array.

Friends And Related Symbol Documentation

◆ get

template<size_t BitsPerInteger, size_t N>
template<size_t I>
constexpr value_type get ( packed_int_array< BitsPerInteger, N > const & rhs)
friend

Get the integer at an index.

If possible this function will use load() to do an efficient unaligned load from memory.

Note
It is undefined behavior if @I is out-of-bound.
Template Parameters
IAn index into the array.
Parameters
rhsThe packed int array to read from.
Returns
The unsigned integer retrieved from the array.

Field Documentation

◆ bits_per_integer

template<size_t BitsPerInteger, size_t N>
constexpr size_t v1::packed_int_array< BitsPerInteger, N >::bits_per_integer = BitsPerInteger
staticconstexpr

Number of bits of the unsigned integer.

◆ store_size

template<size_t BitsPerInteger, size_t N>
constexpr size_t v1::packed_int_array< BitsPerInteger, N >::store_size = ceil(bits_per_integer + CHAR_BIT - 1, size_t{CHAR_BIT}) / size_t{CHAR_BIT}
staticconstexpr

Number of bytes required to hold the number of bits.

This needs extra 7 bits for alignment/adjustment.


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