position_2d

Function position_2d 

Source
pub fn position_2d<T, P>(v: &[Vec<T>], predicate: P) -> Option<(usize, usize)>
where P: FnMut(&T) -> bool,
Expand description

Given 2-dimensional data and a predicate, position_2d() returns the position (ie, the 2D indices) of where the predicate first returned true, or None if the predicate never returns true. The input data is interpreted as follows:

vec![vec![1, 2, 3], vec![4, 5, 6]] is

1 2 3 4 5 6

That is, the indices of the 3 are (2, 0) - in (x, y) form.

Iteration order is left-to-right, top-to-bottom.

let v = vec![vec![1, 2, 3], vec![4, 5, 6]];
assert_eq!(aoclib_rs::position_2d(&v, |&i| i == 3), Some((2, 0)));