java.util.Vector#add ( )源码实例Demo

下面列出了java.util.Vector#add ( ) 实例代码,或者点击链接到github查看源代码,也可以在右侧发表评论。

源代码1 项目: jdk1.8-source-analysis   文件: JFileChooser.java
/**
 * Sets the current file filter. The file filter is used by the
 * file chooser to filter out files from the user's view.
 *
 * @beaninfo
 *   preferred: true
 *       bound: true
 * description: Sets the File Filter used to filter out files of type.
 *
 * @param filter the new current file filter to use
 * @see #getFileFilter
 */
public void setFileFilter(FileFilter filter) {
    FileFilter oldValue = fileFilter;
    fileFilter = filter;
    if (filter != null) {
        if (isMultiSelectionEnabled() && selectedFiles != null && selectedFiles.length > 0) {
            Vector<File> fList = new Vector<File>();
            boolean failed = false;
            for (File file : selectedFiles) {
                if (filter.accept(file)) {
                    fList.add(file);
                } else {
                    failed = true;
                }
            }
            if (failed) {
                setSelectedFiles((fList.size() == 0) ? null : fList.toArray(new File[fList.size()]));
            }
        } else if (selectedFile != null && !filter.accept(selectedFile)) {
            setSelectedFile(null);
        }
    }
    firePropertyChange(FILE_FILTER_CHANGED_PROPERTY, oldValue, fileFilter);
}
 
源代码2 项目: sakai   文件: StringUtil.java
/**
 * Split the source into two strings at the first occurrence of the splitter Subsequent occurrences are not treated specially, and may be part of the second string.
 * 
 * @param source
 *        The string to split
 * @param splitter
 *        The string that forms the boundary between the two strings returned.
 * @return An array of two strings split from source by splitter.
 */
public static String[] splitFirst(String source, String splitter)
{
	// hold the results as we find them
	Vector rv = new Vector();
	int last = 0;
	int next = 0;

	// find first splitter in source
	next = source.indexOf(splitter, last);
	if (next != -1)
	{
		// isolate from last thru before next
		rv.add(source.substring(last, next));
		last = next + splitter.length();
	}

	if (last < source.length())
	{
		rv.add(source.substring(last, source.length()));
	}

	// convert to array
	return (String[]) rv.toArray(new String[rv.size()]);
}
 
源代码3 项目: openjdk-jdk8u   文件: ExtensionDependency.java
private static File[] getExtFiles(File[] dirs) throws IOException {
    Vector<File> urls = new Vector<File>();
    for (int i = 0; i < dirs.length; i++) {
        String[] files = dirs[i].list(new JarFilter());
        if (files != null) {
            debug("getExtFiles files.length " + files.length);
            for (int j = 0; j < files.length; j++) {
                File f = new File(dirs[i], files[j]);
                urls.add(f);
                debug("getExtFiles f["+j+"] "+ f);
            }
        }
    }
    File[] ua = new File[urls.size()];
    urls.copyInto(ua);
    debug("getExtFiles ua.length " + ua.length);
    return ua;
}
 
源代码4 项目: j2objc   文件: VectorTest.java
public void testHasNextAfterRemoval() {
    Vector<String> strings = new Vector<>();
    strings.add("string1");
    Iterator<String> it = strings.iterator();
    it.next();
    it.remove();
    assertFalse(it.hasNext());

    strings = new Vector<>();
    strings.add("string1");
    strings.add("string2");
    it = strings.iterator();
    it.next();
    it.remove();
    assertTrue(it.hasNext());
    assertEquals("string2", it.next());
}
 
源代码5 项目: openjdk-jdk9   文件: Curve.java
public static void insertLine(Vector<Curve> curves,
                              double x0, double y0,
                              double x1, double y1)
{
    if (y0 < y1) {
        curves.add(new Order1(x0, y0,
                              x1, y1,
                              INCREASING));
    } else if (y0 > y1) {
        curves.add(new Order1(x1, y1,
                              x0, y0,
                              DECREASING));
    } else {
        // Do not add horizontal lines
    }
}
 
源代码6 项目: CupDnn   文件: FullConnectionLayer.java
@Override
public void forward() {
	// TODO Auto-generated method stub
	Blob input = mNetwork.getDatas().get(id-1);
	Blob output = mNetwork.getDatas().get(id);
	float[] inputData = input.getData();
	float[] outputData = output.getData();
	float[] wData = w.getData();
	float[] bData = b.getData();
	float[] zData = z.getData();
	z.fillValue(0);
	Vector<Task<Object>> workers = new Vector<Task<Object>>();
	int batch = mNetwork.getBatch();
	for(int n=0;n<batch;n++){
		workers.add(new Task<Object>(n) {
			@Override
		    public Object call() throws Exception {
				for(int os=0;os<outSize;os++){//�ж��ٸ��������ǰ����ж��ٸ���Ԫ
					//��ÿ����Ԫ��Ȩ�����
					for(int is=0;is<inSize;is++){
						//zData[n*output.get3DSize()+os] ��ʾһ�������еĵ�n���ĵ�os����Ԫ
						zData[n*outSize+os] += inputData[n*inSize+is]*wData[os*inSize+is];
					}
					//ƫִ
					zData[n*outSize+os] += bData[os];
					//�����
					if(activationFunc!=null){
						outputData[n*outSize+os] = activationFunc.active(zData[n*outSize+os]);
					}else {
						outputData[n*outSize+os] = zData[n*outSize+os];
					}
				}
				return null;
			}
		});
	}
	ThreadPoolManager.getInstance(mNetwork).dispatchTask(workers);
}
 
源代码7 项目: XPagesExtensionLibrary   文件: DataService.java
public Vector<String> atDbByName(String dbPath){
	String path1 = getRootDir();
	String concatPath = PathUtil.concat(path1, dbPath, '/');
	
	Vector<String> v = new Vector<String>();
	v.add(getHost());
	v.add(concatPath);
	return v;
}
 
源代码8 项目: AndroidRobot   文件: FileUtility.java
public static Vector<String> loadScriptsInFolder(String path){
	File fileScript = new File(path);
	Vector<String> vec = new Vector();
	File files[] = fileScript.listFiles();
	for(int i=0;i<files.length;i++){
		if(!files[i].isDirectory())
			vec.add(files[i].getAbsolutePath());
	}
	return vec;
}
 
源代码9 项目: jdk8u60   文件: XSDHandler.java
private void addRelatedAttribute(XSAttributeDeclaration decl, Vector componentList, String namespace, Map<String, Vector> dependencies) {
    if (decl.getScope() == XSConstants.SCOPE_GLOBAL) {
        if (!componentList.contains(decl)) {
            Vector importedNamespaces = findDependentNamespaces(namespace, dependencies);
            addNamespaceDependency(namespace, decl.getNamespace(), importedNamespaces);
            componentList.add(decl);
        }
    }
    else {
        expandRelatedAttributeComponents(decl, componentList, namespace, dependencies);
    }
}
 
源代码10 项目: openjdk-8   文件: LegalRegistryNames.java
/**
 * return a vector of valid legal RMI naming URLs.
 */
private static Vector getLegalForms() {
    String localHostAddress = null;
    String localHostName = null;

    // get the local host name and address
    try {
        localHostName = InetAddress.getLocalHost().getHostName();
        localHostAddress = InetAddress.getLocalHost().getHostAddress();
    } catch(UnknownHostException e) {
        TestLibrary.bomb("Test failed: unexpected exception", e);
    }

    Vector legalForms = new Vector();
    legalForms.add("///MyName");
    legalForms.add("//:" + Registry.REGISTRY_PORT + "/MyName");
    legalForms.add("//" + localHostAddress + "/MyName");
    legalForms.add("//" + localHostAddress + ":" +
                   Registry.REGISTRY_PORT + "/MyName");
    legalForms.add("//localhost/MyName");
    legalForms.add("//localhost:" + Registry.REGISTRY_PORT + "/MyName");
    legalForms.add("//" + localHostName + "/MyName");
    legalForms.add("//" + localHostName + ":" + Registry.REGISTRY_PORT +
                   "/MyName");
    legalForms.add("MyName");
    legalForms.add("/MyName");
    legalForms.add("rmi:///MyName");
    legalForms.add("rmi://:" + Registry.REGISTRY_PORT + "/MyName");
    legalForms.add("rmi://" + localHostAddress + "/MyName");
    legalForms.add("rmi://" + localHostAddress + ":" +
                   Registry.REGISTRY_PORT + "/MyName");
    legalForms.add("rmi://localhost/MyName");
    legalForms.add("rmi://localhost:" + Registry.REGISTRY_PORT + "/MyName");
    legalForms.add("rmi://" + localHostName + "/MyName");
    legalForms.add("rmi://" + localHostName + ":" +
                   Registry.REGISTRY_PORT + "/MyName");
    return legalForms;
}
 
源代码11 项目: mzmine2   文件: SimpleScan.java
/**
 * @return Returns scan datapoints over certain intensity
 */
public @Nonnull DataPoint[] getDataPointsOverIntensity(double intensity) {
  int index;
  Vector<DataPoint> points = new Vector<DataPoint>();

  for (index = 0; index < dataPoints.length; index++) {
    if (dataPoints[index].getIntensity() >= intensity)
      points.add(dataPoints[index]);
  }

  DataPoint pointsOverIntensity[] = points.toArray(new DataPoint[0]);

  return pointsOverIntensity;
}
 
源代码12 项目: WhereYouGo   文件: LocusMapDataProvider.java
public void addAll() {
    Vector<CartridgeFile> v = new Vector<>();
    v.add(MainActivity.cartridgeFile);
    addCartridges(v);
    addZones((Vector<Zone>) Engine.instance.cartridge.zones, DetailsActivity.et);
    if (DetailsActivity.et != null && !(DetailsActivity.et instanceof Zone))
        addOther(DetailsActivity.et, true);
}
 
源代码13 项目: jcurses   文件: Button.java
protected  Vector<InputChar> getShortCutsList() {
	if (getShortCut() == null) {
		return null;
	}
	Vector<InputChar> result = new Vector<InputChar>();
	result.add(getShortCut());
	return result;
}
 
源代码14 项目: yawl   文件: DOMUtil.java
public static void removeAllAttributes(Element element)
{
    Vector<String> names = new Vector<String>();

    int length = element.getAttributes().getLength();
    NamedNodeMap atts = element.getAttributes();

    for(int i = 0; i < length; names.add(atts.item(i).getLocalName()), i++);

    for(String name : names) element.removeAttribute(name);
}
 
private void initGenotypes(boolean permute, HashMap hashSamples, String[] cohorts) {

		datasetGenotypes = new ExpressionDataset(inputDir + "/Genotypes.binary", '\t', null, hashSamples);

		if (permute) {
			System.out.println("WARNING: PERMUTING GENOTYPE DATA!!!!");
			if (cohorts == null) {
				throw new RuntimeException("Cohorts must be specified for permuation. Can be a single cohort");
				//cohorts = new String[]{"LLDeep", "LLS", "RS", "CODAM"};
			}
			int[] permSampleIDs = new int[datasetGenotypes.nrSamples];
			for (int p = 0; p < cohorts.length; p++) {
				Vector vecSamples = new Vector();
				for (int s = 0; s < datasetGenotypes.nrSamples; s++) {
					//if (datasetGenotypes.sampleNames[s].startsWith(cohorts[p])) {
					vecSamples.add(s);
					//}
				}

				for (int s = 0; s < datasetGenotypes.nrSamples; s++) {
					//if (datasetGenotypes.sampleNames[s].startsWith(cohorts[p])) {
					int randomSample = ((Integer) vecSamples.remove((int) ((double) vecSamples.size() * Math.random()))).intValue();
					permSampleIDs[s] = randomSample;
					//}
				}
			}

			ExpressionDataset datasetGenotypes2 = new ExpressionDataset(datasetGenotypes.nrProbes, datasetGenotypes.nrSamples);
			datasetGenotypes2.probeNames = datasetGenotypes.probeNames;
			datasetGenotypes2.sampleNames = datasetGenotypes.sampleNames;
			datasetGenotypes2.recalculateHashMaps();
			for (int p = 0; p < datasetGenotypes2.nrProbes; p++) {
				for (int s = 0; s < datasetGenotypes2.nrSamples; s++) {
					datasetGenotypes2.rawData[p][s] = datasetGenotypes.rawData[p][permSampleIDs[s]];
				}
			}
			datasetGenotypes = datasetGenotypes2;
		}

	}
 
源代码16 项目: samoa   文件: Utils.java
/**
  * Breaks up the string, if wider than "columns" characters.
  *
  * @param s		the string to process
  * @param columns	the width in columns
  * @return		the processed string
  */
 public static String[] breakUp(String s, int columns) {
   Vector<String>	result;
   String		line;
   BreakIterator	boundary;
   int			boundaryStart;
   int			boundaryEnd;
   String		word;
   String		punctuation;
   int			i;
   String[]		lines;

   result      = new Vector<String>();
   punctuation = " .,;:!?'\"";
   lines       = s.split("\n");

   for (i = 0; i < lines.length; i++) {
     boundary      = BreakIterator.getWordInstance();
     boundary.setText(lines[i]);
     boundaryStart = boundary.first();
     boundaryEnd   = boundary.next();
     line          = "";

     while (boundaryEnd != BreakIterator.DONE) {
word = lines[i].substring(boundaryStart, boundaryEnd);
if (line.length() >= columns) {
  if (word.length() == 1) {
    if (punctuation.indexOf(word.charAt(0)) > -1) {
      line += word;
      word = "";
    }
  }
  result.add(line);
  line = "";
}
line          += word;
boundaryStart  = boundaryEnd;
boundaryEnd    = boundary.next();
     }
     if (line.length() > 0)
result.add(line);
   }

   return result.toArray(new String[result.size()]);
 }
 
源代码17 项目: megamek   文件: WeaponHandler.java
public int checkTerrain(int nDamage, Entity entityTarget,
        Vector<Report> vPhaseReport) {
    boolean isAboveWoods = ((entityTarget != null) && ((entityTarget
            .relHeight() >= 2) || (entityTarget.isAirborne())));
    if (game.getOptions().booleanOption(OptionsConstants.ADVCOMBAT_TACOPS_WOODS_COVER)
            && !isAboveWoods
            && (game.getBoard().getHex(entityTarget.getPosition())
                    .containsTerrain(Terrains.WOODS) || game.getBoard()
                    .getHex(entityTarget.getPosition())
                    .containsTerrain(Terrains.JUNGLE))
            && !(entityTarget.getSwarmAttackerId() == ae.getId())) {
        ITerrain woodHex = game.getBoard()
                .getHex(entityTarget.getPosition())
                .getTerrain(Terrains.WOODS);
        ITerrain jungleHex = game.getBoard()
                .getHex(entityTarget.getPosition())
                .getTerrain(Terrains.JUNGLE);
        int treeAbsorbs = 0;
        String hexType = "";
        if (woodHex != null) {
            treeAbsorbs = woodHex.getLevel() * 2;
            hexType = "wooded";
        } else if (jungleHex != null) {
            treeAbsorbs = jungleHex.getLevel() * 2;
            hexType = "jungle";
        }

        // Do not absorb more damage than the weapon can do.
        treeAbsorbs = Math.min(nDamage, treeAbsorbs);

        nDamage = Math.max(0, nDamage - treeAbsorbs);
        server.tryClearHex(entityTarget.getPosition(), treeAbsorbs,
                ae.getId());
        Report.addNewline(vPhaseReport);
        Report terrainReport = new Report(6427);
        terrainReport.subject = entityTarget.getId();
        terrainReport.add(hexType);
        terrainReport.add(treeAbsorbs);
        terrainReport.indent(2);
        terrainReport.newlines = 0;
        vPhaseReport.add(terrainReport);
    }
    return nDamage;
}
 
/** The SAX <code>endElement</code> method does nothing. */
public void endElement (String namespaceURI,
                        String localName,
                        String qName)
  throws SAXException {

  super.endElement(namespaceURI, localName, qName);

  // Check after popping the stack so we don't erroneously think we
  // are our own extension namespace...
  boolean inExtension = inExtensionNamespace();

  int entryType = -1;
  Vector entryArgs = new Vector();

  if (namespaceURI != null
      && (extendedNamespaceName.equals(namespaceURI))
      && !inExtension) {

    String popURI = (String) baseURIStack.pop();
    String baseURI = (String) baseURIStack.peek();

    if (!baseURI.equals(popURI)) {
      entryType = catalog.BASE;
      entryArgs.add(baseURI);

      debug.message(4, "(reset) xml:base", baseURI);

      try {
        CatalogEntry ce = new CatalogEntry(entryType, entryArgs);
        catalog.addEntry(ce);
      } catch (CatalogException cex) {
        if (cex.getExceptionType() == CatalogException.INVALID_ENTRY_TYPE) {
          debug.message(1, "Invalid catalog entry type", localName);
        } else if (cex.getExceptionType() == CatalogException.INVALID_ENTRY) {
          debug.message(1, "Invalid catalog entry (rbase)", localName);
        }
      }
    }
  }
}
 
源代码19 项目: JDKSourceCode1.8   文件: SetOfIntegerSyntax.java
/**
 * Accumulate the given range (lb .. ub) into the canonical array form
 * into the given vector of int[] objects.
 */
private static void accumulate(Vector ranges, int lb,int ub) {
    // Make sure range is non-null.
    if (lb <= ub) {
        // Stick range at the back of the vector.
        ranges.add(new int[] {lb, ub});

        // Work towards the front of the vector to integrate the new range
        // with the existing ranges.
        for (int j = ranges.size()-2; j >= 0; -- j) {
        // Get lower and upper bounds of the two ranges being compared.
            int[] rangea = (int[]) ranges.elementAt (j);
            int lba = rangea[0];
            int uba = rangea[1];
            int[] rangeb = (int[]) ranges.elementAt (j+1);
            int lbb = rangeb[0];
            int ubb = rangeb[1];

            /* If the two ranges overlap or are adjacent, coalesce them.
             * The two ranges overlap if the larger lower bound is less
             * than or equal to the smaller upper bound. The two ranges
             * are adjacent if the larger lower bound is one greater
             * than the smaller upper bound.
             */
            if (Math.max(lba, lbb) - Math.min(uba, ubb) <= 1) {
                // The coalesced range is from the smaller lower bound to
                // the larger upper bound.
                ranges.setElementAt(new int[]
                                       {Math.min(lba, lbb),
                                            Math.max(uba, ubb)}, j);
                ranges.remove (j+1);
            } else if (lba > lbb) {

                /* If the two ranges don't overlap and aren't adjacent but
                 * are out of order, swap them.
                 */
                ranges.setElementAt (rangeb, j);
                ranges.setElementAt (rangea, j+1);
            } else {
            /* If the two ranges don't overlap and aren't adjacent and
             * aren't out of order, we're done early.
             */
                break;
            }
        }
    }
}
 
源代码20 项目: openjdk-8   文件: Harness.java
/**
 * Create new benchmark harness with given configuration and reporter.
 * Throws ConfigFormatException if there was an error parsing the config
 * file.
 * <p>
 * <b>Config file syntax:</b>
 * <p>
 * '#' marks the beginning of a comment.  Blank lines are ignored.  All
 * other lines should adhere to the following format:
 * <pre>
 *     &lt;weight&gt; &lt;name&gt; &lt;class&gt; [&lt;args&gt;]
 * </pre>
 * &lt;weight&gt; is a floating point value which is multiplied times the
 * benchmark's execution time to determine its weighted score.  The
 * total score of the benchmark suite is the sum of all weighted scores
 * of its benchmarks.
 * <p>
 * &lt;name&gt; is a name used to identify the benchmark on the benchmark
 * report.  If the name contains whitespace, the quote character '"' should
 * be used as a delimiter.
 * <p>
 * &lt;class&gt; is the full name (including the package) of the class
 * containing the benchmark implementation.  This class must implement
 * bench.Benchmark.
 * <p>
 * [&lt;args&gt;] is a variable-length list of runtime arguments to pass to
 * the benchmark.  Arguments containing whitespace should use the quote
 * character '"' as a delimiter.
 * <p>
 * <b>Example:</b>
 * <pre>
 *      3.5 "My benchmark" bench.serial.Test first second "third arg"
 * </pre>
 */
public Harness(InputStream in) throws IOException, ConfigFormatException {
    Vector bvec = new Vector();
    StreamTokenizer tokens = new StreamTokenizer(new InputStreamReader(in));

    tokens.resetSyntax();
    tokens.wordChars(0, 255);
    tokens.whitespaceChars(0, ' ');
    tokens.commentChar('#');
    tokens.quoteChar('"');
    tokens.eolIsSignificant(true);

    tokens.nextToken();
    while (tokens.ttype != StreamTokenizer.TT_EOF) {
        switch (tokens.ttype) {
            case StreamTokenizer.TT_WORD:
            case '"':                       // parse line
                bvec.add(parseBenchInfo(tokens));
                break;

            default:                        // ignore
                tokens.nextToken();
                break;
        }
    }
    binfo = (BenchInfo[]) bvec.toArray(new BenchInfo[bvec.size()]);
}