pub struct Group<T: Eq + Hash>(/* private fields */);Expand description
A sparse collection of weighted elements where zero-valued entries are excluded. Used for efficiently representing portfolios, groups, and other weighted collections.
Implementations§
Source§impl<T: Eq + Hash> Group<T>
impl<T: Eq + Hash> Group<T>
Sourcepub fn into_iter(self) -> impl Iterator<Item = (T, f64)>
pub fn into_iter(self) -> impl Iterator<Item = (T, f64)>
A consuming iterator for the key-value pairs Returns only non-zero weighted pairs.
Sourcepub fn iter(&self) -> impl Iterator<Item = (&T, &f64)>
pub fn iter(&self) -> impl Iterator<Item = (&T, &f64)>
A by-reference iterator for the key-value pairs Returns only non-zero weighted pairs.
Sourcepub fn retain<F: Fn(&T, &f64) -> bool>(&mut self, f: F)
pub fn retain<F: Fn(&T, &f64) -> bool>(&mut self, f: F)
Remove keys based on some criteria This allows filtering the sparse vector with a custom function.
Sourcepub fn len(&self) -> usize
pub fn len(&self) -> usize
The number of key-value pairs. (After a call to .simplify(), equivalent to an L0 norm)
Trait Implementations§
Auto Trait Implementations§
impl<T> Freeze for Group<T>
impl<T> RefUnwindSafe for Group<T>where
T: RefUnwindSafe,
impl<T> Send for Group<T>where
T: Send,
impl<T> Sync for Group<T>where
T: Sync,
impl<T> Unpin for Group<T>where
T: Unpin,
impl<T> UnwindSafe for Group<T>where
T: UnwindSafe,
Blanket Implementations§
Source§impl<T> BorrowMut<T> for Twhere
T: ?Sized,
impl<T> BorrowMut<T> for Twhere
T: ?Sized,
Source§fn borrow_mut(&mut self) -> &mut T
fn borrow_mut(&mut self) -> &mut T
Mutably borrows from an owned value. Read more
Source§impl<T> IntoEither for T
impl<T> IntoEither for T
Source§fn into_either(self, into_left: bool) -> Either<Self, Self>
fn into_either(self, into_left: bool) -> Either<Self, Self>
Converts
self into a Left variant of Either<Self, Self>
if into_left is true.
Converts self into a Right variant of Either<Self, Self>
otherwise. Read moreSource§fn into_either_with<F>(self, into_left: F) -> Either<Self, Self>
fn into_either_with<F>(self, into_left: F) -> Either<Self, Self>
Converts
self into a Left variant of Either<Self, Self>
if into_left(&self) returns true.
Converts self into a Right variant of Either<Self, Self>
otherwise. Read more