rposition method

  1. @override
Option<int> rposition(
  1. bool f(
    1. T
    )
)

Searches for an element in an iterator from the right, returning its index. Recommended to use with a list, as it is more efficient, otherwise use position.

Implementation

@override
Option<int> rposition(bool Function(T) f) {
  final list = toList(growable: false).reversed;
  var index = list.length - 1;
  for (final element in list) {
    if (f(element)) {
      return Some(index);
    }
    index--;
  }
  return None;
}