[−][src]Struct compact::CVec
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.
Methods
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]
ptr: *mut T,
len: usize,
cap: usize
) -> CompactVec<T, A>
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]
T: Copy,
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> Compact for CompactVec<T, A>
[src]
default fn is_still_compact(&self) -> bool
[src]
default fn dynamic_size_bytes(&self) -> usize
[src]
unsafe default fn compact(
source: *mut Self,
dest: *mut Self,
new_dynamic_part: *mut u8
)
[src]
source: *mut Self,
dest: *mut Self,
new_dynamic_part: *mut u8
)
unsafe default fn decompact(source: *const Self) -> Self
[src]
fn total_size_bytes(&self) -> usize
[src]
Total size of the object (static part + dynamic part)
unsafe fn behind(ptr: *mut Self) -> *mut u8
[src]
Get a pointer to behind the static part of self
(commonly used place for the dynamic part)
unsafe fn compact_behind(source: *mut Self, dest: *mut Self)
[src]
Like compact
with new_dynamic_part
set to dest.behind()
impl<T: Copy, A: Allocator> Compact for CompactVec<T, A>
[src]
fn is_still_compact(&self) -> bool
[src]
fn dynamic_size_bytes(&self) -> usize
[src]
unsafe fn compact(source: *mut Self, dest: *mut Self, new_dynamic_part: *mut u8)
[src]
fn total_size_bytes(&self) -> usize
[src]
Total size of the object (static part + dynamic part)
unsafe fn behind(ptr: *mut Self) -> *mut u8
[src]
Get a pointer to behind the static part of self
(commonly used place for the dynamic part)
unsafe fn compact_behind(source: *mut Self, dest: *mut Self)
[src]
Like compact
with new_dynamic_part
set to dest.behind()
unsafe fn decompact(source: *const Self) -> Self
[src]
Creates a clone of self with the dynamic part guaranteed to be stored freely. Read more
impl<T: Compact + Clone, A: Allocator> Extend<T> for CompactVec<T, A>
[src]
fn extend<I: IntoIterator<Item = T>>(&mut self, iter: I)
[src]
impl<T, A: Allocator> Drop for CompactVec<T, A>
[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?
fn into_iter(self) -> Self::IntoIter
[src]
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?
fn into_iter(self) -> Self::IntoIter
[src]
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?
fn into_iter(self) -> Self::IntoIter
[src]
impl<T: Compact, A: Allocator> Default for CompactVec<T, A>
[src]
fn default() -> CompactVec<T, A>
[src]
impl<T: Compact + Clone, A: Allocator> Clone for CompactVec<T, A>
[src]
default fn clone(&self) -> CompactVec<T, A>
[src]
fn clone_from(&mut self, source: &Self)
1.0.0[src]
Performs copy-assignment from source
. Read more
impl<T: Copy, A: Allocator> Clone for CompactVec<T, A>
[src]
fn clone(&self) -> CompactVec<T, A>
[src]
fn clone_from(&mut self, source: &Self)
1.0.0[src]
Performs copy-assignment from source
. Read more
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, A: Allocator> DerefMut for CompactVec<T, A>
[src]
impl<T: Hash> Hash for CompactVec<T>
[src]
fn hash<H: Hasher>(&self, state: &mut H)
[src]
fn hash_slice<H>(data: &[Self], state: &mut H) where
H: Hasher,
1.3.0[src]
H: Hasher,
Feeds a slice of this type into the given [Hasher
]. Read more
impl<T, A: Allocator> Deref for CompactVec<T, A>
[src]
impl<T: Compact + Debug, A: Allocator> Debug for CompactVec<T, A>
[src]
impl<T: Compact + Clone, A: Allocator> FromIterator<T> for CompactVec<T, A>
[src]
fn from_iter<I: IntoIterator<Item = T>>(iter: I) -> Self
[src]
Auto Trait Implementations
impl<T, A = DefaultHeap> !Sync for CompactVec<T, A>
impl<T, A = DefaultHeap> !Send for CompactVec<T, A>
impl<T, A> Unpin for CompactVec<T, A> where
A: Unpin,
T: Unpin,
A: Unpin,
T: Unpin,
impl<T, A> RefUnwindSafe for CompactVec<T, A> where
A: RefUnwindSafe,
T: RefUnwindSafe,
A: RefUnwindSafe,
T: RefUnwindSafe,
impl<T, A> UnwindSafe for CompactVec<T, A> where
A: RefUnwindSafe,
T: RefUnwindSafe,
A: RefUnwindSafe,
T: RefUnwindSafe,
Blanket Implementations
impl<T, U> Into<U> for T where
U: From<T>,
[src]
U: From<T>,
impl<T> ToOwned for T where
T: Clone,
[src]
T: Clone,
type Owned = T
The resulting type after obtaining ownership.
fn to_owned(&self) -> T
[src]
fn clone_into(&self, target: &mut T)
[src]
impl<I> IntoIterator for I where
I: Iterator,
[src]
I: Iterator,
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?
fn into_iter(self) -> I
[src]
impl<T> From<T> for T
[src]
impl<T, U> TryFrom<U> for T where
U: Into<T>,
[src]
U: Into<T>,
type Error = Infallible
The type returned in the event of a conversion error.
fn try_from(value: U) -> Result<T, <T as TryFrom<U>>::Error>
[src]
impl<T, U> TryInto<U> for T where
U: TryFrom<T>,
[src]
U: TryFrom<T>,
type Error = <U as TryFrom<T>>::Error
The type returned in the event of a conversion error.
fn try_into(self) -> Result<U, <U as TryFrom<T>>::Error>
[src]
impl<T> BorrowMut<T> for T where
T: ?Sized,
[src]
T: ?Sized,
fn borrow_mut(&mut self) -> &mut T
[src]
impl<T> Borrow<T> for T where
T: ?Sized,
[src]
T: ?Sized,
impl<T> Any for T where
T: 'static + ?Sized,
[src]
T: 'static + ?Sized,