findIn method

DeriveCodePropsItem? findIn(
  1. List<DeriveCodePropsItem> items,
  2. int target
)
inherited

Find codepoint in an abritrary list of items

Implementation

T? findIn(List<T> items, int target) {
  var left = 0;
  var right = items.length - 1;

  while (left <= right) {
    final middle = (left + right) ~/ 2;
    final middleRange = items[middle] as UcdItemBase;

    if (target < middleRange.start) {
      right = middle - 1;
    } else if (target > middleRange.end) {
      left = middle + 1;
    } else {
      return items[middle];
    }
  }

  return null;
}