This function finds the longest prefix of the form 0, 1, 2, ... within the collection `sequence`. Examples: - For 0, 1, 2, 4, 5; we would produce 3, meaning 0, 1, 2 is the longest satisfying prefix. - For 1, 2, 3, 4; we would produce 0, meaning there is no such prefix.
(
sequence: impl IntoIterator<Item = T>,
)
| 383 | /// prefix. |
| 384 | /// - For 1, 2, 3, 4; we would produce 0, meaning there is no such prefix. |
| 385 | pub fn longest_consecutive_prefix<T: Borrow<usize>>( |
| 386 | sequence: impl IntoIterator<Item = T>, |
| 387 | ) -> usize { |
| 388 | let mut count = 0; |
| 389 | for item in sequence { |
| 390 | if !count.eq(item.borrow()) { |
| 391 | break; |
| 392 | } |
| 393 | count += 1; |
| 394 | } |
| 395 | count |
| 396 | } |
| 397 | |
| 398 | /// Creates single element [`ListArray`], [`LargeListArray`] and |
| 399 | /// [`FixedSizeListArray`] from other arrays |
nothing calls this directly
no test coverage detected
searching dependent graphs…