pub struct EliasFanoBuilder { /* private fields */ }
Expand description

Builder for EliasFano.

Examples

use sucds::mii_sequences::EliasFanoBuilder;

let mut efb = EliasFanoBuilder::new(8, 5)?;

assert_eq!(efb.universe(), 8);
assert_eq!(efb.num_vals(), 5);

efb.push(1)?;
efb.push(3)?;
efb.extend([3, 5, 7])?;

let ef = efb.build();
assert_eq!(ef.len(), 5);
assert_eq!(ef.universe(), 8);

Implementations§

source§

impl EliasFanoBuilder

source

pub fn new(universe: usize, num_vals: usize) -> Result<Self>

Creates a new builder.

Arguments
  • universe: The (exclusive) upper bound of integers to be stored, i.e., an integer in [0..universe - 1].
  • num_vals: The number of integers that will be pushed (> 0).
Errors

An error is returned if num_vals == 0.

source

pub fn push(&mut self, val: usize) -> Result<()>

Pushes integer val at the end.

Arguments
  • val: Pushed integer that must be no less than the last one.
Errors

An error is returned if

source

pub fn extend<I>(&mut self, vals: I) -> Result<()>where I: IntoIterator<Item = usize>,

Appends integers at the end.

Arguments
  • vals: Pushed integers that are monotone increasing.
Errors

An error is returned if

  • vals is not monotone increasing (also compared to the current last value),
  • values in vals is no less than Self::universe(), or
  • the number of stored integers becomes no less than Self::num_vals().
source

pub fn build(self) -> EliasFano

Builds EliasFano from the pushed integers.

source

pub const fn universe(&self) -> usize

Returns the universe, i.e., the (exclusive) upper bound of possible integers.

source

pub const fn num_vals(&self) -> usize

Returns the number of integers that can be stored.

Auto Trait Implementations§

Blanket Implementations§

source§

impl<T> Any for Twhere T: 'static + ?Sized,

source§

fn type_id(&self) -> TypeId

Gets the TypeId of self. Read more
source§

impl<T> Borrow<T> for Twhere T: ?Sized,

source§

fn borrow(&self) -> &T

Immutably borrows from an owned value. Read more
source§

impl<T> BorrowMut<T> for Twhere T: ?Sized,

source§

fn borrow_mut(&mut self) -> &mut T

Mutably borrows from an owned value. Read more
source§

impl<T> From<T> for T

source§

fn from(t: T) -> T

Returns the argument unchanged.

source§

impl<T, U> Into<U> for Twhere U: From<T>,

source§

fn into(self) -> U

Calls U::from(self).

That is, this conversion is whatever the implementation of From<T> for U chooses to do.

source§

impl<T, U> TryFrom<U> for Twhere U: Into<T>,

§

type Error = Infallible

The type returned in the event of a conversion error.
source§

fn try_from(value: U) -> Result<T, <T as TryFrom<U>>::Error>

Performs the conversion.
source§

impl<T, U> TryInto<U> for Twhere U: TryFrom<T>,

§

type Error = <U as TryFrom<T>>::Error

The type returned in the event of a conversion error.
source§

fn try_into(self) -> Result<U, <U as TryFrom<T>>::Error>

Performs the conversion.