pub struct RankedSet<T> {
    pub ascending: bool,
    pub v: Vec<T>,
    pub i: Vec<usize>,
}
Expand description

Struct holding an unordered set and a vector of its ranks (ascending or descending).

Fields

ascending: bool

Ascending order (true), descending (false)

v: Vec<T>

Unordered data vector

i: Vec<usize>

Index giving the data ranks

Implementations

Associated functions for conversions, returning RankedSet

Initialiser, ranks an unordered slice

Initialiser, ranks an unordered Set

From Ordered - the index will be trivial

Converts sort index to ranks

Trait Implementations

Display implemented for struct RankedSet.

Formats the value using the given formatter. Read more

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.

Deletes an item v of the same end-type from self Returns false if the item is not found

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

just make the ranks descending

deletes repetitions.

Union of two RankedSets. Converts ranks to sort indices with invindex, merges, then converts back to ranks Data self.v is simply concatenated

Intersection of two RankedSets

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

For lots of set operations, it is probably better to work in IndexedSet(s) and then only to rank the final result.

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 index!

Deletes repetitions.

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

True if m is a member of the set

Search a Set for m. Returns index of the first m.

Mostly for non-members. Index of the next item in order, or self.len(). For unordered sets returns self.len(), too.

Union of two RankedSets. Returns new RankedSet

Intersection of two RankedSets. Via OrderedSet for convenience, for now. Todo: Probably should use intersect_indexed as in union above.

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

Auto Trait Implementations

Blanket Implementations

Gets the TypeId of self. Read more

Immutably borrows from an owned value. Read more

Mutably borrows from an owned value. Read more

Returns the argument unchanged.

Calls U::from(self).

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

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

Method to serialize generic items, slices, and slices of Vecs. Implementation code is in printing.rs. Read more

Printable in red

Printable in green

Printable in blue

Printable in yellow

Printable in magenta

Printable in cyan

Method to write vector(s) to file f (without brackets). Passes up io errors Read more

Method to print vector(s) to stdout (without brackets).

Converts the given value to a String. Read more

The type returned in the event of a conversion error.

Performs the conversion.

The type returned in the event of a conversion error.

Performs the conversion.