// Path: src/main/java/com/github/eostermueller/heapspank/leakyspank/LeakySpankContext.java
// public class LeakResult {
// 	private long timestamp;
// 	LeakResult() {
// 		this.timestamp = System.currentTimeMillis();
// 	}
// 	public JMapHistoLine line = null;
// 	public int countRunsPresent = 0;
// 	public int countRunsWithLeakierRank = 0;
// 	public int countRunsWithBytesIncrease = 0;
// 	public int countRunsWithInstanceCountIncrease = 0;
// 		
// 	/**
// 	 * The percentage of 'runs' that the bytes increase from the previous run.
// 	 * @return a double between 0 and 1.  Multiply the result by to get a portion of 100%.
// 	 */
// 	public double getPercentageOfRunsWithUpwardByteTrend() {
// 		double rc = 0;
// 			
// 		double totalRunCount = LeakySpankContext.this.getCurrentRunCount() -1;
// 		if (this.countRunsWithBytesIncrease == 0 || totalRunCount == 0) // avoid divide by 0 problems.
// 			rc = 0;
// 		else
// 			rc = this.countRunsWithBytesIncrease / totalRunCount;
// 			
// 		return rc;
// 	}
// 	/**
// 	 * Higher score means more likely a leak
// 	 * @return
// 	 */
// 	int getLeakScore() {
// 		return this.countRunsPresent+this.countRunsWithLeakierRank+this.countRunsWithBytesIncrease+this.countRunsWithInstanceCountIncrease;
// 	}
// 	public String humanReadable() {
// 		StringBuilder sb = new StringBuilder();
// 		 sb.append("Class=" + line.className + "\n");
// 		 sb.append("\ncountRunsPresent=" + this.countRunsPresent + "\n");
// 		 sb.append("countRunsWithRankIncrease=" + this.countRunsWithLeakierRank + "\n");
// 		 sb.append("countRunsWithBytesIncrease=" + this.countRunsWithBytesIncrease + "\n");
// 		 sb.append("countRunsWithInstanceCountIncrease=" + this.countRunsWithInstanceCountIncrease + "\n");
// 		 return sb.toString();
// 	}
// 	/**
// 	 * update values in 'this' with values from the given LeakResult
// 	 * @param oneToAdd
// 	 */
// 	public void update(LeakResult oneToAdd) {
// 		/**
// 		 * Add given values to tally values.
// 		 */
// 		this.countRunsPresent+= oneToAdd.countRunsPresent;
// 		this.countRunsWithBytesIncrease += oneToAdd.countRunsWithBytesIncrease;
// 		this.countRunsWithInstanceCountIncrease += oneToAdd.countRunsWithInstanceCountIncrease;
// 		this.countRunsWithLeakierRank += oneToAdd.countRunsWithLeakierRank;
// 			
// 		/**
// 		 * display current values of these, instead of outdated values.
// 		 */
// 		this.line.bytes = oneToAdd.line.bytes;
// 		this.line.num = oneToAdd.line.num;
// 		this.line.instances = oneToAdd.line.instances;
// 	}
// 		
// }
// 
// Path: src/main/java/com/github/eostermueller/heapspank/util/BaseEvent.java
// public abstract class BaseEvent {
// 
// }
// 
// Path: src/main/java/com/github/eostermueller/heapspank/util/EventListener.java
// public interface EventListener {
// 	public void onEvent(BaseEvent e);
// }
// 
// Path: src/main/java/com/github/eostermueller/heapspank/util/LimitedSizeQueue.java
// public class LimitedSizeQueue<E> extends ConcurrentLinkedQueue<E> {
//     private int limit;
// 
//     public LimitedSizeQueue(int limit) {
//         this.limit = limit;
//     }
// 
//     @Override
//     public boolean add(E o) {
//         boolean added = super.add(o);
//         while (added && size() > limit) {
//            super.remove();
//         }
//         return added;
//     }
//     public E peekFirst() {
//     	Iterator i = this.iterator();
//     	E item = null;
//     	if (i.hasNext())
//     		item = (E) i.next();
//     	return item;
//     }
//     public E peekLast() {
//     	Iterator i = this.iterator();
//     	E item = null;
//     	while(i.hasNext()) {
//     		item = (E) i.next();
//     	}
//     	return item;
//     }
// 
// }


import java.util.ArrayList;
import java.util.Collections;
import java.util.Comparator;
import java.util.Iterator;
import java.util.List;
import com.github.eostermueller.heapspank.leakyspank.LeakySpankContext.LeakResult;
import com.github.eostermueller.heapspank.util.BaseEvent;
import com.github.eostermueller.heapspank.util.EventListener;
import com.github.eostermueller.heapspank.util.LimitedSizeQueue;
package com.github.eostermueller.heapspank.leakyspank;



public class LeakySpankContext {

	private List<EventListener> windowClosedListener = new ArrayList<EventListener>();
	public void addWindowClosedListener(EventListener e) {
		this.windowClosedListener.add(e);
	}
	public static class WindowClosedEvent extends BaseEvent {
		
	}
	private static final String HEAP_SPANK = "heapSpank: ";
	private int currentRunCount  = 0;
// Path: src/main/java/com/github/eostermueller/heapspank/leakyspank/LeakySpankContext.java
// public class LeakResult {
// 	private long timestamp;
// 	LeakResult() {
// 		this.timestamp = System.currentTimeMillis();
// 	}
// 	public JMapHistoLine line = null;
// 	public int countRunsPresent = 0;
// 	public int countRunsWithLeakierRank = 0;
// 	public int countRunsWithBytesIncrease = 0;
// 	public int countRunsWithInstanceCountIncrease = 0;
// 		
// 	/**
// 	 * The percentage of 'runs' that the bytes increase from the previous run.
// 	 * @return a double between 0 and 1.  Multiply the result by to get a portion of 100%.
// 	 */
// 	public double getPercentageOfRunsWithUpwardByteTrend() {
// 		double rc = 0;
// 			
// 		double totalRunCount = LeakySpankContext.this.getCurrentRunCount() -1;
// 		if (this.countRunsWithBytesIncrease == 0 || totalRunCount == 0) // avoid divide by 0 problems.
// 			rc = 0;
// 		else
// 			rc = this.countRunsWithBytesIncrease / totalRunCount;
// 			
// 		return rc;
// 	}
// 	/**
// 	 * Higher score means more likely a leak
// 	 * @return
// 	 */
// 	int getLeakScore() {
// 		return this.countRunsPresent+this.countRunsWithLeakierRank+this.countRunsWithBytesIncrease+this.countRunsWithInstanceCountIncrease;
// 	}
// 	public String humanReadable() {
// 		StringBuilder sb = new StringBuilder();
// 		 sb.append("Class=" + line.className + "\n");
// 		 sb.append("\ncountRunsPresent=" + this.countRunsPresent + "\n");
// 		 sb.append("countRunsWithRankIncrease=" + this.countRunsWithLeakierRank + "\n");
// 		 sb.append("countRunsWithBytesIncrease=" + this.countRunsWithBytesIncrease + "\n");
// 		 sb.append("countRunsWithInstanceCountIncrease=" + this.countRunsWithInstanceCountIncrease + "\n");
// 		 return sb.toString();
// 	}
// 	/**
// 	 * update values in 'this' with values from the given LeakResult
// 	 * @param oneToAdd
// 	 */
// 	public void update(LeakResult oneToAdd) {
// 		/**
// 		 * Add given values to tally values.
// 		 */
// 		this.countRunsPresent+= oneToAdd.countRunsPresent;
// 		this.countRunsWithBytesIncrease += oneToAdd.countRunsWithBytesIncrease;
// 		this.countRunsWithInstanceCountIncrease += oneToAdd.countRunsWithInstanceCountIncrease;
// 		this.countRunsWithLeakierRank += oneToAdd.countRunsWithLeakierRank;
// 			
// 		/**
// 		 * display current values of these, instead of outdated values.
// 		 */
// 		this.line.bytes = oneToAdd.line.bytes;
// 		this.line.num = oneToAdd.line.num;
// 		this.line.instances = oneToAdd.line.instances;
// 	}
// 		
// }
// 
// Path: src/main/java/com/github/eostermueller/heapspank/util/BaseEvent.java
// public abstract class BaseEvent {
// 
// }
// 
// Path: src/main/java/com/github/eostermueller/heapspank/util/EventListener.java
// public interface EventListener {
// 	public void onEvent(BaseEvent e);
// }
// 
// Path: src/main/java/com/github/eostermueller/heapspank/util/LimitedSizeQueue.java
// public class LimitedSizeQueue<E> extends ConcurrentLinkedQueue<E> {
//     private int limit;
// 
//     public LimitedSizeQueue(int limit) {
//         this.limit = limit;
//     }
// 
//     @Override
//     public boolean add(E o) {
//         boolean added = super.add(o);
//         while (added && size() > limit) {
//            super.remove();
//         }
//         return added;
//     }
//     public E peekFirst() {
//     	Iterator i = this.iterator();
//     	E item = null;
//     	if (i.hasNext())
//     		item = (E) i.next();
//     	return item;
//     }
//     public E peekLast() {
//     	Iterator i = this.iterator();
//     	E item = null;
//     	while(i.hasNext()) {
//     		item = (E) i.next();
//     	}
//     	return item;
//     }
// 
// }


// Path: src/main/java/com/github/eostermueller/heapspank/leakyspank/LeakySpankContext.java
import java.util.ArrayList;
import java.util.Collections;
import java.util.Comparator;
import java.util.Iterator;
import java.util.List;
import com.github.eostermueller.heapspank.leakyspank.LeakySpankContext.LeakResult;
import com.github.eostermueller.heapspank.util.BaseEvent;
import com.github.eostermueller.heapspank.util.EventListener;
import com.github.eostermueller.heapspank.util.LimitedSizeQueue;

package com.github.eostermueller.heapspank.leakyspank;



public class LeakySpankContext {

	private List<EventListener> windowClosedListener = new ArrayList<EventListener>();
	public void addWindowClosedListener(EventListener e) {
		this.windowClosedListener.add(e);
	}
	public static class WindowClosedEvent extends BaseEvent {
		
	}
	private static final String HEAP_SPANK = "heapSpank: ";
	private int currentRunCount  = 0;
	private LimitedSizeQueue<String> debugDisplayQ;