diff --git a/src/signed_integer.rs b/src/signed_integer.rs index 1452526..77a5b97 100644 --- a/src/signed_integer.rs +++ b/src/signed_integer.rs @@ -45,3 +45,72 @@ impl_rdxsort!(i8, u8, i8::min_value(), 0i8); impl_rdxsort!(i16, u16, i16::min_value(), 0i16); impl_rdxsort!(i32, u32, i32::min_value(), 0i32); impl_rdxsort!(i64, u64, i64::min_value(), 0i64); + +#[cfg(target_pointer_width = "16")] +impl RdxSortTemplate for isize { + #[inline] + fn cfg_nbuckets() -> usize { + ::cfg_nbuckets() + } + + #[inline] + fn cfg_nrounds() -> usize { + ::cfg_nrounds() + } + + #[inline] + fn get_bucket(&self, round: usize) -> usize { + (*self as i16).get_bucket(round) + } + + #[inline] + fn reverse(round: usize, bucket: usize) -> bool { + ::reverse(round, bucket) + } +} + +#[cfg(target_pointer_width = "32")] +impl RdxSortTemplate for isize { + #[inline] + fn cfg_nbuckets() -> usize { + ::cfg_nbuckets() + } + + #[inline] + fn cfg_nrounds() -> usize { + ::cfg_nrounds() + } + + #[inline] + fn get_bucket(&self, round: usize) -> usize { + (*self as i32).get_bucket(round) + } + + #[inline] + fn reverse(round: usize, bucket: usize) -> bool { + ::reverse(round, bucket) + } +} + +#[cfg(target_pointer_width = "64")] +impl RdxSortTemplate for isize { + #[inline] + fn cfg_nbuckets() -> usize { + ::cfg_nbuckets() + } + + #[inline] + fn cfg_nrounds() -> usize { + ::cfg_nrounds() + } + + #[inline] + fn get_bucket(&self, round: usize) -> usize { + (*self as i64).get_bucket(round) + } + + #[inline] + fn reverse(round: usize, bucket: usize) -> bool { + ::reverse(round, bucket) + } +} diff --git a/src/unsigned_integer.rs b/src/unsigned_integer.rs index 3fb5491..b617ef0 100644 --- a/src/unsigned_integer.rs +++ b/src/unsigned_integer.rs @@ -91,3 +91,72 @@ impl RdxSortTemplate for u64 { false } } + +#[cfg(target_pointer_width = "16")] +impl RdxSortTemplate for usize { + #[inline] + fn cfg_nbuckets() -> usize { + ::cfg_nbuckets() + } + + #[inline] + fn cfg_nrounds() -> usize { + ::cfg_nrounds() + } + + #[inline] + fn get_bucket(&self, round: usize) -> usize { + (*self as u16).get_bucket(round) + } + + #[inline] + fn reverse(round: usize, bucket: usize) -> bool { + ::reverse(round, bucket) + } +} + +#[cfg(target_pointer_width = "32")] +impl RdxSortTemplate for usize { + #[inline] + fn cfg_nbuckets() -> usize { + ::cfg_nbuckets() + } + + #[inline] + fn cfg_nrounds() -> usize { + ::cfg_nrounds() + } + + #[inline] + fn get_bucket(&self, round: usize) -> usize { + (*self as u32).get_bucket(round) + } + + #[inline] + fn reverse(round: usize, bucket: usize) -> bool { + ::reverse(round, bucket) + } +} + +#[cfg(target_pointer_width = "64")] +impl RdxSortTemplate for usize { + #[inline] + fn cfg_nbuckets() -> usize { + ::cfg_nbuckets() + } + + #[inline] + fn cfg_nrounds() -> usize { + ::cfg_nrounds() + } + + #[inline] + fn get_bucket(&self, round: usize) -> usize { + (*self as u64).get_bucket(round) + } + + #[inline] + fn reverse(round: usize, bucket: usize) -> bool { + ::reverse(round, bucket) + } +} diff --git a/tests/lib.rs b/tests/lib.rs index 5e318f7..09bb3e5 100644 --- a/tests/lib.rs +++ b/tests/lib.rs @@ -59,10 +59,12 @@ trivial_myhash!(i8); trivial_myhash!(i16); trivial_myhash!(i32); trivial_myhash!(i64); +trivial_myhash!(isize); trivial_myhash!(u8); trivial_myhash!(u16); trivial_myhash!(u32); trivial_myhash!(u64); +trivial_myhash!(usize); impl MyHash for f32 { fn hash_it(&self, state: &mut H) where H: Hasher { @@ -319,6 +321,25 @@ mod sub_i64 { } } +mod sub_isize { + use super::*; + + #[test] + fn test_rnd_isize() { + test_rnd_generic::(vec![isize::min_value(), isize::min_value() + 1, -1, 0, 1, isize::max_value() - 1, isize::max_value()]); + } + + #[test] + fn test_empty_isize() { + test_empty_generic::(); + } + + #[test] + fn test_single_isize() { + test_single_generic::(3); + } +} + mod sub_u8 { use super::*; @@ -405,6 +426,25 @@ mod sub_u64 { } } +mod sub_usize { + use super::*; + + #[test] + fn test_rnd_usize() { + test_rnd_generic::(vec![0, 1, usize::max_value() - 1, usize::max_value()]); + } + + #[test] + fn test_empty_usize() { + test_empty_generic::(); + } + + #[test] + fn test_single_usize() { + test_single_generic::(3); + } +} + mod sub_f32 { use super::*;