SparseContainer

Struct SparseContainer 

Source
pub struct SparseContainer<T: Clone> { /* private fields */ }
Expand description

A sparse container stores contiguous vertical slices of data

Implementations§

Source§

impl<T: Clone> SparseContainer<T>

Source

pub fn new() -> SparseContainer<T>

Source

pub fn all_missing(n: usize) -> SparseContainer<T>

create an n-length container will all missing data

Source

pub fn present_iter(&self) -> impl Iterator<Item = &T>

Source

pub fn len(&self) -> usize

Source

pub fn is_empty(&self) -> bool

Source

pub fn n_present(&self) -> usize

Return the number of present data

Source

pub fn n_missing(&self) -> usize

Return the number of missing data

Source

pub fn is_present(&self, ix: usize) -> bool

Returns true if the value at ix is present.

§Notes

Will panic id ix is out of bounds

Source

pub fn is_missing(&self, ix: usize) -> bool

Returns true if the value at ix is missing.

§Notes

Will panic id ix is out of bounds

Source

pub fn defragment(&mut self) -> usize

Ensure all adjacent data slices are joined. Reduces indirection. Returns the number of slice merge operations performed.

Source

pub fn pop_front(&mut self, n: usize) -> Vec<Option<T>>

Source

pub fn set_missing(&mut self, ix: usize) -> Option<T>

Set the datum at index ix as missing and return the entry that we there if it existed.

Source

pub fn extract(&mut self, ix: usize) -> Option<T>

Completely remove the datum at index ix and return it if it exists.

This operation decrements the total number of data by one.

Source

pub fn break_slices(&mut self, max_slice_len: usize)

Breaks any slice greater than max_slice_len to be between (max_slice_len + 1) / 2 and max_slice_len. This is designed to help parallelism.

Trait Implementations§

Source§

impl<T: Clone> AccumScore<T> for SparseContainer<T>

Source§

fn accum_score<F: Fn(&T) -> f64>(&self, scores: &mut [f64], ln_f: &F)

Compute scores on the data using score_fn and add them to scores
Source§

impl<T: Clone + Clone> Clone for SparseContainer<T>

Source§

fn clone(&self) -> SparseContainer<T>

Returns a duplicate of the value. Read more
1.0.0 · Source§

fn clone_from(&mut self, source: &Self)

Performs copy-assignment from source. Read more
Source§

impl<T: Clone + TryFrom<Datum>> Container<T> for SparseContainer<T>

Source§

fn get_slices(&self) -> Vec<(usize, &[T])>

get the data slices and the start indices
Source§

fn get(&self, ix: usize) -> Option<T>

Get the entry at ix if it exists
Source§

fn present_cloned(&self) -> Vec<T>

Get as cloned vector containing only the present data
Source§

fn push(&mut self, xopt: Option<T>)

Append a new datum to the end of the container
Source§

fn insert_overwrite(&mut self, ix: usize, x: T)

Insert or overwrite an entry at ix
Source§

fn remove(&mut self, ix: usize) -> Option<T>

Remove and return the entry at ix if it exists. Used to mark a present datum as missing, not to completely remove a record. Does not decrease the length.
Source§

fn upsize(&mut self, n: usize)

Append n new empty entries to the container
Source§

fn push_datum(&mut self, x: Datum)

Source§

fn insert_datum(&mut self, row_ix: usize, x: Datum)

Source§

impl<T: Debug + Clone> Debug for SparseContainer<T>

Source§

fn fmt(&self, f: &mut Formatter<'_>) -> Result

Formats the value using the given formatter. Read more
Source§

impl<T: Clone> Default for SparseContainer<T>

Source§

fn default() -> SparseContainer<T>

Returns the “default value” for a type. Read more
Source§

impl<'de, T> Deserialize<'de> for SparseContainer<T>
where T: Deserialize<'de> + Default + Clone,

Source§

fn deserialize<__D>(__deserializer: __D) -> Result<Self, __D::Error>
where __D: Deserializer<'de>,

Deserialize this value from the given Serde deserializer. Read more
Source§

impl<T: Clone> From<Vec<(T, bool)>> for SparseContainer<T>

Source§

fn from(xs: Vec<(T, bool)>) -> SparseContainer<T>

Converts to this type from the input type.
Source§

impl<T: Clone> From<Vec<Option<T>>> for SparseContainer<T>

Source§

fn from(xs: Vec<Option<T>>) -> SparseContainer<T>

Converts to this type from the input type.
Source§

impl<T: Clone> From<Vec<T>> for SparseContainer<T>

Source§

fn from(xs: Vec<T>) -> SparseContainer<T>

Converts to this type from the input type.
Source§

impl<T: PartialEq + Clone> PartialEq for SparseContainer<T>

Source§

fn eq(&self, other: &SparseContainer<T>) -> bool

Tests for self and other values to be equal, and is used by ==.
1.0.0 · Source§

fn ne(&self, other: &Rhs) -> bool

Tests for !=. The default implementation is almost always sufficient, and should not be overridden without very good reason.
Source§

impl<T> Serialize for SparseContainer<T>
where T: Serialize + Clone,

Source§

fn serialize<__S>(&self, __serializer: __S) -> Result<__S::Ok, __S::Error>
where __S: Serializer,

Serialize this value into the given Serde serializer. Read more
Source§

impl<T: Clone> StructuralPartialEq for SparseContainer<T>

Auto Trait Implementations§

§

impl<T> Freeze for SparseContainer<T>

§

impl<T> RefUnwindSafe for SparseContainer<T>
where T: RefUnwindSafe,

§

impl<T> Send for SparseContainer<T>
where T: Send,

§

impl<T> Sync for SparseContainer<T>
where T: Sync,

§

impl<T> Unpin for SparseContainer<T>
where T: Unpin,

§

impl<T> UnwindSafe for SparseContainer<T>
where T: UnwindSafe,

Blanket Implementations§

Source§

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

Source§

fn type_id(&self) -> TypeId

Gets the TypeId of self. Read more
Source§

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

Source§

fn borrow(&self) -> &T

Immutably borrows from an owned value. Read more
Source§

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

Source§

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

Mutably borrows from an owned value. Read more
Source§

impl<T> CloneToUninit for T
where T: Clone,

Source§

unsafe fn clone_to_uninit(&self, dest: *mut u8)

🔬This is a nightly-only experimental API. (clone_to_uninit)
Performs copy-assignment from self to dest. 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 T
where 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> IntoEither for T

Source§

fn into_either(self, into_left: bool) -> Either<Self, Self>

Converts self into a Left variant of Either<Self, Self> if into_left is true. Converts self into a Right variant of Either<Self, Self> otherwise. Read more
Source§

fn into_either_with<F>(self, into_left: F) -> Either<Self, Self>
where F: FnOnce(&Self) -> bool,

Converts self into a Left variant of Either<Self, Self> if into_left(&self) returns true. Converts self into a Right variant of Either<Self, Self> otherwise. Read more
Source§

impl<T> Pointable for T

Source§

const ALIGN: usize

The alignment of pointer.
Source§

type Init = T

The type for initializers.
Source§

unsafe fn init(init: <T as Pointable>::Init) -> usize

Initializes a with the given initializer. Read more
Source§

unsafe fn deref<'a>(ptr: usize) -> &'a T

Dereferences the given pointer. Read more
Source§

unsafe fn deref_mut<'a>(ptr: usize) -> &'a mut T

Mutably dereferences the given pointer. Read more
Source§

unsafe fn drop(ptr: usize)

Drops the object pointed to by the given pointer. Read more
Source§

impl<T> ToOwned for T
where T: Clone,

Source§

type Owned = T

The resulting type after obtaining ownership.
Source§

fn to_owned(&self) -> T

Creates owned data from borrowed data, usually by cloning. Read more
Source§

fn clone_into(&self, target: &mut T)

Uses borrowed data to replace owned data, usually by cloning. Read more
Source§

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

Source§

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 T
where U: TryFrom<T>,

Source§

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.
Source§

impl<V, T> VZip<V> for T
where V: MultiLane<T>,

Source§

fn vzip(self) -> V

Source§

impl<T> DeserializeOwned for T
where T: for<'de> Deserialize<'de>,