diff --git a/Cargo.toml b/Cargo.toml index ab5b707..6d7c6fc 100644 --- a/Cargo.toml +++ b/Cargo.toml @@ -1,6 +1,6 @@ [package] name = "indxvec" -version = "1.9.3" +version = "1.9.4" authors = ["Libor Spacek"] edition = "2021" description = "Vecs sorting, merging, indexing, ranking, searching, reversing, intersecting, printing, etc." diff --git a/README.md b/README.md index 0769dad..81e727b 100644 --- a/README.md +++ b/README.md @@ -291,9 +291,7 @@ use indxvec::{MinMax,here}; ## Release Notes (Latest First) -**Version 1.9.3** Made `ranked` faster. - -**Version 1.9.2** Added `ranked` to trait Indices. Given rank index, it selects data values from `v` of sufficient rank, keeping their order. +**Version 1.9.4** Added `ranked` to trait Indices. Given rank index, it selects data values from `v` of sufficient rank, keeping their order. **Version 1.9.1** Stopped Trait Printing consuming single items by implementing it for `&T` rather than `T`. diff --git a/src/indices.rs b/src/indices.rs index 9b0df94..a7aff66 100644 --- a/src/indices.rs +++ b/src/indices.rs @@ -34,8 +34,10 @@ impl Indices for &[usize] { let mut res = Vec::with_capacity(rank); let mut count = 0_usize; // count the produced items for early exit for (&r,item) in self.iter().zip(v) { - if r < rank { count += 1; res.push(item.clone()); - if count > rank { break }; }; + if r < rank { + res.push(item.clone()); + count += 1; + if count == rank { break }; }; }; res }