/** * Given a set of features, add to it all the features directly or indirectly implied by any of * them, and return it. * * @param features the set of features to expand * @return the same set of features, expanded with all implied features */ public static Set<Feature<?>> addImpliedFeatures(Set<Feature<?>> features) { Queue<Feature<?>> queue = new ArrayDeque<>(features); while (!queue.isEmpty()) { Feature<?> feature = queue.remove(); for (Feature<?> implied : feature.getImpliedFeatures()) { if (features.add(implied)) { queue.add(implied); } } } return features; }
/** * Given a set of features, return a new set of all features directly or indirectly implied by any * of them. * * @param features the set of features whose implications to find * @return the implied set of features */ public static Set<Feature<?>> impliedFeatures(Set<Feature<?>> features) { Set<Feature<?>> impliedSet = new LinkedHashSet<>(); Queue<Feature<?>> queue = new ArrayDeque<>(features); while (!queue.isEmpty()) { Feature<?> feature = queue.remove(); for (Feature<?> implied : feature.getImpliedFeatures()) { if (!features.contains(implied) && impliedSet.add(implied)) { queue.add(implied); } } } return impliedSet; }
/** * Given a set of features, return a new set of all features directly or * indirectly implied by any of them. * @param features the set of features whose implications to find * @return the implied set of features */ public static Set<Feature<?>> impliedFeatures(Set<Feature<?>> features) { Set<Feature<?>> implied = new LinkedHashSet<Feature<?>>(); for (Feature<?> feature : features) { implied.addAll(feature.getImpliedFeatures()); } addImpliedFeatures(implied); return implied; }
/** * Given a set of features, add to it all the features directly or indirectly implied by any of * them, and return it. * * @param features the set of features to expand * @return the same set of features, expanded with all implied features */ public static Set<Feature<?>> addImpliedFeatures(Set<Feature<?>> features) { Queue<Feature<?>> queue = new ArrayDeque<>(features); while (!queue.isEmpty()) { Feature<?> feature = queue.remove(); for (Feature<?> implied : feature.getImpliedFeatures()) { if (features.add(implied)) { queue.add(implied); } } } return features; }
/** * Given a set of features, return a new set of all features directly or indirectly implied by any * of them. * * @param features the set of features whose implications to find * @return the implied set of features */ public static Set<Feature<?>> impliedFeatures(Set<Feature<?>> features) { Set<Feature<?>> impliedSet = new LinkedHashSet<>(); Queue<Feature<?>> queue = new ArrayDeque<>(features); while (!queue.isEmpty()) { Feature<?> feature = queue.remove(); for (Feature<?> implied : feature.getImpliedFeatures()) { if (!features.contains(implied) && impliedSet.add(implied)) { queue.add(implied); } } } return impliedSet; }