Trait array_tool::vec::Uniq [] [src]

pub trait Uniq<T> {
    fn uniq(&self, other: Self) -> Self;
fn unique(&self) -> Self;
fn is_unique(&self) -> bool;
fn uniq_via<F: Fn(&T, &T) -> bool>(&self, other: Self, f: F) -> Self;
fn unique_via<F: Fn(&T, &T) -> bool>(&self, f: F) -> Self;
fn is_unique_via<F: Fn(&T, &T) -> bool>(&self, f: F) -> bool; }

Several different methods for getting, or evaluating, uniqueness.

Required Methods

uniq returns a vector of unique values within itself as compared to the other vector which is provided as an input parameter.

Example

use array_tool::vec::Uniq;

vec![1,2,3,4,5,6].uniq( vec![1,2,5,7,9] );

Output

vec![3,4,6]

unique removes duplicates from within the vector and returns Self.

Example

use array_tool::vec::Uniq;

vec![1,2,1,3,2,3,4,5,6].unique();

Output

vec![1,2,3,4,5,6]

is_unique returns boolean value on whether all values within Self are unique.

Example

use array_tool::vec::Uniq;

vec![1,2,1,3,4,3,4,5,6].is_unique();

Output

false

uniq_via returns a vector of unique values within itself as compared to the other vector which is provided as an input parameter, as defined by a provided custom comparator.

Example

use array_tool::vec::Uniq;

vec![1,2,3,4,5,6].uniq_via( vec![1,2,5,7,9], |&l, r| l == r + 2 );

Output

vec![1,2,4,6]

unique_via removes duplicates, as defined by a provided custom comparator, from within the vector and returns Self.

Example

use array_tool::vec::Uniq;

vec![1.0,2.0,1.4,3.3,2.1,3.5,4.6,5.2,6.2].unique_via( |l: &f64, r: &f64| l.floor() == r.floor() );

Output

vec![1.0,2.0,3.3,4.6,5.2,6.2]

is_unique_via returns boolean value on whether all values within Self are unique, as defined by a provided custom comparator.

Example

use array_tool::vec::Uniq;

vec![1.0,2.0,1.4,3.3,2.1,3.5,4.6,5.2,6.2].is_unique_via( |l: &f64, r: &f64| l.floor() == r.floor() );

Output

false

Implementations on Foreign Types

impl<T: Clone + PartialEq> Uniq<T> for Vec<T>
[src]

[src]

[src]

[src]

[src]

[src]

[src]

Implementors