Expand description
This crate adds the TotallyOrderable trait for f32 and f64 values as well as the ABI-transparent TotallyOrdered type which adds Ord + Eq + Hash to wrapped floating point values.
Main use case: sorting of floating-point arrays which may or may not contain not-a-numbers, infinities, and positive or negative zeros.
use totally_ordered::TotallyOrdered;
let mut values : [f64; 4] = [-0.0, 0.0, -1.0, 1.0];
TotallyOrdered::new_slice_mut(&mut values).sort();Structs§
- Totally
Ordered - An ABI-transparent newtype wrapper around types that adds Ord + Eq to TotallyOrderable types (f32 and f64).
Traits§
- InPlace
Totally Orderable - Implement this for types that are not directly
Ord + Eq, but can be transformed in place in such a way that the associated typeTransformedis. Implemented forf32andf64. - Totally
Orderable - Implement this for types that are not directly
Ord + Eq, but can be at a slightly higher runtime cost. Implemented forf32andf64.
Functions§
- total_
sort - (Potentially) faster alternative to
TotallyOrdered::new_slice_mutfollowed bysortfor values that can be transformed in place.