Performs a binary search to find the physical index for the given logical index. Useful for extracting the corresponding physical `run_ends` when this buffer is logically sliced. The result is arbitrary if `logical_index >= self.len()`.
(&self, logical_index: usize)
| 230 | /// |
| 231 | /// The result is arbitrary if `logical_index >= self.len()`. |
| 232 | pub fn get_physical_index(&self, logical_index: usize) -> usize { |
| 233 | let logical_index = E::usize_as(self.logical_offset + logical_index); |
| 234 | let cmp = |p: &E| p.partial_cmp(&logical_index).unwrap(); |
| 235 | |
| 236 | match self.run_ends.binary_search_by(cmp) { |
| 237 | Ok(idx) => idx + 1, |
| 238 | Err(idx) => idx, |
| 239 | } |
| 240 | } |
| 241 | |
| 242 | /// Returns the physical index at which the logical array starts. |
| 243 | /// |