ObjectHistogram implements Histogram<T, ObjectHistogram<T>>, DistributionComputer { @Override public ObjectHistogram<T> plus(ObjectHistogram<T> other) { ObjectHistogram<T> res = newInstance(); addTo(this.hist, res.hist); addTo(other.hist, res.hist); return res; }  @Override void addElement(T val); @Override Set<Integer> buckets(); @Override Optional<Double> getValue(Integer bucketId); @Override TreeMap<Integer, Double> computeDistributionFunction(); @Override ObjectHistogram<T> plus(ObjectHistogram<T> other); @Override boolean isEqualTo(ObjectHistogram<T> other); abstract Integer mapToBucket(T obj); abstract Double mapToCounter(T obj); abstract ObjectHistogram<T> newInstance();  }
@Test public void testAddHist() { ObjectHistogram<Double> res = hist1.plus(hist2); testBuckets(res, new int[] {0, 1, 2, 3, 4, 5, 6}, new int[] {10, 8, 2, 1, 1, 2, 1}); }