Expand description
Struct holding an unordered set and a vector of its ranks (ascending or descending).
Fields
ascending: boolv: Vec<T>i: Vec<usize>Implementations
sourceimpl<T> RankedSet<T>
impl<T> RankedSet<T>
sourcepub fn from_slice(s: &[T], asc: bool) -> Self where
T: PartialOrd + Copy,
pub fn from_slice(s: &[T], asc: bool) -> Self where
T: PartialOrd + Copy,
Initialiser, ranks an unordered slice
sourcepub fn from_set(s: &Set<T>, asc: bool) -> Self where
T: PartialOrd + Copy,
pub fn from_set(s: &Set<T>, asc: bool) -> Self where
T: PartialOrd + Copy,
Initialiser, ranks an unordered Set
sourcepub fn from_ordered(s: &OrderedSet<T>, asc: bool) -> Self where
T: PartialOrd + Copy,
pub fn from_ordered(s: &OrderedSet<T>, asc: bool) -> Self where
T: PartialOrd + Copy,
From Ordered - the index will be trivial
sourcepub fn from_indexed(s: &IndexedSet<T>, asc: bool) -> Self where
T: PartialOrd + Copy,
pub fn from_indexed(s: &IndexedSet<T>, asc: bool) -> Self where
T: PartialOrd + Copy,
Converts sort index to ranks
Trait Implementations
sourceimpl<'a, T: Display> Display for RankedSet<T> where
T: Copy,
impl<'a, T: Display> Display for RankedSet<T> where
T: Copy,
Display implemented for struct RankedSet.
sourceimpl<T> MutSetOps<T> for RankedSet<T> where
T: Copy + PartialOrd,
impl<T> MutSetOps<T> for RankedSet<T> where
T: Copy + PartialOrd,
The primitive functions from indxvec all expect indexed sets,
so for now we convert from ranks to sort indices using .invindex().
Even though that is a simple operation, for lots of set operations,
it will be slightly quicker to work in IndexedSet(s)
and only to rank the final result.
sourcefn mnonrepeat(&mut self)
fn mnonrepeat(&mut self)
deletes repetitions.
sourcefn munion(&mut self, s: &Self)
fn munion(&mut self, s: &Self)
Union of two RankedSets.
Converts ranks to sort indices with invindex, merges, then converts back to ranks
Data self.v is simply concatenated
sourcefn mintersection(&mut self, s: &Self)
fn mintersection(&mut self, s: &Self)
Intersection of two RankedSets
sourcefn mdifference(&mut self, s: &Self)
fn mdifference(&mut self, s: &Self)
Complement of s in self (i.e. self-s)
sourceimpl<T> SetOps<T> for RankedSet<T> where
T: Copy + PartialOrd,
impl<T> SetOps<T> for RankedSet<T> where
T: Copy + PartialOrd,
For lots of set operations, it is probably better to work in IndexedSet(s) and then only to rank the final result.
sourcefn reverse(&self) -> Self
fn reverse(&self) -> Self
switches between ascending and descending ranks, which is what is logically expected here but it is not the same as a literal reversal of the ranks!
sourcefn nonrepeat(&self) -> OrderedSet<T>
fn nonrepeat(&self) -> OrderedSet<T>
Deletes repetitions.
sourcefn infsup(&self) -> MinMax<T>
fn infsup(&self) -> MinMax<T>
Finds minimum, minimum’s first index, maximum, maximum’s first index
sourcefn intersection(&self, s: &Self) -> OrderedSet<T>
fn intersection(&self, s: &Self) -> OrderedSet<T>
Intersection of two RankedSets.
Via OrderedSet for convenience, for now.
Todo: Probably should use intersect_indexed as in union above.
sourcefn difference(&self, s: &Self) -> OrderedSet<T>
fn difference(&self, s: &Self) -> OrderedSet<T>
Complement of s in self (i.e. self-s)
Auto Trait Implementations
impl<T> RefUnwindSafe for RankedSet<T> where
T: RefUnwindSafe,
impl<T> Send for RankedSet<T> where
T: Send,
impl<T> Sync for RankedSet<T> where
T: Sync,
impl<T> Unpin for RankedSet<T> where
T: Unpin,
impl<T> UnwindSafe for RankedSet<T> where
T: UnwindSafe,
Blanket Implementations
sourceimpl<T> BorrowMut<T> for T where
T: ?Sized,
impl<T> BorrowMut<T> for T where
T: ?Sized,
const: unstable · sourcefn borrow_mut(&mut self) -> &mut T
fn borrow_mut(&mut self) -> &mut T
Mutably borrows from an owned value. Read more
sourceimpl<T> Printing<T> for T where
T: Display,
impl<T> Printing<T> for T where
T: Display,
sourcefn to_str(self) -> String
fn to_str(self) -> String
Method to serialize generic items, slices, and slices of Vecs.
Adds square brackets around Vecs (prettier lists).
Implementation code is in printing.rs. Read more
sourcefn to_plainstr(self) -> String
fn to_plainstr(self) -> String
Method to serialize generic items, slices, and slices of Vecs.
Implementation code is in printing.rs. Read more
sourcefn rd(self) -> String
fn rd(self) -> String
Methods to serialize and render the resulting string in bold ANSI terminal colours. Read more