List of usage examples for java.util Map putAll
void putAll(Map<? extends K, ? extends V> m);
From source file:gpframework.RunExperiment.java
/** * Application's entry point.//from w ww. j ava 2 s. com * * @param args * @throws ParseException * @throws ParameterException */ public static void main(String[] args) throws ParseException, ParameterException { // Failsafe parameters if (args.length == 0) { args = new String[] { "-f", "LasSortednessFunction", "-n", "5", "-ff", "JoinFactory", "-tf", "SortingElementFactory", "-pf", "SortingProgramFactory", "-s", "SMOGPSelection", "-a", "SMOGP", "-t", "50", "-e", "1000000000", "-mf", "SingleMutationFactory", "-d", "-bn", "other" }; } // Create options Options options = new Options(); setupOptions(options); // Read options from the command line CommandLineParser parser = new PosixParser(); CommandLine cmd; // Print help if parameter requirements are not met try { cmd = parser.parse(options, args); } // If some parameters are missing, print help catch (MissingOptionException e) { HelpFormatter hf = new HelpFormatter(); hf.printHelp("java -jar GPFramework \n", options); System.out.println(); System.out.println("Missing parameters: " + e.getMissingOptions()); return; } // Re-initialize PRNG long seed = System.currentTimeMillis(); Utils.random = new Random(seed); // Set the problem size int problemSize = Integer.parseInt(cmd.getOptionValue("n")); // Set debug mode and cluster mode Utils.debug = cmd.hasOption("d"); RunExperiment.cluster = cmd.hasOption("c"); // Initialize fitness function and some factories FitnessFunction fitnessFunction = fromName(cmd.getOptionValue("f"), problemSize); MutationFactory mutationFactory = fromName(cmd.getOptionValue("mf")); Selection selectionCriterion = fromName(cmd.getOptionValue("s")); FunctionFactory functionFactory = fromName(cmd.getOptionValue("ff")); TerminalFactory terminalFactory = fromName(cmd.getOptionValue("tf"), problemSize); ProgramFactory programFactory = fromName(cmd.getOptionValue("pf"), functionFactory, terminalFactory); // Initialize algorithm Algorithm algorithm = fromName(cmd.getOptionValue("a"), mutationFactory, selectionCriterion); algorithm.setParameter("evaluationsBudget", cmd.getOptionValue("e")); algorithm.setParameter("timeBudget", cmd.getOptionValue("t")); // Initialize problem Problem problem = new Problem(programFactory, fitnessFunction); Program solution = algorithm.solve(problem); Utils.debug("Population results: "); Utils.debug(algorithm.getPopulation().toString()); Utils.debug(algorithm.getPopulation().parse()); Map<String, Object> entry = new HashMap<String, Object>(); // Copy algorithm setup for (Object o : options.getRequiredOptions()) { Option option = options.getOption(o.toString()); entry.put(option.getLongOpt(), cmd.getOptionValue(option.getOpt())); } entry.put("seed", seed); // Copy results entry.put("bestProgram", solution.toString()); entry.put("bestSolution", fitnessFunction.normalize(solution)); // Copy all statistics entry.putAll(algorithm.getStatistics()); Utils.debug("Maximum encountered population size: " + algorithm.getStatistics().get("maxPopulationSizeToCompleteFront")); Utils.debug("Maximum encountered tree size: " + algorithm.getStatistics().get("maxProgramComplexityToCompleteFront")); Utils.debug("Solution complexity: " + solution.complexity() + "/" + (2 * problemSize - 1)); }
From source file:gov.jgi.meta.hadoop.input.FastaBlockLineReader.java
public static void main(String[] args) { int num = 1;// w w w .j a v a2 s .co m int last = -1; do { try { FileInputStream fstream = new FileInputStream("/scratch/karan/30mb.fas"); FastaBlockLineReader fblr = new FastaBlockLineReader(fstream); Text key = new Text(); Map<String, String> setofreads = new HashMap<String, String>(); Map<String, String> setofreadsTotal = new HashMap<String, String>(); int length = (int) (Math.random() * 10000); length = 3000000; System.out.println("lenght = " + length); int total = 0; fblr.readLine(key, setofreads, Integer.MAX_VALUE, length); // System.out.println("setofreads.size = " + setofreads.size()); total += setofreads.size(); //for (String s : setofreads.keySet()) { // System.out.println(s); // } Runtime r = Runtime.getRuntime(); while (setofreads.size() > 0) { setofreadsTotal.putAll(setofreads); setofreads.clear(); fblr.readLine(key, setofreads, Integer.MAX_VALUE, length); // System.out.println("setofreads.size = " + setofreads.size()); total += setofreads.size(); r.gc(); } System.out.println("total = " + total); System.out.println("heap size = " + r.totalMemory() / 1048576); if (last != -1) { if (last != total) { System.out.println( "error!!!, length = " + length + ": last = " + last + " current = " + total); } } last = total; } catch (Exception e) { System.out.println(e); } } while (num-- > 0); }
From source file:Main.java
public static <K, V> Map<K, V> mergedMap(Map<K, ? extends V> base, Map<K, ? extends V> overrides) { Map<K, V> map = new HashMap<>(); map.putAll(base); map.putAll(overrides);// w w w.j ava 2s .c o m return map; }
From source file:Main.java
public static <K, V> Map<K, V> join(Map<? extends K, ? extends V> first, Map<? extends K, ? extends V> second, Map<K, V> destination) { destination.putAll(first); destination.putAll(second);// w w w . ja v a2 s . c o m return destination; }
From source file:Main.java
/** * Clones a map.//from w ww . j ava 2s .co m * * @param source the source map * @return the clone of the source map */ public static Map copy(Map source) { if (source == null) { return null; } Map result = new HashMap(); result.putAll(source); return result; }
From source file:Main.java
public static <K, V> Map<K, V> unicon(Map<K, V> map1, Map<K, V> map2) { Map<K, V> map = new HashMap<>(); map.putAll(map1); map.putAll(map2);/*from www. j a v a2 s . c o m*/ return map; }
From source file:Main.java
public final static <K, V> Map<K, V> unicon(Map<K, V> map1, Map<K, V> map2) { Map<K, V> map = new HashMap<>(map1.size() + map2.size()); map.putAll(map1); map.putAll(map2);/*from w w w. j a v a 2 s .co m*/ return map; }
From source file:Main.java
public static Map putAll(Map original, Map... others) { for (Map other : others) { original.putAll(other); }// w w w.j a v a 2 s. c om return original; }
From source file:com.homeadvisor.kafdrop.config.ini.IniFilePropertySource.java
private static Map<String, Object> loadPropertiesForIniFile(IniFileProperties iniProperties, String[] activeProfiles) { final Map<String, Object> properties = Maps.newLinkedHashMap(); properties.putAll(iniProperties.getDefaultProperties()); if (activeProfiles != null && activeProfiles.length > 0) { for (String profile : activeProfiles) { final Map<String, String> sectionProperties = iniProperties.getSectionProperties(profile); if (sectionProperties != null) { properties.putAll(sectionProperties); }/*from w ww .j a v a2s . c o m*/ } } return properties; }
From source file:Main.java
/** *//*from w ww. j ava 2 s .c o m*/ public static ArrayList<Element> mergeByAttrib(ArrayList<Element> master, ArrayList<Element> slave, String attrib) throws Exception { Map<String, Element> masterMap = mapFromArrayListByAttribute(master, attrib); Map<String, Element> slaveMap = mapFromArrayListByAttribute(slave, attrib); slaveMap.putAll(masterMap); ArrayList<Element> res = new ArrayList<Element>(); Collection<Element> collection = slaveMap.values(); for (Element e : collection) { res.add(e); } return res; }