pub struct DefaultSparseVec<T: Default + PartialEq + Clone> { /* private fields */ }Expand description
Implementations§
Source§impl<T: Default + PartialEq + Clone> DefaultSparseVec<T>
impl<T: Default + PartialEq + Clone> DefaultSparseVec<T>
pub fn with_capacity(cap: usize) -> Self
pub fn is_empty(&self) -> bool
Sourcepub fn reserve(&mut self, additional: usize)
pub fn reserve(&mut self, additional: usize)
reserveメソッドの実装 スパースベクトルの容量を増やす 既に確保されている容量よりも小さい場合は何もしない 既に確保されている容量よりも大きい場合は、新しい容量に再確保する
Sourcepub fn shrink_to_fit(&mut self)
pub fn shrink_to_fit(&mut self)
shrink_to_fitメソッドの実装 スパースベクトルの容量を現在の長さに合わせる 既に確保されている容量と現在の長さが同じ場合は何もしない
pub fn get_mut(&mut self, index: usize) -> Option<&mut T>
👎Deprecated: このメソッドは避けるべきです.
スパース分部の実値を渡すため、スパース分部の値を無駄に生成します.
default値以外を代入する場合は問題ありません.
Sourcepub fn insert(&mut self, index: usize, elem: T)
pub fn insert(&mut self, index: usize, elem: T)
insertメソッド 「index 番目に新しい要素を割り込む」という動作
- 後続要素のインデックスは常に +1 シフト
elemが非デフォルト値なら物理領域に書き込む (raw_len += 1)elemがデフォルト値なら物理領域には書き込まない(スパース化)
Sourcepub fn remove(&mut self, index: usize) -> T
pub fn remove(&mut self, index: usize) -> T
removeメソッド
index 番目の要素を削除し、削除した要素を返します。
- 論理インデックス
indexが物理的に存在すれば、その値を返す - 物理的になければ(= デフォルト扱いだった)デフォルト値を返す
いずれにせよ後ろの要素(論理インデックスが index より大きい要素)は
インデックスを 1 つ前にシフトします。
Sourcepub fn append(&mut self, other: Self)
pub fn append(&mut self, other: Self)
2つのスパースベクタを “連結” する append 実装例
otherは消費 (ムーブ) して、自分に要素をつけ足すotherのインデックスは自分のlen分だけシフト
Sourcepub fn extend<I>(&mut self, iter: I)where
I: IntoIterator<Item = T>,
pub fn extend<I>(&mut self, iter: I)where
I: IntoIterator<Item = T>,
extendメソッドの実装
Sourcepub fn iter(&self) -> impl Iterator<Item = (&usize, &T)>
pub fn iter(&self) -> impl Iterator<Item = (&usize, &T)>
iterメソッドの実装(仮) スパース分部を含みません スパース分部が必要な場合はNormalVecMethods trait実装
Sourcepub fn iter_mut(&mut self) -> impl Iterator<Item = (&mut usize, &mut T)>
pub fn iter_mut(&mut self) -> impl Iterator<Item = (&mut usize, &mut T)>
iter_mutメソッドの実装(仮) スパース分部を含みません スパース分部が必要な場合はNormalVecMethods trait実装
pub fn as_slice_val(&self) -> &[T]
pub fn as_slice_ind(&self) -> &[usize]
pub fn as_mut_slice_val(&mut self) -> &mut [T]
pub fn as_mut_slice_ind(&mut self) -> &mut [usize]
Trait Implementations§
Source§impl<T> Math<T> for DefaultSparseVec<T>
impl<T> Math<T> for DefaultSparseVec<T>
fn u64_dot(&self, other: &Self) -> u64
fn u128_dot(&self, other: &Self) -> u128
fn u32_dot(&self, other: &Self) -> u32
fn u16_dot(&self, other: &Self) -> u16
fn u8_dot(&self, other: &Self) -> u8
fn i128_dot(&self, other: &Self) -> i128
fn i64_dot(&self, other: &Self) -> i64
fn i32_dot(&self, other: &Self) -> i32
fn i16_dot(&self, other: &Self) -> i16
fn i8_dot(&self, other: &Self) -> i8
fn f64_dot(&self, other: &Self) -> f64
fn f32_dot(&self, other: &Self) -> f32
Source§impl<T: Default + PartialEq + Clone> NormalVecMethods<T> for DefaultSparseVec<T>
impl<T: Default + PartialEq + Clone> NormalVecMethods<T> for DefaultSparseVec<T>
impl<T: Send + Default + PartialEq + Clone> Send for DefaultSparseVec<T>
impl<T: Send + Default + PartialEq + Clone> Sync for DefaultSparseVec<T>
Auto Trait Implementations§
impl<T> Freeze for DefaultSparseVec<T>where
T: Freeze,
impl<T> RefUnwindSafe for DefaultSparseVec<T>where
T: RefUnwindSafe,
impl<T> Unpin for DefaultSparseVec<T>where
T: Unpin,
impl<T> UnwindSafe for DefaultSparseVec<T>where
T: UnwindSafe + RefUnwindSafe,
Blanket Implementations§
§impl<T> BorrowMut<T> for Twhere
T: ?Sized,
impl<T> BorrowMut<T> for Twhere
T: ?Sized,
§fn borrow_mut(&mut self) -> &mut T
fn borrow_mut(&mut self) -> &mut T
Mutably borrows from an owned value. Read more
§impl<T> CloneToUninit for Twhere
T: Clone,
impl<T> CloneToUninit for Twhere
T: Clone,
§unsafe fn clone_to_uninit(&self, dest: *mut u8)
unsafe fn clone_to_uninit(&self, dest: *mut u8)
🔬This is a nightly-only experimental API. (
clone_to_uninit)