lookup method
Returns an Optional
containing an element equal to element
if there is
one in this set, otherwise returns Optional.empty
.
Checks whether element
is in the set, like contains, and if so,
returns the object in the set wrapped in an Optional
, otherwise returns
Optional.empty
.
This lookup can not distinguish between an object not being in the set or
being the null
value.
The method contains can be used if the distinction is important.
Implementation
Optional<T> lookup(Object? element) =>
Optional.ofNullable(_set.lookup(element));