/Dart 2

lookup method

E lookup (Object object)

If an object equal to object is in the set, return it.

Checks whether object is in the set, like contains, and if so, returns the object in the set, otherwise returns null.

If the equality relation used by the set is not identity, then the returned object may not be identical to object. Some set implementations may not be able to implement this method. If the contains method is computed, rather than being based on an actual object instance, then there may not be a specific object instance representing the set element.


E lookup(Object object) {
  if (!_validKey(object)) return null;
  int comp = _splay(object);
  if (comp != 0) return null;
  return _root.key;

© 2012 the Dart project authors
Licensed under the Creative Commons Attribution-ShareAlike License v4.0.