package com.github.atorr0.predictor.statistics;

import java.util.ArrayList;
import java.util.List;

/**
 * Simple stats. for hits & misses.
 *
 * @author https://github.com/atorr0
 */
public class Statistics {

	protected final List<Long> missesList = new ArrayList<>();

	protected long hits = 0, misses = 0;

	public long incrementHits() {
		return ++hits;
	}

	public long incrementMisses() {
		return ++misses;
	}

	public void next() {

		missesList.add(misses);
		hits = 0;
		misses = 0;
	}

	@Override
	public String toString() {

		long total = 0;
		for (Long misses : missesList)
			total += misses;

		final float hitRatio = Float.parseFloat("" + total) / missesList.size();

		return "Statistics [" //
				+ "hitRatio=" + hitRatio //
				+ ", missesList=" + missesList //
				+ ", hits=" + hits + ", misses=" + misses //
				+ "]";
	}
}
@@ -299,18 +299,8 @@
 long
- hits = 0,
  mis
@@ -323,47 +323,177 @@
 lic 
-long incrementHits() %7B%0D%0A%09%09return ++hits
+float getHitRatio() %7B%0D%0A%0D%0A%09%09long total = 0;%0D%0A%09%09for (final Long misses : missesList)%0D%0A%09%09%09total += misses;%0D%0A%0D%0A%09%09return 1f - Float.parseFloat(%22%22 + total) / missesList.size()
 ;%0D%0A%09
@@ -613,21 +613,8 @@
 );%0D%0A
-%09%09hits = 0;%0D%0A
 %09%09mi
@@ -677,162 +677,8 @@
 %0D%0A%0D%0A
-%09%09long total = 0;%0D%0A%09%09for (Long misses : missesList)%0D%0A%09%09%09total += misses;%0D%0A%0D%0A%09%09final float hitRatio = Float.parseFloat(%22%22 + total) / missesList.size();%0D%0A%0D%0A
 %09%09re
@@ -721,24 +721,29 @@
 tio=%22 + 
-h
+getH
 itRatio
+()
  //%0D%0A%09%09%09
@@ -790,27 +790,8 @@
 + %22,
- hits=%22 + hits + %22,
  mis

UPDATE remove hit counts + FIX hit ratio was wrongly calculated