LoopStatistics { protected static long sumOf(Bag<Integer> bag) { long total = 0; for (Integer record : bag.asSet()) { total += record * bag.repetitionsOf(record); } return total; }  static Function<LoopStatistics, Integer> methodTopRecord(); static Function<LoopStatistics, Long> methodNumberOfIterations(); static Function<LoopStatistics, Integer> methodNumberOfRecords(); static Function<LoopStatistics, Integer> methodNumberOfErrorExits(); static Function<LoopStatistics, Integer> methodNumberOfBreakExits(); static Function<LoopStatistics, Integer> methodNumberOfReturnExits(); static Function<LoopStatistics, Integer> methodNumberOfConditionalExits(); static Function<LoopStatistics, Integer> methodNumberOfNonConditionalExits(); static Function<LoopStatistics, Double> methodIterationsRatio(); static Function<LoopStatistics, Double> methodIterationsMedian(); static Function<LoopStatistics, Double> methodIterationsFirstQuartile(); static Function<LoopStatistics, Double> methodIterationsThirdQuartile(); static Function<LoopStatistics, Bag<Integer>> methodExitRecords(); static Function<LoopStatistics, Bag<Integer>> methodConditionalRecords(); static Function<LoopStatistics, Bag<Integer>> methodErrorRecords(); static Function<LoopStatistics, Bag<Integer>> methodBreakRecords(); static Function<LoopStatistics, Bag<Integer>> methodReturnRecords(); static LoopStatistics empty(); static double meanOf(Bag<Integer> bag); static double medianOf(Bag<Integer> bag); static double firstQuartileOf(Bag<Integer> bag); static double thirdQuartileOf(Bag<Integer> bag); static double percentile(int percentile, Bag<Integer> bag); boolean hasInfiniteInvocation(); Integer infiniteInvocation(); int topRecord(); int numberOfRecords(); int numberOfErrorExits(); int numberOfBreakExits(); int numberOfReturnExits(); int numberOfConditionalExits(); int numberOfNonConditionalExits(); long numberOfIterations(); double iterationsRatio(); double iterationMedian(); double iterationsFirstQuartile(); double iterationsThirdQuartile(); Bag<Integer> exitRecords(); Bag<Integer> errorRecords(); Bag<Integer> breakRecords(); Bag<Integer> returnRecords(); Bag<Integer> conditionalRecords(); @Override String toString();  }
@Test public void sumIntegerBag() { Bag<Integer> bag = newHashBag(); assertEquals(0, sumOf(bag)); bag.addAll(asList(1, 2, 3, 4, 5, 1, 2, 3, 4, 5, 6, 7, 8, 9, 10)); assertEquals(70, sumOf(bag)); }