Struct sets::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) -> boolwhere Self: Sized,

Deletes an item from self Returns false if item not found

source§

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 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> 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 Twhere T: 'static + ?Sized,

source§

fn type_id(&self) -> TypeId

Gets the TypeId of self. Read more
source§

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

source§

fn borrow(&self) -> &T

Immutably borrows from an owned value. Read more
source§

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

source§

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

Mutably borrows from an owned value. 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 Twhere 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> Printing<T> for Twhere T: Display,

source§

fn to_str(self) -> String

Method to serialize. Decorates Vecs with square brackets and tuples with round ones. Implementation code is in printing.rs.
source§

fn to_plainstr(self) -> String

Method to serialize in minimal form (space separated, no brackets) Implementation code is in printing.rs.
source§

fn rd(self) -> String

Printable in red
source§

fn gr(self) -> String

Printable in green
source§

fn bl(self) -> String

Printable in blue
source§

fn yl(self) -> String

Printable in yellow
source§

fn mg(self) -> String

Printable in magenta
source§

fn cy(self) -> String

Printable in cyan
source§

fn wvec(self, f: &mut File) -> Result<(), Error>

Method to write vector(s) to file f (space separated, without brackets). Passes up io errors
source§

fn pvec(self)

Method to print vector(s) to stdout (space separated,without brackets).
source§

impl<T> ToOwned for Twhere T: Clone,

§

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 Twhere T: Display + ?Sized,

source§

default fn to_string(&self) -> String

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

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

§

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 Twhere U: TryFrom<T>,

§

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.