DifferenceAll

Trait DifferenceAll 

Source
pub trait DifferenceAll<A, I>
where A: IntoIterator, I: PartialEq + Ord + Clone,
{ // Required method fn difference_all( &self, others: Vec<&[I]>, is_sorted: Option<bool>, ) -> Vec<I>; }
Expand description

A trait that implements the DifferenceAll::difference_all method on arrays.

Required Methods§

Source

fn difference_all(&self, others: Vec<&[I]>, is_sorted: Option<bool>) -> Vec<I>

Creates a vector of values in this array that are not included in the others nested arrays.

  • others - The nested values to exclude.
  • is_sorted - The sorted flag. Should be set to Some(true) if you are certain that other is a sorted array. Internally, binary search is utilized when this flag is provided and is truthy, enabling searching in O(log n) time, compared to the O(n) time complexity of linear search otherwise.
§Examples
use rodash::DifferenceAll;

assert_eq!(
    [2, 1, 2, 3].difference_all(vec![&[3, 4], &[3, 2]], None),
    [1]
);

Implementations on Foreign Types§

Source§

impl<A> DifferenceAll<Vec<A>, A> for Vec<A>
where A: PartialEq + Ord + Clone,

Source§

fn difference_all(&self, others: Vec<&[A]>, is_sorted: Option<bool>) -> Vec<A>

Source§

impl<A, const N: usize> DifferenceAll<[A; N], A> for [A; N]
where A: PartialEq + Ord + Clone,

Source§

fn difference_all(&self, others: Vec<&[A]>, is_sorted: Option<bool>) -> Vec<A>

Implementors§