Trait arr_rs::alphanumeric::operations::compare::ArrayStringCompare
source · pub trait ArrayStringCompare<N: Alphanumeric>where
Self: Sized + Clone,{
// Required methods
fn equal(&self, other: &Array<N>) -> Result<Array<bool>, ArrayError>;
fn not_equal(&self, other: &Array<N>) -> Result<Array<bool>, ArrayError>;
fn greater_equal(&self, other: &Array<N>) -> Result<Array<bool>, ArrayError>;
fn less_equal(&self, other: &Array<N>) -> Result<Array<bool>, ArrayError>;
fn greater(&self, other: &Array<N>) -> Result<Array<bool>, ArrayError>;
fn less(&self, other: &Array<N>) -> Result<Array<bool>, ArrayError>;
fn compare(
&self,
other: &Array<N>,
cmp_op: &str
) -> Result<Array<bool>, ArrayError>;
}Expand description
ArrayTrait - Alphanumeric Array operations
Required Methods§
sourcefn equal(&self, other: &Array<N>) -> Result<Array<bool>, ArrayError>
fn equal(&self, other: &Array<N>) -> Result<Array<bool>, ArrayError>
Return (self == other) element-wise
Arguments
other- array to perform the operation with
Examples
use arr_rs::prelude::*;
let expected = Array::flat(vec![true, false]);
let arr = Array::flat(vec!["aaa".to_string(), "bbbxx".to_string()]);
let other = Array::flat(vec!["aaa".to_string(), "bbbbb".to_string()]).unwrap();
assert_eq!(expected, arr.equal(&other));sourcefn not_equal(&self, other: &Array<N>) -> Result<Array<bool>, ArrayError>
fn not_equal(&self, other: &Array<N>) -> Result<Array<bool>, ArrayError>
Return (self != other) element-wise
Arguments
other- array to perform the operation with
Examples
use arr_rs::prelude::*;
let expected = Array::flat(vec![false, true]);
let arr = Array::flat(vec!["aaa".to_string(), "bbbxx".to_string()]);
let other = Array::flat(vec!["aaa".to_string(), "bbbbb".to_string()]).unwrap();
assert_eq!(expected, arr.not_equal(&other));sourcefn greater_equal(&self, other: &Array<N>) -> Result<Array<bool>, ArrayError>
fn greater_equal(&self, other: &Array<N>) -> Result<Array<bool>, ArrayError>
Return (self >= other) element-wise
Arguments
other- array to perform the operation with
Examples
use arr_rs::prelude::*;
let expected = Array::flat(vec![true, false, true]);
let arr = Array::flat(vec!["aaa".to_string(), "aaa".to_string(), "bbbxx".to_string()]);
let other = Array::flat(vec!["aaa".to_string(), "aba".to_string(), "bbbbb".to_string()]).unwrap();
assert_eq!(expected, arr.greater_equal(&other));sourcefn less_equal(&self, other: &Array<N>) -> Result<Array<bool>, ArrayError>
fn less_equal(&self, other: &Array<N>) -> Result<Array<bool>, ArrayError>
Return (self <= other) element-wise
Arguments
other- array to perform the operation with
Examples
use arr_rs::prelude::*;
let expected = Array::flat(vec![true, true, false]);
let arr = Array::flat(vec!["aaa".to_string(), "aaa".to_string(), "bbbxx".to_string()]);
let other = Array::flat(vec!["aaa".to_string(), "aba".to_string(), "bbbbb".to_string()]).unwrap();
assert_eq!(expected, arr.less_equal(&other));sourcefn greater(&self, other: &Array<N>) -> Result<Array<bool>, ArrayError>
fn greater(&self, other: &Array<N>) -> Result<Array<bool>, ArrayError>
Return (self > other) element-wise
Arguments
other- array to perform the operation with
Examples
use arr_rs::prelude::*;
let expected = Array::flat(vec![false, false, true]);
let arr = Array::flat(vec!["aaa".to_string(), "aaa".to_string(), "bbbxx".to_string()]);
let other = Array::flat(vec!["aaa".to_string(), "aba".to_string(), "bbbbb".to_string()]).unwrap();
assert_eq!(expected, arr.greater(&other));sourcefn less(&self, other: &Array<N>) -> Result<Array<bool>, ArrayError>
fn less(&self, other: &Array<N>) -> Result<Array<bool>, ArrayError>
Return (self < other) element-wise
Arguments
other- array to perform the operation with
Examples
use arr_rs::prelude::*;
let expected = Array::flat(vec![false, true, false]);
let arr = Array::flat(vec!["aaa".to_string(), "aaa".to_string(), "bbbxx".to_string()]);
let other = Array::flat(vec!["aaa".to_string(), "aba".to_string(), "bbbbb".to_string()]).unwrap();
assert_eq!(expected, arr.less(&other));sourcefn compare(
&self,
other: &Array<N>,
cmp_op: &str
) -> Result<Array<bool>, ArrayError>
fn compare( &self, other: &Array<N>, cmp_op: &str ) -> Result<Array<bool>, ArrayError>
Performs element-wise comparison of two string arrays using the comparison operator specified by cmp_op
Arguments
other- array to perform the operation withcmp_op- Type of comparison: {“<”, “<=”, “==”, “>=”, “>”, “!=”}
Examples
use arr_rs::prelude::*;
let arr = Array::flat(vec!["aaa".to_string(), "bbbxx".to_string()]);
let other = Array::flat(vec!["aaa".to_string(), "bbbbb".to_string()]).unwrap();
let expected = Array::flat(vec![true, false]);
assert_eq!(expected, arr.compare(&other, "=="));
let expected = Array::flat(vec![false, true]);
assert_eq!(expected, arr.compare(&other, "!="));
let expected = Array::flat(vec![true, true]);
assert_eq!(expected, arr.compare(&other, ">="));
let expected = Array::flat(vec![true, false]);
assert_eq!(expected, arr.compare(&other, "<="));
let expected = Array::flat(vec![false, true]);
assert_eq!(expected, arr.compare(&other, ">"));
let expected = Array::flat(vec![false, false]);
assert_eq!(expected, arr.compare(&other, "<"));