Struct IsizeVec

Source
pub struct IsizeVec<T> { /* private fields */ }
Expand description

Container for multiple elements sorted by a certain isize order.

Every element T is tagged with an associated isize. The isize value decides the relative ordering of the elements. All manipulations keep the items T ordered according to the isize values from lowest to highest.

use isize_vec::IsizeVec;

let mut vector = IsizeVec::new();

vector.insert(10, 'a');
vector.insert(5, 'b');

println!("{:?}", vector);

for value in vector {
    println!("{}", value);
}

Implementations§

Source§

impl<T> IsizeVec<T>

Source

pub fn new() -> Self

Create a new vector.

Source

pub fn iter(&self) -> Iter<'_, T>

Get an iterator to the values.

Source

pub fn iter_mut(&mut self) -> IterMut<'_, T>

Get an iterator to the values (mutable).

Source

pub fn push(&mut self, item: T) -> usize

Push a value to the end of the vector, with relative: isize::MAX.

Source

pub fn pop(&mut self) -> Option<(T, isize)>

Remove the last element from this vector.

Source

pub fn drain<R>(&mut self, range: R) -> Drain<'_, T>
where R: Clone + RangeBounds<usize>,

Create a drain iterator.

Source

pub fn len(&self) -> usize

Returns the length of the container

Source

pub fn is_empty(&self) -> bool

Returns whether the container is empty.

Source

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

Get the item at a given index.

Source

pub fn get_mut(&mut self, index: usize) -> Option<&mut T>

Get the item at a given index.

Source

pub fn extract(&mut self) -> Vec<T>

Return the backing vector and clear this container.

Source

pub fn first_positive(&self) -> usize

Find the index at which positive elements start.

Source

pub fn insert(&mut self, relative: isize, item: T) -> usize

Insert a value into this vector.

The value relative indicates where the value will be put in the list relative to other values. If two values have the same relative value, then the value will be prepended if it is signed, and appended if unsigned.

Returns the index of insertion.

Source

pub fn remove(&mut self, index: usize) -> (T, isize)

Remove the given index from the vector.

Source

pub fn first_right_of(&self, relative: isize) -> usize

Find the first index to the right of the relative list.

Source

pub fn swap(&mut self, a: usize, b: usize)

Swap two elements in the list. Associated order is swapped.

Source

pub fn retain<F>(&mut self, f: F)
where F: FnMut(&T) -> bool,

Same as Vec::retain.

Trait Implementations§

Source§

impl<T: Clone> Clone for IsizeVec<T>

Source§

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

Returns a copy 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: Debug> Debug for IsizeVec<T>

Source§

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

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

impl<T> Default for IsizeVec<T>

Source§

fn default() -> Self

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

impl<T, I> Index<I> for IsizeVec<T>
where I: SliceIndex<[T]>,

Source§

type Output = <I as SliceIndex<[T]>>::Output

The returned type after indexing.
Source§

fn index(&self, index: I) -> &<Vec<T> as Index<I>>::Output

Performs the indexing (container[index]) operation. Read more
Source§

impl<T, I> IndexMut<I> for IsizeVec<T>
where I: SliceIndex<[T]>,

Source§

fn index_mut(&mut self, index: I) -> &mut <Vec<T> as Index<I>>::Output

Performs the mutable indexing (container[index]) operation. Read more
Source§

impl<'a, T> IntoIterator for &'a IsizeVec<T>

Source§

type Item = &'a T

The type of the elements being iterated over.
Source§

type IntoIter = Iter<'a, T>

Which kind of iterator are we turning this into?
Source§

fn into_iter(self) -> Iter<'a, T>

Creates an iterator from a value. Read more
Source§

impl<'a, T> IntoIterator for &'a mut IsizeVec<T>

Source§

type Item = &'a mut T

The type of the elements being iterated over.
Source§

type IntoIter = IterMut<'a, T>

Which kind of iterator are we turning this into?
Source§

fn into_iter(self) -> IterMut<'a, T>

Creates an iterator from a value. Read more
Source§

impl<T> IntoIterator for IsizeVec<T>

Source§

type Item = T

The type of the elements being iterated over.
Source§

type IntoIter = IntoIter<T>

Which kind of iterator are we turning this into?
Source§

fn into_iter(self) -> IntoIter<T>

Creates an iterator from a value. Read more

Auto Trait Implementations§

§

impl<T> Freeze for IsizeVec<T>

§

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

§

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

§

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

§

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

§

impl<T> UnwindSafe for IsizeVec<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> 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.