<commit_before>package Cache;

import java.util.Comparator;

public class CacheReplacement {

	public static enum Policy{LRU,BUGS,CHANGES,AUTHORS};
	static final CacheReplacement.Policy REPDEFAULT = CacheReplacement.Policy.LRU;


	protected Comparator<CacheItem> compareFunc;
	
	public CacheReplacement(Policy p){
		switch (p){
		case BUGS: compareFunc = new ComparatorBugs();break;
		case CHANGES: compareFunc = new ComparatorChanges();break;
		case AUTHORS: compareFunc = new ComparatorAuthors();break;
		case LRU: compareFunc = new ComparatorLRU();
		}
	}

	public CacheItem minimum(CacheItem o1, CacheItem o2){
		if (compareFunc.compare(o1, o2) <0 )<commit_msg>Added LRU tiebreaking to the cache replacement algorithm<commit_after>package Cache;

import java.util.Comparator;

public class CacheReplacement {

	public static enum Policy{LRU,BUGS,CHANGES,AUTHORS};
	static final CacheReplacement.Policy REPDEFAULT = CacheReplacement.Policy.LRU;

	protected Comparator<CacheItem> compareFunc;
	protected ComparatorLRU tiebreaker;
	
	public CacheReplacement(Policy p){
		switch (p){
		case BUGS: compareFunc = new ComparatorBugs();break;
		case CHANGES: compareFunc = new ComparatorChanges();break;
		case AUTHORS: compareFunc = new ComparatorAuthors();break;
		case LRU: compareFunc = new ComparatorLRU();
		}
	}

	public CacheItem minimum(CacheItem o1, CacheItem o2){
		int comparison = compareFunc.compare(o1, o2);		
		if (comparison == 0){
			if (tiebreaker.compare(o1, o2) < 0)
				return o1;
			else
				return o2;
		}
		else if (comparison < 0 )
{'fraction_non_alphanumeric': 0.09401159047005796, 'fraction_numerical': 0.0103026400515132, 'mean_word_length': 5.291497975708502, 'pattern_counts': {'":': 0, '<': 8, '<?xml version=': 0, '>': 5, 'https://': 0, 'lorem ipsum': 0, 'www.': 0, 'xml': 0}, 'pii_count': 0, 'substrings_counts': 0, 'word_list_counts': {'cursed_substrings.json': 0, 'profanity_word_list.json': 0, 'sexual_word_list.json': 0, 'zh_pornsignals.json': 0}}
{'dir': 'git-commits-cleaned', 'id': '948657', 'n_tokens_mistral': 541, 'n_tokens_neox': 481, 'n_words': 134}