Struct Set

Source
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>
where T: Copy + PartialOrd + Default,

Associated functions for conversions and self operations returning Set = Self

Source

pub const EMPTYSET: Set<T>

Associated constant EMPTYSET, unique for each concrete end-type T

Source

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

Source

pub fn new_empty() -> Self

Creates a new empty Set

Source

pub fn new_unordered(d: &[T]) -> Self

Initialiser - creates a new SType::Unordered Set from data

Source

pub fn new_ordered(d: &[T], asc: bool) -> Self

Initialiser - creates a new SType::Ordered Set in asc order from data

Source

pub fn new_indexed(d: &[T], asc: bool) -> Self

Initialiser - creates a new SType::Indexed Set in asc order from data

Source

pub fn new_ranked(d: &[T], asc: bool) -> Self

Initialiser - creates a new SType::Ranked Set in asc order from data

Source

pub fn to_unordered(&self) -> Self

Converter - to SType::Unordered Set Caution: this just throws away the valuable index!

Source

pub fn to_ordered(&self, asc: bool) -> Self

Converts any Set type to ordered

Source

pub fn to_indexed(&self, asc: bool) -> Self

Converts any Set type to indexed

Source

pub fn to_ranked(&self, asc: bool) -> Self

Converts any Set type to ranked

Source

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

Source

pub fn insert(&self, item: T) -> Self

Inserts an item of the same end-type to self

Source

pub fn delete(&self, item: T) -> Self

Deletes an item of the same end-type from self

Source

pub fn reverse(&self) -> Self

Reverses a vec by iterating over only half of its length and swapping the items

Source

pub fn nonrepeat(&self) -> Self

Deletes any repetitions

Source

pub fn union(&self, s: &Self) -> Self

Union of two selfs

Source

pub fn intersection(&self, s: &Self) -> Self

Intersection of two selfs

Source

pub fn difference(&self, s: &Self) -> Self

Complement of s in self (i.e. self -= s)

Source

pub fn infsup(&self) -> MinMax<T>
where T: Default,

Finds minimum, minimum’s first index, maximum, maximum’s first index

Source

pub fn search(&self, m: T) -> Option<usize>

Search a Set self for m. Returns the subscript of the first m or None

Source

pub fn member(&self, m: T) -> bool

True if m is a member of the self Throws away the subscript found by search

Trait Implementations§

Source§

impl<T: Clone> Clone for Set<T>

Source§

fn clone(&self) -> Set<T>

Returns a copy of the value. Read more
1.0.0 · Source§

fn clone_from(&mut self, source: &Self)

Performs copy-assignment from source. Read more
Source§

impl<T: Default> Default for Set<T>

Source§

fn default() -> Set<T>

Returns the “default value” for a type. Read more
Source§

impl<T> Display for Set<T>
where T: Copy + Display,

Implementation of Display trait for struct Set.

Source§

fn fmt(&self, f: &mut Formatter<'_>) -> Result

Formats the value using the given formatter. Read more
Source§

impl<T> MutSetOps<T> for Set<T>
where T: Copy + PartialOrd + Default,

Source§

fn munordered(&mut self)

Makes a Set unordered Caution: this just throws away the valuable index!

Source§

fn mordered(&mut self, quantify: impl Copy + Fn(&T) -> f64, asc: bool)

Makes a Set ordered

Source§

fn mindexed(&mut self, quantify: impl Copy + Fn(&T) -> f64, asc: bool)

Makes any Set indexed

Source§

fn mranked(&mut self, asc: bool)

Converts any Set type to ranked

Source§

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) -> bool
where Self: Sized,

Deletes an item from self Returns false if item not found

Source§

fn mdeleteall(&mut self, item: T) -> usize
where Self: Sized,

Deletes all occurrences of a matching item from self Returns number found and deleted

Source§

fn minsert(&mut self, item: T)

Inserts an item v of the same end-type to self

Source§

fn mreverse(&mut self)

Reverses a vec by iterating over only half of its length and swapping the items

Source§

fn mnonrepeat(&mut self)

Deletes all repetitions

Source§

fn munion(&mut self, s: &Self)

sets union

Source§

fn mintersection(&mut self, s: &Self)

Intersection of two unordered sets, assigned to self

Source§

fn mdifference(&mut self, s: &Self)

Complement of s in self (i.e. self -= s)

Auto Trait Implementations§

§

impl<T> Freeze for Set<T>

§

impl<T> RefUnwindSafe for Set<T>
where T: RefUnwindSafe,

§

impl<T> Send for Set<T>
where T: Send,

§

impl<T> Sync for Set<T>
where T: Sync,

§

impl<T> Unpin for Set<T>
where T: Unpin,

§

impl<T> UnwindSafe for Set<T>
where T: UnwindSafe,

Blanket Implementations§

Source§

impl<T> Any for T
where T: 'static + ?Sized,

Source§

fn type_id(&self) -> TypeId

Gets the TypeId of self. Read more
Source§

impl<T> Borrow<T> for T
where T: ?Sized,

Source§

fn borrow(&self) -> &T

Immutably borrows from an owned value. Read more
Source§

impl<T> BorrowMut<T> for T
where T: ?Sized,

Source§

fn borrow_mut(&mut self) -> &mut T

Mutably borrows from an owned value. Read more
Source§

impl<T> CloneToUninit for T
where T: Clone,

Source§

unsafe fn clone_to_uninit(&self, dest: *mut u8)

🔬This is a nightly-only experimental API. (clone_to_uninit)
Performs copy-assignment from self to dest. Read more
Source§

impl<T> From<T> for T

Source§

fn from(t: T) -> T

Returns the argument unchanged.

Source§

impl<T, U> Into<U> for T
where U: From<T>,

Source§

fn into(self) -> U

Calls U::from(self).

That is, this conversion is whatever the implementation of From<T> for U chooses to do.

Source§

impl<T> ToOwned for T
where T: Clone,

Source§

type Owned = T

The resulting type after obtaining ownership.
Source§

fn to_owned(&self) -> T

Creates owned data from borrowed data, usually by cloning. Read more
Source§

fn clone_into(&self, target: &mut T)

Uses borrowed data to replace owned data, usually by cloning. Read more
Source§

impl<T> ToString for T
where T: Display + ?Sized,

Source§

fn to_string(&self) -> String

Converts the given value to a String. Read more
Source§

impl<T, U> TryFrom<U> for T
where U: Into<T>,

Source§

type Error = Infallible

The type returned in the event of a conversion error.
Source§

fn try_from(value: U) -> Result<T, <T as TryFrom<U>>::Error>

Performs the conversion.
Source§

impl<T, U> TryInto<U> for T
where U: TryFrom<T>,

Source§

type Error = <U as TryFrom<T>>::Error

The type returned in the event of a conversion error.
Source§

fn try_into(self) -> Result<U, <U as TryFrom<T>>::Error>

Performs the conversion.