pub fn hash_median<T>(s:&mut [T],min:f64,max:f64) -> f64
    where T: Copy+PartialOrd,f64:From<T> {
    let n = s.len();
    if n == 0 { panic!("{} empty vector!",here!()); };
    if n == 1 { return f64::from(s[0]); };
    if n == 2 { return (f64::from(s[0])+f64::from(s[1]))/2.0; }; 
    hashsort(s,min,max); 
    let mid = s.len()/2; // midpoint (floors odd sizes)
    if (n & 1) == 0 { (f64::from(s[mid-1]) + f64::from(s[mid])) / 2.0 } // s is even
    else { f64::from(s[mid]) } // s is odd     
}
/// Exactly the same as naive_median, except uses hashsort, 
/// which is about 25% faster for >1K items.
Exactly the same as naive_median, except uses hashsort,
which is about 25% faster for >1K items.
Exactly the same as naive_median except uses hashsort which is about 25% faster for > 1K items .
pub fn hash_median<T>(s:&mut [T],min:f64,max:f64) -> f64
    where T: Copy+PartialOrd,f64:From<T> {
    let n = s.len();
    if n == 0 { panic!("{} empty vector!",here!()); };
    if n == 1 { return f64::from(s[0]); };
    if n == 2 { return (f64::from(s[0])+f64::from(s[1]))/2.0; }; 
    hashsort(s,min,max); 
    let mid = s.len()/2; // midpoint (floors odd sizes)
    if (n & 1) == 0 { (f64::from(s[mid-1]) + f64::from(s[mid])) / 2.0 } // s is even
    else { f64::from(s[mid]) } // s is odd     
}
pub fn hash_median < T > ( s : & mut [ T ] , min : f64 , max : f64 ) -> f64 where T : Copy + PartialOrd , f64 : From < T > { let n = s . len ( ) ; if n == 0 { panic ! ( " " here ( ) ) ; } ; if n == 1 { return f64 :: from ( s [ 0 ] ) ; } ; if n == 2 { return ( f64 :: from ( s [ 0 ] ) + f64 :: from ( s [ 1 ] ) ) / 2.0 ; } ; hashsort ( s , min , max ) ; let mid = s . len ( ) / 2 ; // midpoint (floors odd sizes) if ( n & 1 ) == 0 { ( f64 :: from ( s [ mid - 1 ] ) + f64 :: from ( s [ mid ] ) ) / 2.0 } // s is even else { f64 :: from ( s [ mid ] ) } // s is odd      }
Exactly the same as naive_median, except uses hashsort,
which is about 25% faster for >1K items.
Exactly the same as naive_median except uses hashsort which is about 25% faster for > 1K items .
s
&mut [T]
min
f64
max
f64
s
&mut [T]
min
f64
max
f64