|0.1.7||Jul 10, 2021|
|0.1.6||Jul 10, 2021|
#279 in Algorithms
30 downloads per month
Insert into your Cargo.toml file [dependencies] section:
sets = "^0.1"
Import into your source file(s) the structs and trait:
The initialisers and conversions are associated with their structs, e.g.:
let s = Set::from_slice(&v);
The rest are methods of the traits SetOps, and MutSetOps e.g.:
let mut su = s.nonrepeat(); // new set with unique elements
su.mreverese; // transformed into the opposite order
See tests/tests.rs for example usage.
sets consists mostly of structs
Set, OrderedSet, IndexedSet, RankedSet, which are type-safe wrappers for the more primitive imported functions and methods from crate
The main capabilities of
sets include: efficient sorting, ranking, merging, searching and indices manipulations. The structs contain generic vectors
Vec<T>. Thus they will work with vectors/slices of primitive types but also on any arbitrarily complex end type
T, as long as the required traits
Copy, are implemented for
reverse, nonrepeat, infsup, member, search, union, intersection, difference,
for all four types of sets. Some of these methods are more efficient for the ordered and indexed sets, rather than for the unordered sets. For example,
search are then able to use binary search. Union is like the classical merge but only one copy of items that were present in both input sets is kept. To remove repetitions from a set, use
Union, interesection and difference applied to IndexedSet(s) or RankedSet(s) for now return only OrderedSet(s). Should this not be what is wanted, convert the result, or better still, use
munion, minteresection and mdifference, (see below), which do not have this restriction.
mreverse, mnonrepeat, munion, mintersection, mdifference,
for all four types of sets. They overwrite the mutable set to which they are applied with the result. Thus they are not functional but in this context of handling potentially large vectors, they are in some cases simpler and more efficient.
Version 0.1.7 - just some cosmetic cleaning up. No change of functionality from the previous version.
Version 0.1.6 - implemented
MutSetOps for all set types and added some tests.
Version 0.1.5 - implemented
RankedSet, making the implementations now complete. Future work: adding mutable sets.
Version 0.1.4 - updated readme, implemented
Version 0.1.3 - fixed readme typos, improved tests, implemented
Version 0.1.2 - implemented
SetOps trait for struct
Set. The other three structs will follow in the next versions.
Version 0.1.1 - competed the associated functions for all initiations and conversions of the four set structs.
Version 0.1.0 - first version, includes creation and conversions of the structs representing the four types of sets.