Indxvec
Description
This crate is lightweight and it has no dependencies.
The facilities provided are:
- simple and efficient random numbers,
- ranking, sorting, merging, searching,
- set operations and indices manipulations,
- easy printing of generic slices and slices of vectors.
Usage
Import into your source file(s) struct MinMax
, macro here!()
and other auxiliary functions, as needed:
use indxvec::{MinMax,here,tof64,ranf64,ranv64,ranvu8,ranvvf64,rannvvu8};
Use trait Indices
use indxvec::Indices;
Trait Indices
is implemented on type &[usize]
, i.e. slices of subscripts to slices and vectors.
Use trait Printing
use indxvec::Printing;
This trait provides utility methods to stringify (serialise for printing) generic slices and slices of slices. Optionally, it enables printing in bold green for emphasis (see tests/tests.rs
).
Use functions from module merge.rs
use indxvec::{merge::*};
They are applicable to generic slices &[T]
. Thus they will work on Rust primitive end types, such as f64. They can also work on slices holding any arbitrarily complex end type T
, as long as the required traits, mostly just PartialOrd
and/or Copy
, are implemented for T
.
The following statement will import everything:
use indxvec::{MinMax,here,tof64,ranf64,ranv64,ranvu8,ranvvf64,rannvvu8,Indices,Printing,merge::*};
Testing
It is highly recommended to read and run tests/tests.rs
to learn from examples of usage. Use a single thread to run them. It may be a bit slower but it will write the results in the right order:
cargo test --release -- --test-threads=1 --nocapture --color always
Trait Indices
The methods of this trait are implemented for slices of subscripts, i.e. they take the type &[usize]
as input (self) and produce new index Vec<usize>
, new data vector Vec<T>
, or other results as appropriate:
/// Methods to manipulate indices of `Vec<usize>` type.
Trait Printing
This trait is implemented for generic individual items T, for slices &[T] and for slices of vecs &[Vec]
/// Method `to_str()` to serialize generic items, slices, and slices of Vecs.
/// Method `gr()` to serialize and make the resulting string bold green when printed.
Functions Signatures
These functions can be found in module src/merge.rs
:
/// Maximum value T of slice &[T]
Release Notes (Latest First)
Version 1.0.4 - here!() now highlights the (first) error in bold red. Added fast random number generation functions ranf64, ranv64, ranvu8, ranvvf64, rannvvu8
.
Version 1.0.3 - Added utilities functions maxt, mint, minmaxt
. Rationalised the functions for printing generic slices and slices of vectors. They are now turned into two chainable methods in trait Printing
: .to_str()
and .gr()
. The latter also serialises slices to strings but additionally makes them bold green.
Version 1.0.2 - Added function occurs
that efficiently counts occurrences of specified items in a set with repetitions.
Version 1.0.1 - Some code style tidying up. Added function binsearchdesc
for completeness and symmetry with binsearch
.
Version 1.0.0 - indxvec
has been stable for some time now, so it gets promoted to v1.0.0. There are some improvements to README.md
to mark the occasion.
Version 0.2.12 - added utility function printvv
to prettyprint vectors of vectors.
Version 0.2.11 - added some badges and improved readme
.
Version 0.2.9 - added struct MinMax for returning values from function 'minmax' and displaying them. Removed function wt
used previously for displaying them as tuples.
Version 0.2.6 - added unindexf64
for convenience. Same as unindex
but the output is always converted to Vec<f64>
.
Version 0.2.5 - added memsearchdesc_indexed
= binary search of a descending indexed set.
Version 0.2.4 - added helper function wt
= write tuple. Added memsearchdesc
= binary search of a descending set.
Version 0.2.3 - general tidying up and readme update.
Version 0.2.2 - replaced GV and GI with functions wv
and wi
respectively. Added revindex
to Indices
trait, so that it can be functionally chained with its other methods.
Version 0.2.1 - moved GI from rstats
to here. Fixed minmax
.
Version 0.2.0 - added set operations: sansrepeat, member, memsearch, memsearch_indexed, unite, unite_indexed, intersect, intersect_indexed, diff, diff_indexed
. They are also used, with type/struct wrappers, by crate sets
.