MinMax implements Consumer<C> { public boolean sameState(final MinMax<C> other) { return this == other || Objects.equals(_min, other._min) && Objects.equals(_max, other._max); } private  MinMax(final Comparator<? super C> comparator); @Override void accept(final C object); MinMax<C> combine(final MinMax<C> other); long count(); C min(); C max(); boolean sameState(final MinMax<C> other); @Override String toString(); static T min(final Comparator<? super T> comp, final T a, final T b); static T max(final Comparator<? super T> comp, final T a, final T b); static Collector<T, ?, MinMax<T>> toMinMax(final Comparator<? super T> comparator); static Collector<C, ?, MinMax<C>> toMinMax(); static MinMax<T> of(final Comparator<? super T> comparator); static MinMax<C> of(); static Function<C, Stream<C>> toStrictlyIncreasing(); static Function<C, Stream<C>> toStrictlyDecreasing(); static Function<T, Stream<T>> toStrictlyImproving(final Comparator<? super T> comparator);  }
@Test public void sameState() { final MinMax<Long> mm1 = MinMax.of(); final MinMax<Long> mm2 = MinMax.of(); final Random random = new Random(); for (int i = 0; i < 100; ++i) { final long value = random.nextInt(1_000_000); mm1.accept(value); mm2.accept(value); Assert.assertTrue(mm1.sameState(mm2)); Assert.assertTrue(mm2.sameState(mm1)); Assert.assertTrue(mm1.sameState(mm1)); Assert.assertTrue(mm2.sameState(mm2)); } }