public <A> Histogram<A> build(AttributeExtractor<T,A> extractor){
        Histogram<A> histogram = new Histogram<A>();
        for (T item : collection) {
            A attribute = extractor.extract(item);
            histogram.put(attribute, histogram.get(attribute) + 1);
        }
        return histogram;
    }