本文整理了Java中java.util.Vector.add()
方法的一些代码示例,展示了Vector.add()
的具体用法。这些代码示例主要来源于Github
/Stackoverflow
/Maven
等平台,是从一些精选项目中提取出来的代码,具有较强的参考意义,能在一定程度帮忙到你。Vector.add()
方法的具体详情如下:
包路径:java.util.Vector
类名称:Vector
方法名:add
[英]Adds the specified object into this vector at the specified location. The object is inserted before any element with the same or a higher index increasing their index by 1. If the location is equal to the size of this vector, the object is added at the end.
[中]在指定位置将指定对象添加到此向量中。将对象插入到具有相同或更高索引的任何元素之前,并将其索引增加1。如果位置等于该向量的大小,则对象将添加到末尾。
代码示例来源:origin: log4j/log4j
protected Vector getColumnNameAndNumber() {
Vector columnNameAndNumber = new Vector();
for (int i = 0; i < _colNames.length; i++) {
columnNameAndNumber.add(i, _colNames[i]);
}
return columnNameAndNumber;
}
代码示例来源:origin: libgdx/libgdx
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);
}
代码示例来源:origin: log4j/log4j
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();
}
代码示例来源:origin: stackoverflow.com
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);
}
}
代码示例来源:origin: apache/geode
/**
* 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;
}
代码示例来源:origin: Sable/soot
@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()) {
代码示例来源:origin: geotools/geotools
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;
}
代码示例来源:origin: apache/geode
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());
代码示例来源:origin: org.osgi/org.osgi.compendium
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))
代码示例来源:origin: robovm/robovm
/**
* 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);
}
}
代码示例来源:origin: marytts/marytts
/**
* @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;
}
代码示例来源:origin: alibaba/TProfiler
/**
* 占位并生成方法ID
*
* @return
*/
public synchronized static int Request() {
mCacheMethods.add(new MethodInfo());
return mCacheMethods.size() - 1;
}
代码示例来源:origin: robovm/robovm
/**
* 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);
}
}
代码示例来源:origin: libgdx/libgdx
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);
}
代码示例来源:origin: brianfrankcooper/YCSB
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");
代码示例来源:origin: apache/geode
/**
* 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;
}
代码示例来源:origin: geotools/geotools
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);
代码示例来源:origin: gocd/gocd
/**
* Go back to the hardwired default exclude patterns.
*
* @since Ant 1.6
*/
public static void resetDefaultExcludes() {
defaultExcludes = new Vector();
for (int i = 0; i < DEFAULTEXCLUDES.length; i++) {
defaultExcludes.add(DEFAULTEXCLUDES[i]);
}
}
代码示例来源:origin: marytts/marytts
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();
}
代码示例来源:origin: robovm/robovm
/**
* @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;
}
内容来源于网络,如有侵权,请联系作者删除!