pub struct Set<T> {
pub stype: SType,
pub ascending: bool,
pub data: Vec<T>,
pub index: Vec<usize>,
}
Expand description
The struct type for sets
Fields§
§stype: SType
type of the set
ascending: bool
order: ascending (true), descending (false)
data: Vec<T>
data Vec
index: Vec<usize>
index Vec
Implementations§
Source§impl<T> Set<T>
Associated functions for conversions and self operations returning Set = Self
impl<T> Set<T>
Associated functions for conversions and self operations returning Set
Sourcepub fn new(set_type: SType, d: &[T], asc: bool) -> Self
pub fn new(set_type: SType, d: &[T], asc: bool) -> Self
all in one Initialiser creates a new Set of self_type, from slice d, in asc order
Sourcepub fn new_unordered(d: &[T]) -> Self
pub fn new_unordered(d: &[T]) -> Self
Initialiser - creates a new SType::Unordered Set from data
Sourcepub fn new_ordered(d: &[T], asc: bool) -> Self
pub fn new_ordered(d: &[T], asc: bool) -> Self
Initialiser - creates a new SType::Ordered Set in asc order from data
Sourcepub fn new_indexed(d: &[T], asc: bool) -> Self
pub fn new_indexed(d: &[T], asc: bool) -> Self
Initialiser - creates a new SType::Indexed Set in asc order from data
Sourcepub fn new_ranked(d: &[T], asc: bool) -> Self
pub fn new_ranked(d: &[T], asc: bool) -> Self
Initialiser - creates a new SType::Ranked Set in asc order from data
Sourcepub fn to_unordered(&self) -> Self
pub fn to_unordered(&self) -> Self
Converter - to SType::Unordered Set Caution: this just throws away the valuable index!
Sourcepub fn to_ordered(&self, asc: bool) -> Self
pub fn to_ordered(&self, asc: bool) -> Self
Converts any Set type to ordered
Sourcepub fn to_indexed(&self, asc: bool) -> Self
pub fn to_indexed(&self, asc: bool) -> Self
Converts any Set type to indexed
Sourcepub fn to_same(&self, s: &Self) -> Self
pub fn to_same(&self, s: &Self) -> Self
General converter: s -> Set of the same type and order as self self only serves as a template for the type and order and is not involved in the conversion
Sourcepub fn reverse(&self) -> Self
pub fn reverse(&self) -> Self
Reverses a vec by iterating over only half of its length and swapping the items
Sourcepub fn intersection(&self, s: &Self) -> Self
pub fn intersection(&self, s: &Self) -> Self
Intersection of two selfs
Sourcepub fn difference(&self, s: &Self) -> Self
pub fn difference(&self, s: &Self) -> Self
Complement of s in self (i.e. self -= s)
Sourcepub fn infsup(&self) -> MinMax<T>where
T: Default,
pub fn infsup(&self) -> MinMax<T>where
T: Default,
Finds minimum, minimum’s first index, maximum, maximum’s first index
Trait Implementations§
Source§impl<T> MutSetOps<T> for Set<T>
impl<T> MutSetOps<T> for Set<T>
Source§fn munordered(&mut self)
fn munordered(&mut self)
Makes a Set unordered Caution: this just throws away the valuable index!
Source§fn msame(&mut self, s: &mut Self, quantify: impl Copy + Fn(&T) -> f64)
fn msame(&mut self, s: &mut Self, quantify: impl Copy + Fn(&T) -> f64)
General converter: s -> Set of the same type and order as self self only serves as a template for the type and order and is not involved in the conversion
Source§fn mdelete(&mut self, item: T) -> boolwhere
Self: Sized,
fn mdelete(&mut self, item: T) -> boolwhere
Self: Sized,
Deletes an item from self Returns false if item not found
Source§fn mdeleteall(&mut self, item: T) -> usizewhere
Self: Sized,
fn mdeleteall(&mut self, item: T) -> usizewhere
Self: Sized,
Deletes all occurrences of a matching item from self Returns number found and deleted
Source§fn mreverse(&mut self)
fn mreverse(&mut self)
Reverses a vec by iterating over only half of its length and swapping the items
Source§fn mnonrepeat(&mut self)
fn mnonrepeat(&mut self)
Deletes all repetitions
Source§fn mintersection(&mut self, s: &Self)
fn mintersection(&mut self, s: &Self)
Intersection of two unordered sets, assigned to self
Source§fn mdifference(&mut self, s: &Self)
fn mdifference(&mut self, s: &Self)
Complement of s in self (i.e. self -= s)