private Iterator<Feature> adjust( final Set<Feature> set, THashSet exclude, TObjectDoubleHashMap include) { // like set.removeAll(exclude) but faster exclude.forEach( new TObjectProcedure() { @Override public boolean execute(Object o) { set.remove(o); return true; // indicates it's ok to invoke this procedure again } }); if (include != null) { // like set.addAll( include ) but faster include.forEachKey( new TObjectProcedure() { @Override public boolean execute(Object key) { set.add((Feature) key); return true; // indicates it's ok to invoke this procedure again } }); } return set.iterator(); }
/** Analogous to binaryFeatureSet */ private Set<Feature> featureSet(int start, int end, Instance otherInstance) { Set<Feature> s = new HashSet<Feature>(); s.addAll(binaryFeatureSet(start, end, otherInstance)); s.addAll(numericFeatureSet(start, end, otherInstance)); return s; }
private void addAll(Set<Feature> s, Iterator<Feature> i) { while (i.hasNext()) s.add(i.next()); }