// Path: src/org/styloot/hobo/Item.java
// public class Item implements Comparable<Item>{
//     public Item(String i, String c, Collection<String> f, int q, CIELabColor clr, int cst) {
// 	id = i; category = Category.getCategory(c); quality = q;
// 	features = Feature.getFeatures(f);
// 	color = clr;
// 	cost = cst;
//     }
// 
//     public Item(String i, String c, String[] f, int q, CIELabColor clr, int cst) {
// 	id = i; category = Category.getCategory(c); quality = q;
// 	features = Feature.getFeatures(f);
// 	color = clr;
// 	cost = cst;
//     }
// 
//     public Item(String i, String c, Vector<String> f, int q, CIELabColor clr, int cst) {
// 	this(i, c, f.toArray((String[])(new String[]{})), q, clr, cst);
//     }
// 
//     public boolean hasFeatures(Collection<String> feats) {
// 	log.warn("Calling item.hasFeatures(Collection<String> features) - will be inefficient.");
// 	if (feats == null) {
// 	    return true;
// 	}
// 	return hasFeatures(Feature.getFeatures(feats));
//     }
// 
//     public Feature[] getFeatures() {
// 	return features;
//     }
// 
//     public boolean hasFeature(Feature f) {
// 	for (Feature f2 : features) {
// 	    if (f == f2) {
// 		return true;
// 	    }
// 	}
// 	return false;
//     }
// 
//     public boolean hasFeatures(Feature[] feats) {
// 	if (feats == null) {
// 	    return true;
// 	}
// 	if (features == null && feats.length > 0) { //We definitely don't have the feature
// 	    return false;
// 	}
// 	for (Feature f : feats) {
// 	    if (!hasFeature(f)) {
// 		return false;
// 	    }
// 	}
// 	return true;
//     }
// 
//     public boolean hasFeaturesSorted(Feature[] feats) {
// 	return Util.isSubsetSorted(feats, features);
//     }
// 
//     public double colorDist2From(CIELabColor other) {
// 	return other.distance2To(color);
//     }
// 
//     public CIELabColor getColor() {
// 	return color;
//     }
// 
//     public final String id;
//     public final Category category;
//     public final Feature[] features;
//     public final int quality;
//     public final CIELabColor color;
//     public final int cost;
// 
//     public int compareTo(Item o) {
// 	if (quality != o.quality) {
// 	    return (o.quality - quality);
// 	}
// 	return id.compareTo(o.id);
//     }
// 
//     private static final Logger log = LoggerFactory.getLogger(Item.class);
// }


import org.styloot.hobo.*;
import org.styloot.hobo.Item;
import java.util.*;


public class HasFeaturesBenchmark {
    public static final int NUM_RUNS = 100000;
    public static final int FEATURES_PER_ITEM = 10;
    public static final int FEATURES_PER_QUERY = 4;

    private static Vector<String> randomFeatureSet(int numFeatures) {
	Vector<String> f = new Vector<String>();
	for (int j=0;j<numFeatures;j++) {
	    if (Math.random() > 0.5) {
		f.add("feature-" + j);
	    }
	}
	return f;
    }

// Path: src/org/styloot/hobo/Item.java
// public class Item implements Comparable<Item>{
//     public Item(String i, String c, Collection<String> f, int q, CIELabColor clr, int cst) {
// 	id = i; category = Category.getCategory(c); quality = q;
// 	features = Feature.getFeatures(f);
// 	color = clr;
// 	cost = cst;
//     }
// 
//     public Item(String i, String c, String[] f, int q, CIELabColor clr, int cst) {
// 	id = i; category = Category.getCategory(c); quality = q;
// 	features = Feature.getFeatures(f);
// 	color = clr;
// 	cost = cst;
//     }
// 
//     public Item(String i, String c, Vector<String> f, int q, CIELabColor clr, int cst) {
// 	this(i, c, f.toArray((String[])(new String[]{})), q, clr, cst);
//     }
// 
//     public boolean hasFeatures(Collection<String> feats) {
// 	log.warn("Calling item.hasFeatures(Collection<String> features) - will be inefficient.");
// 	if (feats == null) {
// 	    return true;
// 	}
// 	return hasFeatures(Feature.getFeatures(feats));
//     }
// 
//     public Feature[] getFeatures() {
// 	return features;
//     }
// 
//     public boolean hasFeature(Feature f) {
// 	for (Feature f2 : features) {
// 	    if (f == f2) {
// 		return true;
// 	    }
// 	}
// 	return false;
//     }
// 
//     public boolean hasFeatures(Feature[] feats) {
// 	if (feats == null) {
// 	    return true;
// 	}
// 	if (features == null && feats.length > 0) { //We definitely don't have the feature
// 	    return false;
// 	}
// 	for (Feature f : feats) {
// 	    if (!hasFeature(f)) {
// 		return false;
// 	    }
// 	}
// 	return true;
//     }
// 
//     public boolean hasFeaturesSorted(Feature[] feats) {
// 	return Util.isSubsetSorted(feats, features);
//     }
// 
//     public double colorDist2From(CIELabColor other) {
// 	return other.distance2To(color);
//     }
// 
//     public CIELabColor getColor() {
// 	return color;
//     }
// 
//     public final String id;
//     public final Category category;
//     public final Feature[] features;
//     public final int quality;
//     public final CIELabColor color;
//     public final int cost;
// 
//     public int compareTo(Item o) {
// 	if (quality != o.quality) {
// 	    return (o.quality - quality);
// 	}
// 	return id.compareTo(o.id);
//     }
// 
//     private static final Logger log = LoggerFactory.getLogger(Item.class);
// }


// Path: benchmarks/HasFeaturesBenchmark.java
import org.styloot.hobo.*;
import org.styloot.hobo.Item;
import java.util.*;



public class HasFeaturesBenchmark {
    public static final int NUM_RUNS = 100000;
    public static final int FEATURES_PER_ITEM = 10;
    public static final int FEATURES_PER_QUERY = 4;

    private static Vector<String> randomFeatureSet(int numFeatures) {
	Vector<String> f = new Vector<String>();
	for (int j=0;j<numFeatures;j++) {
	    if (Math.random() > 0.5) {
		f.add("feature-" + j);
	    }
	}
	return f;
    }

    private static Item[] getItems(int numItems) {