@Test public void subtract() { Histogram h = new Histogram(new HashMap<Histogram.Range, Double>() { { put(new Histogram.Range(0, 1), 2d); put(new Histogram.Range(1, 8), 14d); put(new Histogram.Range(8, 10), 4d); } }.entrySet().stream().map(HistogramTest::map_)); Histogram i = new Histogram(new HashMap<Histogram.Range, Double>() { { put(new Histogram.Range(0, 10), 10d); } }.entrySet().stream().map(HistogramTest::map_)); Histogram expect = new Histogram(new HashMap<Histogram.Range, Double>() { { put(new Histogram.Range(0, 1), 1d); put(new Histogram.Range(1, 8), 7d); put(new Histogram.Range(8, 10), 2d); } }.entrySet().stream().map(HistogramTest::map_)); assertEquals(expect, Histogram.subtract(h, i)); }
public static Histogram subtract(Histogram x, Histogram y) { return new Histogram(Stream.concat( x.stream(), y.stream().map(rwc -> { rwc.setCount(-rwc.getCount()); return rwc; }))); }
Histogram implements Serializable, Comparable<Histogram> { public static Histogram subtract(Histogram x, Histogram y) { return new Histogram(Stream.concat( x.stream(), y.stream().map(rwc -> { rwc.setCount(-rwc.getCount()); return rwc; }))); } }
Histogram implements Serializable, Comparable<Histogram> { public static Histogram subtract(Histogram x, Histogram y) { return new Histogram(Stream.concat( x.stream(), y.stream().map(rwc -> { rwc.setCount(-rwc.getCount()); return rwc; }))); } Histogram(RangeWithCount... items);  Histogram(Stream<RangeWithCount> items); }
Histogram implements Serializable, Comparable<Histogram> { public static Histogram subtract(Histogram x, Histogram y) { return new Histogram(Stream.concat( x.stream(), y.stream().map(rwc -> { rwc.setCount(-rwc.getCount()); return rwc; }))); } Histogram(RangeWithCount... items);  Histogram(Stream<RangeWithCount> items); Stream<RangeWithCount> stream(); double getEventCount(); boolean isEmpty(); Optional<Double> min(); Optional<Double> max(); Optional<Double> median(); Optional<Double> avg(); double sum(); double get(double index); double percentile(double percentile); Histogram modifyEventCounters(BiFunction<Range, Double, Double> fn); static Histogram add(Histogram x, Histogram y); static Histogram negate(Histogram x); static Histogram subtract(Histogram x, Histogram y); static Histogram multiply(Histogram x, double y); static Histogram divide(Histogram x, double y); @Override int hashCode(); @Override boolean equals(Object obj); @Override int compareTo(Histogram o); @Override String toString(); }
Histogram implements Serializable, Comparable<Histogram> { public static Histogram subtract(Histogram x, Histogram y) { return new Histogram(Stream.concat( x.stream(), y.stream().map(rwc -> { rwc.setCount(-rwc.getCount()); return rwc; }))); } Histogram(RangeWithCount... items);  Histogram(Stream<RangeWithCount> items); Stream<RangeWithCount> stream(); double getEventCount(); boolean isEmpty(); Optional<Double> min(); Optional<Double> max(); Optional<Double> median(); Optional<Double> avg(); double sum(); double get(double index); double percentile(double percentile); Histogram modifyEventCounters(BiFunction<Range, Double, Double> fn); static Histogram add(Histogram x, Histogram y); static Histogram negate(Histogram x); static Histogram subtract(Histogram x, Histogram y); static Histogram multiply(Histogram x, double y); static Histogram divide(Histogram x, double y); @Override int hashCode(); @Override boolean equals(Object obj); @Override int compareTo(Histogram o); @Override String toString();  }