private void relabelToFront() { assert (!V.isEmpty()) : "No vertices"; ListIterator<Vertex> iter = V.listIterator(); while (iter.hasNext()) { Vertex v = iter.next(); // System.out.println("Considering vertex: " + v); int oldHeight = v.getHeight(); discharge(v); if (v.getHeight() > oldHeight) { iter.remove(); V.addFirst(v); iter = V.listIterator(1); } } }
public String hasSameContent(JarFile2 file, JarEntry entry) throws IOException { String thisName = null; Long crcL = new Long(entry.getCrc()); // check if this jar contains files with the passed in entry's crc if (_crcToEntryMap.containsKey(crcL)) { // get the Linked List with files with the crc LinkedList ll = (LinkedList) _crcToEntryMap.get(crcL); // go through the list and check for content match ListIterator li = ll.listIterator(0); if (li != null) { while (li.hasNext()) { JarEntry thisEntry = (JarEntry) li.next(); // check for content match InputStream oldIS = getJarFile().getInputStream(thisEntry); InputStream newIS = file.getJarFile().getInputStream(entry); if (!differs(oldIS, newIS)) { thisName = thisEntry.getName(); return thisName; } } } } return thisName; }
public static void maxFlow(ListGraph g) { ListGraph residualG = g.residualGraph(); LinkedList<DirEdge> path = residualG.getFlowPath(); while (path != null) { // System.out.println("Got path"); int minCapacity = ListGraph.minCapacityInPath(path); assert minCapacity > 0; // augment every edge on the path in the original graph int head = g.getSource(); ListIterator it = path.listIterator(); while (it.hasNext()) { DirEdge rEdge = (DirEdge) it.next(); int tail = rEdge.end; DirEdge e = g.getEdge(head, tail); e.flow += minCapacity; // System.out.println("Augmenting (" + head + "," + tail + ") to be " + e.flow); head = tail; } residualG = g.residualGraph(); // System.out.println("g:"); // g.print(); // System.out.println("Residual graph:"); // residualG.print(); path = residualG.getFlowPath(); } }
/** Sorts the static LinkedList mainlineLinks in the order they appear on the freeway */ private LinkedList<Link> recursiveLinkSort(LinkedList<Link> links2) { if (links2.size() == 1) { return links2; } else { boolean swapMade = false; ListIterator<Link> itr1 = links2.listIterator(); while (itr1.hasNext()) { Link temp = itr1.next(); int tempindex = itr1.nextIndex(); // if this loop makes any switches, set the flag to true if (links2.getFirst().getUpNode().getNodeID() == temp.getDownNode().getNodeID()) { swapMade = true; links2.addFirst(temp); links2.remove(tempindex); return this.recursiveLinkSort(links2); } } if (!swapMade) { // assign last n-1 links to links3 LinkedList<Link> links3 = new LinkedList<Link>(); Link temp = links2.getFirst(); links2.removeFirst(); links3 = this.recursiveLinkSort(links2); links3.addFirst(temp); return links3; } else { return links2; } } }
public static int minCapacityInPath(LinkedList<DirEdge> path) { int minCapacity = Integer.MAX_VALUE; ListIterator it = path.listIterator(); while (it.hasNext()) { DirEdge e = (DirEdge) it.next(); if (e.capacity < minCapacity) { minCapacity = e.capacity; } } return minCapacity; }
/** * Perform this job - start compilation. * * @param compiler The compiler to use. * @param arguments The compiler arguments to use. * @return The result. */ public CompileResult perform(String compiler, ArrayList<String> arguments) { Debug.trace("starting job " + this.name); // we have some maximum command line length - need to count int cmdline_len = 0; // used to collect the arguments for executing the compiler LinkedList<String> args = new LinkedList<String>(arguments); { for (String arg : args) { cmdline_len += (arg).length() + 1; } } boolean isEclipseCompiler = compiler.equalsIgnoreCase(ECLIPSE_COMPILER_NAME); // add compiler in front of arguments args.add(0, compiler); cmdline_len += compiler.length() + 1; // construct classpath argument for compiler // - collect all classpaths StringBuffer classpath_sb = new StringBuffer(); for (String cp : this.classpath) { if (classpath_sb.length() > 0) { classpath_sb.append(File.pathSeparatorChar); } classpath_sb.append(new File(cp).getAbsolutePath()); } String classpath_str = classpath_sb.toString(); // - add classpath argument to command line if (classpath_str.length() > 0) { args.add("-classpath"); cmdline_len += 11; args.add(classpath_str); cmdline_len += classpath_str.length() + 1; } // remember how many arguments we have which don't change for the // job int common_args_no = args.size(); // remember how long the common command line is int common_args_len = cmdline_len; // used for execution FileExecutor executor = new FileExecutor(); String output[] = new String[2]; // used for displaying the progress bar String jobfiles = ""; int fileno = 0; int last_fileno = 0; // now iterate over all files of this job for (File file : this.files) { String fpath = file.getAbsolutePath(); Debug.trace("processing " + fpath); // we add the file _first_ to the arguments to have a better // chance to get something done if the command line is almost // MAX_CMDLINE_SIZE or even above fileno++; jobfiles += file.getName() + " "; args.add(fpath); cmdline_len += fpath.length(); // start compilation if maximum command line length reached if (!isEclipseCompiler && cmdline_len >= MAX_CMDLINE_SIZE) { Debug.trace("compiling " + jobfiles); // display useful progress bar (avoid showing 100% while // still compiling a lot) this.listener.progress(last_fileno, jobfiles); last_fileno = fileno; int retval = runCompiler(executor, output, args); // update progress bar: compilation of fileno files done this.listener.progress(fileno, jobfiles); if (retval != 0) { CompileResult result = new CompileResult( this.langpack.getString("CompilePanel.error"), args, output[0], output[1]); this.listener.handleCompileError(result); if (!result.isContinue()) { return result; } } else { // verify that all files have been compiled successfully // I found that sometimes, no error code is returned // although compilation failed. Iterator<String> arg_it = args.listIterator(common_args_no); while (arg_it.hasNext()) { File java_file = new File(arg_it.next()); String basename = java_file.getName(); int dotpos = basename.lastIndexOf('.'); basename = basename.substring(0, dotpos) + ".class"; File class_file = new File(java_file.getParentFile(), basename); if (!class_file.exists()) { CompileResult result = new CompileResult( this.langpack.getString("CompilePanel.error.noclassfile") + java_file.getAbsolutePath(), args, output[0], output[1]); this.listener.handleCompileError(result); if (!result.isContinue()) { return result; } // don't continue any further break; } } } // clean command line: remove files we just compiled for (int i = args.size() - 1; i >= common_args_no; i--) { args.removeLast(); } cmdline_len = common_args_len; jobfiles = ""; } } if (cmdline_len > common_args_len) { this.listener.progress(last_fileno, jobfiles); int retval = runCompiler(executor, output, args); if (!isEclipseCompiler) { this.listener.progress(fileno, jobfiles); } if (retval != 0) { CompileResult result = new CompileResult( this.langpack.getString("CompilePanel.error"), args, output[0], output[1]); this.listener.handleCompileError(result); if (!result.isContinue()) { return result; } } else { // verify that all files have been compiled successfully // I found that sometimes, no error code is returned // although compilation failed. Iterator<String> arg_it = args.listIterator(common_args_no); while (arg_it.hasNext()) { File java_file = new File(arg_it.next()); String basename = java_file.getName(); int dotpos = basename.lastIndexOf('.'); basename = basename.substring(0, dotpos) + ".class"; File class_file = new File(java_file.getParentFile(), basename); if (!class_file.exists()) { CompileResult result = new CompileResult( this.langpack.getString("CompilePanel.error.noclassfile") + java_file.getAbsolutePath(), args, output[0], output[1]); this.listener.handleCompileError(result); if (!result.isContinue()) { return result; } // don't continue any further break; } } } } Debug.trace("job " + this.name + " done (" + fileno + " files compiled)"); return new CompileResult(); }
public void run() { System.err.println(); Date now = new Date(); if (!done) flout("INTERRUPTED\n"); flout("START: " + start + "\n"); flout("FINISH: " + now + "\n"); flout("N: " + n_files + "\n"); flout("Subject id: " + subject_id + "\n"); flout("Sample id: " + sample_id + "\n"); flout("total files: " + total_files + "\n"); flout("total bytes: " + total_bytes + "\n"); flout("retrieve failures: " + retrieve_failures + "\n"); flout("metadata retrieve failures: " + md_retrieve_failures + "\n"); flout("bad files retrieved: " + bad_file_errors + "\n"); flout("bad metadata retrieved: " + bad_md_errors + "\n"); reportExceptions(); flout("store retries: " + store_retries + "\n"); flout("retrieve retries: " + retrieve_retries + "\n"); flout("md retrieve retries: " + md_retrieve_retries + "\n"); if (md_retrieve_time > 0) flout("md retrieve rate (ms/record): " + (md_retrieve_time / md_retrieves) + "\n"); if (total_store_time > 0) flout("total store rate (bytes/sec): " + ((total_bytes * 1000) / total_store_time) + "\n"); if (total_retrieve_time > 0) flout( "total retrieve rate (bytes/sec): " + ((total_bytes * 1000) / total_retrieve_time) + "\n"); if (time_store_30M > 0) flout("30 MB store (bytes/sec): " + (1000 * bytes_30M / time_store_30M) + "\n"); if (time_retrv_30M > 0) flout("30 MB retrieve (bytes/sec): " + (1000 * bytes_30M / time_retrv_30M) + "\n"); if (time_store_3M > 0) flout("3 MB store (bytes/sec): " + (1000 * bytes_30M / time_store_3M) + "\n"); if (time_retrv_3M > 0) flout("3 MB retrieve (bytes/sec): " + (1000 * bytes_3M / time_retrv_3M) + "\n"); if (time_store_300K > 0) flout("300 KB store (bytes/sec): " + (1000 * bytes_300K / time_store_300K) + "\n"); if (time_retrv_300K > 0) flout("300 KB retrieve (bytes/sec): " + (1000 * bytes_300K / time_retrv_300K) + "\n"); if (update) { flout("update oid query retries: " + query_retries + "\n"); flout("update retries: " + update_retries + "\n"); if (oid_query_time > 0) flout("query-oid's time (ms): " + oid_query_time + "\n"); if (update_time > 0) flout("update time (ms/record): " + (update_time / updates) + "\n"); if (updating && updates != n_files * 3) flout("files saved: " + (n_files * 3) + " updates: " + updates + "\n"); } if (failed_rtrv.size() > 0) { ListIterator li = failed_rtrv.listIterator(0); while (li.hasNext()) flout("lost data: " + (String) li.next() + "\n"); } if (failed_md_rtrv.size() > 0) { ListIterator li = failed_md_rtrv.listIterator(0); while (li.hasNext()) flout("lost mdata: " + (String) li.next() + "\n"); } // long deltat = now.getTime() - start.getTime(); // if (deltat > 0) // flout("total thruput (bytes/sec rdwr): " + // (2000 * total_bytes / deltat) + "\n"); try { new File(lastfile).delete(); } catch (Exception e) { } }