Crate sdset[−][src]
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 operations are much more performant thanmulti
. - The
multi
module types can be used to do set operations on multiple slices from zero up to an infinite number.
So prefer using the 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
pub use set::Set; |
pub use set::SetBuf; |
pub use set::Error; |
Modules
duo |
Contains the types to make set operations on two slices and only two. |
multi |
Contains the types to make set operations on any given number of slices. |
set |
All the methods and types associated to |
Traits
SetOperation |
Represent a type that can produce a set operation on multiple |