pub struct ScoringMatrix<T> { /* private fields */ }Implementations§
Source§impl<T> ScoringMatrix<T>
impl<T> ScoringMatrix<T>
Sourcepub fn new() -> Self
pub fn new() -> Self
Creates a new empty matrix with default values.
let matrix: ScoringMatrix<i32> = ScoringMatrix::new();
assert_eq!(matrix.get(0, 0), 0); // Using T::default()Sourcepub fn with_defaults(same: T, missing: T) -> Self
pub fn with_defaults(same: T, missing: T) -> Self
Creates a new matrix with specified default values.
let matrix = ScoringMatrix::with_defaults(0.0, -1.0);
assert_eq!(matrix.get(0, 0), 0.0); // same value
assert_eq!(matrix.get(0, 1), -1.0); // missing valueSourcepub fn with_size_and_defaults(size: usize, same: T, missing: T) -> Self
pub fn with_size_and_defaults(size: usize, same: T, missing: T) -> Self
Creates a new matrix with specified size and default values.
let matrix = ScoringMatrix::with_size_and_defaults(3, 1.0, 0.0);
assert_eq!(matrix.size(), 3);
assert_eq!(matrix.get(0, 0), 1.0); // same value
assert_eq!(matrix.get(0, 1), 0.0); // missing valuepub fn with_size(size: usize) -> Self
pub fn size(&self) -> usize
Sourcepub fn set(&mut self, row: usize, col: usize, value: T)
pub fn set(&mut self, row: usize, col: usize, value: T)
Returns the value of the given cell.
let mut m = ScoringMatrix::with_size_and_defaults(5, 0, 1);
m.set(1, 2, 42);
assert_eq!(m.get(1, 2), 42);
assert_eq!(m.get(2, 1), 42);
assert_eq!(m.get(3, 3), 0);
assert_eq!(m.get(1, 3), 1);pub fn get(&self, row: usize, col: usize) -> T
Trait Implementations§
Auto Trait Implementations§
impl<T> Freeze for ScoringMatrix<T>where
T: Freeze,
impl<T> RefUnwindSafe for ScoringMatrix<T>where
T: RefUnwindSafe,
impl<T> Send for ScoringMatrix<T>where
T: Send,
impl<T> Sync for ScoringMatrix<T>where
T: Sync,
impl<T> Unpin for ScoringMatrix<T>where
T: Unpin,
impl<T> UnwindSafe for ScoringMatrix<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