use std::marker::PhantomData;
use crate::bit_block::BitBlock;
use crate::cache;
use crate::cache::ReduceCache;
use crate::primitive_array::PrimitiveArray;
type DefaultCache = cache::FixedCache<32>;
pub trait Config: 'static {
type Level0BitBlock: BitBlock;
type Level0BlockIndices: PrimitiveArray;
type Level1BitBlock: BitBlock;
type Level1BlockIndices: PrimitiveArray;
type DataBitBlock: BitBlock;
const MAX_CAPACITY: usize;
type DefaultCache: ReduceCache;
}
#[inline]
const fn max_capacity<Conf: Config>() -> usize {
(1 << Conf::Level0BitBlock::SIZE_POT_EXPONENT)
* (1 << Conf::Level1BitBlock::SIZE_POT_EXPONENT)
* (1 << Conf::DataBitBlock::SIZE_POT_EXPONENT)
}
#[derive(Default)]
pub struct _64bit<DefaultCache: ReduceCache = self::DefaultCache>(PhantomData<DefaultCache>);
impl<DefaultCache: ReduceCache> Config for _64bit<DefaultCache> {
type Level0BitBlock = u64;
type Level0BlockIndices = [u8; 64];
type Level1BitBlock = u64;
type Level1BlockIndices = [u16; 64];
type DataBitBlock = u64;
const MAX_CAPACITY: usize = max_capacity::<Self>();
type DefaultCache = DefaultCache;
}
#[cfg(feature = "simd")]
#[cfg_attr(docsrs, doc(cfg(feature = "simd")))]
#[derive(Default)]
pub struct _128bit<DefaultCache: ReduceCache = self::DefaultCache>(PhantomData<DefaultCache>);
#[cfg(feature = "simd")]
#[cfg_attr(docsrs, doc(cfg(feature = "simd")))]
impl<DefaultCache: ReduceCache> Config for _128bit<DefaultCache> {
type Level0BitBlock = wide::u64x2;
type Level0BlockIndices = [u8; 128];
type Level1BitBlock = wide::u64x2;
type Level1BlockIndices = [u16; 128];
type DataBitBlock = wide::u64x2;
const MAX_CAPACITY: usize = max_capacity::<Self>();
type DefaultCache = DefaultCache;
}
#[cfg(feature = "simd")]
#[cfg_attr(docsrs, doc(cfg(feature = "simd")))]
#[derive(Default)]
pub struct _256bit<DefaultCache: ReduceCache = self::DefaultCache>(PhantomData<DefaultCache>);
#[cfg(feature = "simd")]
#[cfg_attr(docsrs, doc(cfg(feature = "simd")))]
impl<DefaultCache: ReduceCache> Config for _256bit<DefaultCache> {
type Level0BitBlock = wide::u64x4;
type Level0BlockIndices = [u8; 256];
type Level1BitBlock = wide::u64x4;
type Level1BlockIndices = [u16; 256];
type DataBitBlock = wide::u64x4;
const MAX_CAPACITY: usize = max_capacity::<Self>() - (256*256);
type DefaultCache = DefaultCache;
}