[−][src]Crate sdset
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
pub use crate::set::Set; |
pub use crate::set::SetBuf; |
pub use crate::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 |
Structs
Counter | A |
Traits
Collection | This trait is meant to abstract any kind of collection
(i.e. |
SetOperation | Represent a type that can produce a set operation on multiple |
Functions
exponential_search | Exponential searches this sorted slice for a given element. |
exponential_search_by | Binary searches this sorted slice with a comparator function. |
exponential_search_by_key | Binary searches this sorted slice with a key extraction function. |