Exemplo n.º 1
0
        /// <summary>
        /// Indicates whether some other object is "equal to" this OptionalDouble. The
        /// other object is considered equal if:
        /// <ul>
        /// <li>it is also an {@code OptionalDouble} and;
        /// <li>both instances have no value present or;
        /// <li>the present values are "equal to" each other via {@code Double.compare() == 0}.
        /// </ul>
        /// </summary>
        /// <param name="obj"> an object to be tested for equality </param>
        /// <returns> {code true} if the other object is "equal to" this object
        /// otherwise {@code false} </returns>
        public override bool Equals(Object obj)
        {
            if (this == obj)
            {
                return(true);
            }

            if (!(obj is OptionalDouble))
            {
                return(false);
            }

            OptionalDouble other = (OptionalDouble)obj;

            return((IsPresent && other.IsPresent) ? Value.CompareTo(other.Value) == 0 : IsPresent == other.IsPresent);
        }
Exemplo n.º 2
0
 /// <summary>
 /// Constructs a {@code FindOp} for streams of doubles.
 /// </summary>
 /// <param name="mustFindFirst"> whether the {@code TerminalOp} must produce the
 ///        first element in the encounter order </param>
 /// <returns> a {@code TerminalOp} implementing the find operation </returns>
 public static TerminalOp <Double, OptionalDouble> MakeDouble(bool mustFindFirst)
 {
     return(new FindOp <>(mustFindFirst, StreamShape.DOUBLE_VALUE, OptionalDouble.Empty(), OptionalDouble::isPresent, FindSink.OfDouble::new));
 }