lookup method

  1. @override
V? lookup(
  1. Object? element
)
override

Implementation

@override
V? lookup(Object? element) {
  if (element is! V || _root == null) return null;
  AvlNode<V>? x = _root;
  int compare = 0;
  while (x != null) {
    compare = comparator(element, x.object);
    if (compare == 0) {
      return x.object;
    } else if (compare < 0) {
      x = x._left;
    } else {
      x = x._right;
    }
  }
  return null;
}