use crate::{
bitpack::{bitpack_encoded, packed_byte_size},
encoder::{
Exception,
exception::{exceptions_byte_size, write_exceptions},
},
float::AlpFloat,
header::{header_len, write_header},
params::AlpParams,
};
#[inline(always)]
pub fn encode_standard<F: AlpFloat>(
params: AlpParams,
encoded_ints: &[F::Int],
base: F::Int,
exceptions: &[Exception<F::RawBits>],
dst: &mut Vec<u8>,
) {
let count = encoded_ints.len();
let is_large = count > u16::MAX as usize;
let exc_len = exceptions_byte_size::<F>(exceptions.len(), is_large);
let total_len =
header_len(count) + F::BASE_SIZE + packed_byte_size(count, params.bit_width) + exc_len;
dst.reserve(total_len);
let type_byte = params.standard_type::<F>();
write_header(type_byte, count, Some(params.pack()), dst);
F::write_base(base, dst);
bitpack_encoded::<F>(encoded_ints, base, params.bit_width, dst);
write_exceptions::<F>(count, exceptions, dst);
}