rightNeighbour method

dynamic rightNeighbour(
  1. dynamic reference
)

Returns the smallest value in the tree which is larger than reference.

reference is either a value of type T or a function int order(T other) which returns -1, 0, or 1 depending on wether the value other in a tree node is smaller, equal, or larger as the reference point.

The standard case is to invoke it with a value of type T. The second option is useful in special usage scenarios only, see notes in the class description.

The returned value is either:

  • null, if this tree is empty
  • a single value of type T, if this tree doesn't support equivalence classes
  • a list of type List[T], if this tree does support equivalence classes

Implementation

dynamic rightNeighbour(reference) {
  var n = _rightNeighbourNode(reference);
  if (n == null) return null;
  if (_withEquivalenceClasses) {
    return n.values;
  } else {
    return n.values.first;
  }
}