Struct sliding_windows::Storage [] [src]

pub struct Storage<T> {
    // some fields omitted
}

This holds the backing allocation for the Window of a Adaptor.

See sliding_windows for more information.

Methods

impl<T> Storage<T>

fn optimized<I: Iterator>(iter: &I, window_size: usize) -> Storage<T>

Create a new Storage with a given window size optimized for a given Iterator. This will allocate an amount of memory big enough to avoid shifting elements during iteration.

This should be the most performant option, which uses the most memory: Iterator::size_hint() * mem::size_of<Iterator::Item>. If there is no size_hint, this is identical to Storage::new().

If you want to use less memory, but more CPU, consider using Storage::new() or Storage::new_exact() instead.

See sliding_windows for more information.

fn new(window_size: usize) -> Storage<T>

Create a new Storage with a given window size. This will allocate twice as much memory as is needed to store the Window for performance reasons.

If you want to use as few memory as possible, but more CPU, consider using Storage::new_exact() instead.

See sliding_windows for more information.

fn new_exact(window_size: usize) -> Storage<T>

Create a new Storage with a given window size. This will allocate exactly as much memory as is needed to store the Window.

See sliding_windows for more information.

fn from_vec<S: Into<Vec<T>>>(vec: S, window_size: usize) -> Storage<T>

Create a new Storage with a given window size from a given struct implementing Into<Vec>. The contents of the Vec will be removed. This will reuse the allocation of the Vec instead of allocating new memory.

See sliding_windows for more information.

Trait Implementations

impl<T> Into<Vec<T>> for Storage<T>

fn into(self) -> Vec<T>