/* $Id: SpreadFilter.java 125 2011-03-09 09:49:51Z ohura $ */
package smart_gs.image_search.research;

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

import smart_gs.image_search.logical.SearchResult;


public class SpreadFilter implements SearchFilter{

	
	public List<SearchResultSet> filtering(List<List<SearchResult>> results) {
		
		List<SearchResult> results1 = results.get(0);
		List<SearchResult> results2 = results.get(1);
		
		return this.filtering(results1,results2);
	}

	private List<SearchResultSet> filtering(List<SearchResult> result1, List<SearchResult> result2) {
		List<SearchResultSet> result = new ArrayList<SearchResultSet>();
		
		for(int i=0;i<result1.size();i++){
			SearchResult res1 = result1.get(i);
			for(int j=0;j<result2.size();j++){
				SearchResult res2 = result2.get(j);
				if(res1.getSpread().equals(res2.getSpread())){
					SearchResultSet set = new SearchResultSet();
					set.addResult(res1);
				    set.addResult(res2);
				    result.add(set);
				}
			}
		}
		return result;
	}
}
