001 /** 002 * CDRSet.java 003 * jCOLIBRI2 framework. 004 * @author Juan A. Recio-García. 005 * GAIA - Group for Artificial Intelligence Applications 006 * http://gaia.fdi.ucm.es 007 * 21/11/2007 008 */ 009 package jcolibri.method.retrieve.selection.compromiseDriven; 010 011 import java.util.ArrayList; 012 import java.util.HashSet; 013 import java.util.Hashtable; 014 import java.util.Set; 015 016 import jcolibri.cbrcore.CBRCase; 017 018 /** 019 * Stores the retrieved cases and their "like" and "covered" sets. 020 * @author Juan A. Recio-Garcia 021 * @author Developed at University College Cork (Ireland) in collaboration with Derek Bridge. 022 * @version 1.0 023 * 024 */ 025 public class CDRSet extends ArrayList<CBRCase> 026 { 027 private static final long serialVersionUID = 1L; 028 029 private Hashtable<CBRCase,HashSet<CBRCase>> likeSets; 030 private Hashtable<CBRCase,HashSet<CBRCase>> coveredSets; 031 032 /** 033 * Constructor 034 */ 035 public CDRSet() 036 { 037 likeSets = new Hashtable<CBRCase,HashSet<CBRCase>>(); 038 coveredSets = new Hashtable<CBRCase,HashSet<CBRCase>>(); 039 } 040 041 /** 042 * Adds a case to the like set of another case 043 */ 044 public void addToLikeSet(CBRCase _case, CBRCase likeCase) 045 { 046 HashSet<CBRCase> like = likeSets.get(_case); 047 if(like == null) 048 { 049 like = new HashSet<CBRCase>(); 050 likeSets.put(_case, like); 051 } 052 like.add(likeCase); 053 } 054 055 /** 056 * Returns the like set of a case 057 */ 058 public Set<CBRCase> getLikeSet(CBRCase _case) 059 { 060 return likeSets.get(_case); 061 } 062 063 /** 064 * Adds a case to the covered set of another case 065 */ 066 public void addToCoveredSet(CBRCase _case, CBRCase coveredCase) 067 { 068 HashSet<CBRCase> covered = coveredSets.get(_case); 069 if(covered == null) 070 { 071 covered = new HashSet<CBRCase>(); 072 coveredSets.put(_case, covered); 073 } 074 covered.add(coveredCase); 075 } 076 077 /** 078 * Returns the covered set of a case 079 */ 080 public Set<CBRCase> getCoveredSet(CBRCase _case) 081 { 082 return coveredSets.get(_case); 083 } 084 }