ZipEntryRO[] getEntriesAt(String path) { Vector<ZipEntryRO> zev = new Vector<ZipEntryRO>(); Collection<ZipEntryRO> values = mHashMap.values(); if (null == path) path = ""; int length = path.length(); for (ZipEntryRO ze : values) { if (ze.mFileName.startsWith(path)) { if (-1 == ze.mFileName.indexOf('/', length)) { zev.add(ze); } } } ZipEntryRO[] entries = new ZipEntryRO[zev.size()]; return zev.toArray(entries); }
public SortedKeyEnumeration(Hashtable ht) { Enumeration f = ht.keys(); Vector keys = new Vector(ht.size()); for (int i, last = 0; f.hasMoreElements(); ++last) { String key = (String) f.nextElement(); for (i = 0; i < last; ++i) { String s = (String) keys.get(i); if (key.compareTo(s) <= 0) break; } keys.add(i, key); } e = keys.elements(); }
final Vector<Double> vector = new Vector<Double>(); vector.add(1.0); vector.add(2.0); // Not thread safe! If another thread modifies "vector" during the loop, then // a ConcurrentModificationException will be thrown. for (Double num : vector) { System.out.println(num); } // You can try this as a quick fix, but it might not be what you want: synchronized (vector) { // "vector" must be final for (Double num : vector) { System.out.println(num); } }
/** * Returns a collection of decimals based on the given collection but with the doubles formatted * according to the pattern. String values are ignored. */ public static Vector formatDecimal(Collection c, String pattern) { DecimalFormat f = new DecimalFormat(pattern); Vector v = new Vector(); for (Iterator i = c.iterator(); i.hasNext();) { Object o = i.next(); if (o instanceof Double) v.add(f.format(o)); else v.add(o); } return v; }
@SuppressWarnings("fallthrough") private static void generateMetricsTables() { Vector<String> columns = new Vector<String>(); columns.add(text); System.out.println("Exception while reading from metricList" + metricListFileName); System.exit(1); Vector<String> allMetrics = new Vector<String>(); allMetrics.add(text); System.out.println("Exception while reading from metricList" + metricListFileName); System.exit(1); if (CSV) { newClassName += ".csv"; System.out.println("Creating csv file" + newClassName + " from metrics info"); } else { newClassName += ".tex"; while (it.hasNext()) { String fileName = it.next(); if (fileName.indexOf('-') < 0) { while (keys.hasNext()) {
public static Vector findConnectedComponents(final Collection nodes, final Collection edges) { Vector components = new Vector(); Vector nodesVisited = new Vector(); Iterator nodesIt = nodes.iterator(); while (nodesIt.hasNext()) { Node next = (Node) nodesIt.next(); if (!(nodesVisited.contains(next))) { Vector componentNodes = new Vector(); Vector componentEdges = new Vector(); expandComponent(next, edges, componentNodes, componentEdges); nodesVisited.addAll(componentNodes); Graph component = new BasicGraph(componentNodes, componentEdges); components.add(component); } } return components; }
System.out.println( String.format("WARNING: %s is not a directory. Defaulting to current directory %s.", new Object[] {workdir, curDir})); if (trace != null && trace.length() > 0) { for (int i = 0; i < cmdarray.length; i++) { System.out.println("cmdarray[" + i + "] = " + cmdarray[i]); System.out.println("workdir=" + workdir.getPath()); System.out.println("logfile=" + logfile.getPath()); cmdVec.add("cmd.exe"); cmdVec.add("/c"); sb.append("start /b \"\" "); } else { cmdVec.add("bash"); cmdVec.add("--norc"); cmdVec.add("-c"); } else { cmdVec.add(commandShell); sb.append(" </dev/null &"); cmdVec.add(sb.toString());
private static String[] split(String input, char sep, int limit) { Vector v = new Vector(); boolean limited = (limit > 0); int applied = 0; else { ++applied; v.add(part.toString()); part = new StringBuffer(); ++index; v.add(part.toString()); int last = v.size(); if (0 == limit) { for (int j = v.size() - 1; j >= 0; --j) { String s = (String) v.elementAt(j); if ("".equals(s))
/** * Attempt to register any unregistered extension namespaces. */ public void registerUnregisteredNamespaces() { for (int i = 0; i < m_unregisteredExtensions.size(); i++) { String ns = (String)m_unregisteredExtensions.get(i); ExtensionNamespaceSupport extNsSpt = defineJavaNamespace(ns); if (extNsSpt != null) m_extensions.add(extNsSpt); } }
/** * @param allInOneLine * allInOneLine * @return result.toArray(new String[0]) * @deprecated Unstable due to platform-specific behavior. Use {@link org.apache.commons.lang.StringUtils#split} or similar * instead. */ @Deprecated public static String[] toStringArray(String allInOneLine) { if (allInOneLine != "") { Vector<String> result = new Vector<String>(); StringTokenizer s = new StringTokenizer(allInOneLine, System.getProperty("line.separator")); String line = null; // Read until either end of file or an empty line while (s.hasMoreTokens() && ((line = s.nextToken()) != null) && (!line.equals(""))) result.add(line); return result.toArray(new String[0]); } else return null; }
/** * If necessary, register the extension namespace found compiling a function or * creating an extension element. * * If it is a predefined namespace, create a * support object to simplify the instantiate of an appropriate ExtensionHandler * during transformation runtime. Otherwise, add the namespace, if necessary, * to a vector of undefined extension namespaces, to be defined later. * */ public void registerExtension(String namespace) { if (namespaceIndex(namespace, m_extensions) == -1) { int predef = namespaceIndex(namespace, m_predefExtensions); if (predef !=-1) m_extensions.add(m_predefExtensions.get(predef)); else if (!(m_unregisteredExtensions.contains(namespace))) m_unregisteredExtensions.add(namespace); } }
ZipEntryRO[] getEntriesAt(String path) { Vector<ZipEntryRO> zev = new Vector<ZipEntryRO>(); Collection<ZipEntryRO> values = mHashMap.values(); if (null == path) path = ""; int length = path.length(); for (ZipEntryRO ze : values) { if (ze.mFileName.startsWith(path)) { if (-1 == ze.mFileName.indexOf('/', length)) { zev.add(ze); } } } ZipEntryRO[] entries = new ZipEntryRO[zev.size()]; return zev.toArray(entries); }
public static void main(String[] args) { if (args.length != 3) { System.out.println("Please specify a threadcount, columnfamily and operation count"); System.exit(0); Vector<Thread> allthreads = new Vector<>(); long st = System.currentTimeMillis(); Status result; Vector<HashMap<String, ByteIterator>> scanResults = new Vector<>(); Set<String> scanFields = new HashSet<String>(); result = cli.scan("table1", "user2", 20, null, scanResults); allthreads.add(t); t.join(); } catch (InterruptedException ignored) { System.err.println("interrupted"); Thread.currentThread().interrupt(); System.out.println("Throughput: " + ((1000.0) * (((double) (opcount * threadcount)) / ((double) (en - st)))) + " ops/sec");
/** * Returns a collection of strings based on the given collection but with all strings padded on * the right to the length of the longest one. */ public static Vector padRight(Collection strings) { Vector v = new Vector(); int length = maxLength(strings); for (Iterator i = strings.iterator(); i.hasNext();) { String string = (String) i.next(); v.add(padRight(string, length)); } return v; }
Collection nodes = incoming.getNodes(); Iterator nodeIt = nodes.iterator(); Vector clusterNodes = new Vector(); Vector clusterEdges = new Vector(); while (nodeIt.hasNext()) { DelaunayNode next = (DelaunayNode) nodeIt.next(); SimpleFeature nextFeature = next.getFeature(); double totalTarget = ((Number) targetObj).doubleValue(); Collection newEdges = new Vector(); Vector newNodes = new Vector(); newNodes.add(next); Vector removals = new Vector(); while (edgeIt.hasNext()) { DelaunayEdge nextEdge = (DelaunayEdge) edgeIt.next(); if (nextEdge.getEuclideanDistance() > 30) { removals.add(nextEdge); } else { DelaunayNode neighbor = (DelaunayNode) nextEdge.getOtherNode(next); newNodes.add(neighbor); nodesToAdd.add(farNode); edgesToAdd.add(nextEdge);
public static double getSortedValue(double[] x, double percentSmallerThan) { int retInd = -1; Vector<Double> v = new Vector<Double>(); for (int i = 0; i < x.length; i++) v.add(x[i]); Collections.sort(v); int index = (int) Math.floor(percentSmallerThan / 100.0 * (x.length - 1) + 0.5); index = Math.max(0, index); index = Math.min(index, x.length - 1); return ((Double) (v.get(index))).doubleValue(); }
/** * @return key declarations for the key associated to this KeyTable */ private Vector getKeyDeclarations() { int nDeclarations = m_keyDeclarations.size(); Vector keyDecls = new Vector(nDeclarations); // Walk through each of the declarations made with xsl:key for (int i = 0; i < nDeclarations; i++) { KeyDeclaration kd = (KeyDeclaration) m_keyDeclarations.elementAt(i); // Add the declaration if the name on this key declaration // matches the name on the iterator for this walker. if (kd.getName().equals(getKeyTableName())) { keyDecls.add(kd); } } return keyDecls; }