Skip to content

Instantly share code, notes, and snippets.

Created March 3, 2016 11:11
Show Gist options
  • Save anonymous/3b45c0c3b25d75519d26 to your computer and use it in GitHub Desktop.
Save anonymous/3b45c0c3b25d75519d26 to your computer and use it in GitHub Desktop.
package stackoverflow;
import java.util.*;
public class AllOptions {
private static final List<Option> options = new ArrayList<>();
private static int counter;
public static void main(String... args) {
Map<String, String> src = new HashMap<>();
src.put("Has GPS – based Lat/Long", "Yes, No");
src.put("Ad Size", "320x480, 300x250");
src.put("Integration", "Direct, Indirect");
src.put("Vdo Ad Formats", "Max, Min, Med");
src.put("App/Mobile Targeting", "Mobile Web, App");
for (Map.Entry<String, String> srcEntry : src.entrySet()) {
Option option = new Option(srcEntry.getKey());
options.add(option);
for (String val : srcEntry.getValue().split(",")) {
option.possibleValues.add(val);
}
}
counter = 0;
next(new String[options.size()], 0);
}
private static void next(String[] buffer, int currentIndex) {
if (currentIndex == options.size()) {
counter++;
System.out.println("===============================");
System.out.println("Counter: " + counter);
for (int i = 0; i < buffer.length; i++) {
System.out.println(options.get(i).name + ": " + buffer[i]);
}
} else {
for (String val : options.get(currentIndex).possibleValues) {
buffer[currentIndex] = val;
next(buffer, currentIndex + 1);
}
}
}
public static class Option {
public final String name;
public final List<String> possibleValues = new ArrayList<>();
public Option(String name) {
this.name = name;
}
}
}
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment