[][src]Struct compact::CVec

pub struct CVec<T, A: Allocator = DefaultHeap> { /* fields omitted */ }

A dynamically-sized vector that can be stored in compact sequential storage and automatically spills over into free heap storage using Allocator. Tries to closely follow the API of std::vec::Vec, but is not complete.

Implementations

impl<T: Compact + Clone, A: Allocator> CompactVec<T, A>[src]

pub fn len(&self) -> usize[src]

Get the number of elements in the vector

pub fn is_empty(&self) -> bool[src]

Is the vector empty?

pub fn new() -> CompactVec<T, A>[src]

Create a new, empty vector

pub fn with_capacity(cap: usize) -> CompactVec<T, A>[src]

Create a new, empty vector with a given capacity

pub unsafe fn from_raw_parts(
    ptr: *mut T,
    len: usize,
    cap: usize
) -> CompactVec<T, A>
[src]

Create a new vector from raw parts Assumes that ptr has been allocated by the same Allocator that is A

pub fn capacity(&self) -> usize[src]

current capacity

pub fn push(&mut self, value: T)[src]

Push an item onto the vector, spills onto the heap if the capacity in compact storage is insufficient

pub fn push_at(&mut self, _: usize, value: T)[src]

push at position

pub fn extend_from_copy_slice(&mut self, other: &[T]) where
    T: Copy
[src]

Extend from a copyable slice

pub fn pop(&mut self) -> Option<T>[src]

Pop and return the last element, if the vector wasn't empty

pub fn insert(&mut self, index: usize, value: T)[src]

Insert a value at index, copying the elements after index upwards

pub fn remove(&mut self, index: usize) -> T[src]

Remove the element at index, copying the elements after index downwards

pub fn swap_remove(&mut self, index: usize) -> T[src]

Removes an element from the vector and returns it.

The removed element is replaced by the last element of the vector.

This does not preserve ordering, but is O(1).

pub fn retain<F: FnMut(&T) -> bool>(&mut self, keep: F)[src]

Take a function which returns whether an element should be kept, and mutably removes all elements from the vector which are not kept

pub fn truncate(&mut self, desired_len: usize)[src]

Truncate the vector to the given length

pub fn clear(&mut self)[src]

Clear the vector

pub fn drain(&mut self) -> IntoIter<T, A>[src]

Drain (empty & iterate over) the vector

pub fn ptr_to_string(&self) -> String[src]

debug printing

Trait Implementations

impl<T: Compact + Clone, A: Allocator> Clone for CompactVec<T, A>[src]

impl<T: Copy, A: Allocator> Clone for CompactVec<T, A>[src]

impl<T: Compact + Clone, A: Allocator> Compact for CompactVec<T, A>[src]

impl<T: Copy, A: Allocator> Compact for CompactVec<T, A>[src]

impl<T: Compact + Debug, A: Allocator> Debug for CompactVec<T, A>[src]

impl<T: Compact, A: Allocator> Default for CompactVec<T, A>[src]

impl<T, A: Allocator> Deref for CompactVec<T, A>[src]

type Target = [T]

The resulting type after dereferencing.

impl<T, A: Allocator> DerefMut for CompactVec<T, A>[src]

impl<T, A: Allocator> Drop for CompactVec<T, A>[src]

fn drop(&mut self)[src]

Drop elements and deallocate free heap storage, if any is allocated

impl<T: Compact + Clone, A: Allocator> Extend<T> for CompactVec<T, A>[src]

impl<T: Compact + Clone, A: Allocator> From<Vec<T>> for CompactVec<T, A>[src]

fn from(vec: Vec<T>) -> Self[src]

Create a CompactVec from a normal Vec, directly using the backing storage as free heap storage

impl<T: Compact + Clone, A: Allocator> FromIterator<T> for CompactVec<T, A>[src]

impl<T: Hash> Hash for CompactVec<T>[src]

impl<T, A: Allocator> IntoIterator for CompactVec<T, A>[src]

type Item = T

The type of the elements being iterated over.

type IntoIter = IntoIter<T, A>

Which kind of iterator are we turning this into?

impl<'a, T, A: Allocator> IntoIterator for &'a CompactVec<T, A>[src]

type Item = &'a T

The type of the elements being iterated over.

type IntoIter = Iter<'a, T>

Which kind of iterator are we turning this into?

impl<'a, T, A: Allocator> IntoIterator for &'a mut CompactVec<T, A>[src]

type Item = &'a mut T

The type of the elements being iterated over.

type IntoIter = IterMut<'a, T>

Which kind of iterator are we turning this into?

Auto Trait Implementations

impl<T, A> RefUnwindSafe for CompactVec<T, A> where
    A: RefUnwindSafe,
    T: RefUnwindSafe

impl<T, A = DefaultHeap> !Send for CompactVec<T, A>

impl<T, A = DefaultHeap> !Sync for CompactVec<T, A>

impl<T, A> Unpin for CompactVec<T, A>

impl<T, A> UnwindSafe for CompactVec<T, A> where
    A: RefUnwindSafe,
    T: RefUnwindSafe

Blanket Implementations

impl<T> Any for T where
    T: 'static + ?Sized
[src]

impl<T> Borrow<T> for T where
    T: ?Sized
[src]

impl<T> BorrowMut<T> for T where
    T: ?Sized
[src]

impl<T> From<T> for T[src]

impl<T, U> Into<U> for T where
    U: From<T>, 
[src]

impl<I> IntoIterator for I where
    I: Iterator
[src]

type Item = <I as Iterator>::Item

The type of the elements being iterated over.

type IntoIter = I

Which kind of iterator are we turning this into?

impl<T> ToOwned for T where
    T: Clone
[src]

type Owned = T

The resulting type after obtaining ownership.

impl<T, U> TryFrom<U> for T where
    U: Into<T>, 
[src]

type Error = Infallible

The type returned in the event of a conversion error.

impl<T, U> TryInto<U> for T where
    U: TryFrom<T>, 
[src]

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

The type returned in the event of a conversion error.