Expand description
Operations for already sorted and deduplicated slices.
This library contains two modules containing types to produce set operations:
- The
duo
module is for types limited to be used with two slices not more not less. - The
multi
module types can be used to do set operations on multiple slices from zero up to an infinite number.
The duo
operations are much more performant than multi
so prefer using duo
when you know that you will need set operations for two slices.
Examples
Using a duo
union set operation on two slices.
use sdset::duo::OpBuilder;
use sdset::{SetOperation, Set, SetBuf};
let a = Set::new(&[1, 2, 4, 6, 7])?;
let b = Set::new(&[2, 3, 4, 5, 6, 7])?;
let op = OpBuilder::new(a, b).union();
let res: SetBuf<i32> = op.into_set_buf();
assert_eq!(&res[..], &[1, 2, 3, 4, 5, 6, 7]);
Using a multi
intersection set operation on three slices.
use sdset::multi::OpBuilder;
use sdset::{SetOperation, Set, SetBuf};
let a = Set::new(&[1, 2, 4])?;
let b = Set::new(&[2, 3, 4, 5, 7])?;
let c = Set::new(&[2, 4, 6, 7])?;
let op = OpBuilder::from_vec(vec![a, b, c]).intersection();
let res: SetBuf<i32> = op.into_set_buf();
assert_eq!(&res[..], &[2, 4]);
Re-exports
Modules
Contains the types to make set operations on two slices and only two.
Contains the types to make set operations on any given number of slices.
Traits
Represent a type that can produce a set operation on multiple
Set
s.Functions
Exponential searches this sorted slice for a given element.
Binary searches this sorted slice with a comparator function.
Binary searches this sorted slice with a key extraction function.