[−][src]Struct nested::Nested
A two dimensional collection with minimal allocation
T
is the owning underlying container.
For instance, it behaves similarly to Vec<Vec<T>>
or Vec<String>
but
only has 2 internal buffers.
It can be used:
- on your own collection as long as it implements the
Collection
trait. - like a sparse vector
- when you need to collect (move ownership) many
String
s orVec<T>
s
Methods
impl<T: Collection> Nested<T>
[src]
pub fn new() -> Self
[src]
Create a new Nested
.
pub fn with_capacity(len: usize, size: usize) -> Self
[src]
Creates a new Nested
with given capacity.
len: the expected item count size: the expected total size taken by all items
pub fn push<I: AsRef<Item<T>>>(&mut self, el: I)
[src]
Pushes a new item
pub fn pop(&mut self) -> Option<T>
[src]
Removes the last element from a Nested
and returns it, or None if it is empty.
pub fn extend_empty(&mut self, count: usize)
[src]
Extend with count
empty elements
pub fn len(&self) -> usize
[src]
Returns the number of elements in the Nested
.
pub fn data_len(&self) -> usize
[src]
Get the total length taken by the data
pub fn is_empty(&self) -> bool
[src]
Returns true if self has a length of zero.
pub fn truncate(&mut self, len: usize)
[src]
Shortens the Nested
, keeping the first len elements and dropping the rest.
If len is greater than the vector's current length, this has no effect.
Note that this method has no effect on the allocated capacity of the vector.
pub fn clear(&mut self)
[src]
Truncates this Nested
, removing all contents.
While this means the Nested
will have a length of zero, it does not touch its capacity.
pub fn get(&self, index: usize) -> Option<&Item<T>>
[src]
Returns a shared reference to the output at this location, if in bounds.
pub fn into_parts(self) -> (Vec<usize>, T)
[src]
Converts this Nested
into its constituent parts.
pub fn indices(&self) -> &[usize]
[src]
Returns a reference to the underlying indices.
Each index represents the start of each logical vector beyond the first one.
pub fn data(&self) -> &T
[src]
Returns a reference to the underlying data.
The data is stored contiguously.
pub fn iter(&self) -> Iter<T>
[src]
Returns an iterator over Nested
elements.
pub fn split_off(&mut self, at: usize) -> Nested<T>
[src]
Splits the collection into two at the given index.
Returns a newly allocated Self. self contains elements [0, at), and the returned Self contains elements [at, len).
Note that the capacity of self does not change.
Trait Implementations
impl<T: Clone> Clone for Nested<T>
[src]
impl<T: Debug> Debug for Nested<T>
[src]
impl<T: Eq> Eq for Nested<T>
[src]
impl<T: Collection, A: AsRef<Item<T>>> Extend<A> for Nested<T>
[src]
impl<T: Collection, A: AsRef<Item<T>>> FromIterator<A> for Nested<T>
[src]
fn from_iter<I: IntoIterator<Item = A>>(iter: I) -> Self
[src]
impl<T: Hash> Hash for Nested<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,
impl<T: Collection> Index<usize> for Nested<T>
[src]
type Output = Item<T>
The returned type after indexing.
fn index(&self, index: usize) -> &Self::Output
[src]
impl<T: PartialEq> PartialEq<Nested<T>> for Nested<T>
[src]
impl<T> StructuralEq for Nested<T>
[src]
impl<T> StructuralPartialEq for Nested<T>
[src]
Auto Trait Implementations
impl<T> RefUnwindSafe for Nested<T> where
T: RefUnwindSafe,
T: RefUnwindSafe,
impl<T> Send for Nested<T> where
T: Send,
T: Send,
impl<T> Sync for Nested<T> where
T: Sync,
T: Sync,
impl<T> Unpin for Nested<T> where
T: Unpin,
T: Unpin,
impl<T> UnwindSafe for Nested<T> where
T: UnwindSafe,
T: UnwindSafe,
Blanket Implementations
impl<T> Any for T where
T: 'static + ?Sized,
[src]
T: 'static + ?Sized,
impl<T> Borrow<T> for T where
T: ?Sized,
[src]
T: ?Sized,
impl<T> BorrowMut<T> for T where
T: ?Sized,
[src]
T: ?Sized,
fn borrow_mut(&mut self) -> &mut T
[src]
impl<T> From<T> for T
[src]
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<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>,