Java Code Examples for java.util.Vector#set()

The following examples show how to use java.util.Vector#set() . You can vote up the ones you like or vote down the ones you don't like, and go to the original project or source file by following the links above each example. You may check out the related API usage on the sidebar.
Example 1
Source File: XSDHandler.java    From openjdk-jdk8u with GNU General Public License v2.0 6 votes vote down vote up
/**
 * Namespace growth
 *
 * Go throuth the grammar bucket, and for each grammar in the bucket
 * check the import list. If there exists a grammar in import list
 * that has the same namespace as newGrammar, but a different instance,
 * then update the import list and replace the old grammar instance with
 * the new one
 */
private void updateImportListWith(SchemaGrammar newGrammar) {
    SchemaGrammar[] schemaGrammars = fGrammarBucket.getGrammars();
    for (int i = 0; i < schemaGrammars.length; ++i) {
        SchemaGrammar sg = schemaGrammars[i];
        if (sg != newGrammar) {
            Vector importedGrammars = sg.getImportedGrammars();
            if (importedGrammars != null) {
                for (int j=0; j<importedGrammars.size(); j++) {
                    SchemaGrammar isg = (SchemaGrammar) importedGrammars.elementAt(j);
                    if (null2EmptyString(isg.getTargetNamespace()).equals(null2EmptyString(newGrammar.getTargetNamespace()))) {
                        if (isg != newGrammar) {
                            importedGrammars.set(j, newGrammar);
                        }
                        break;
                    }
                }
            }
        }
    }
}
 
Example 2
Source File: XSDHandler.java    From openjdk-jdk9 with GNU General Public License v2.0 6 votes vote down vote up
/**
 * Namespace growth
 *
 * Go throuth the grammar bucket, and for each grammar in the bucket
 * check the import list. If there exists a grammar in import list
 * that has the same namespace as newGrammar, but a different instance,
 * then update the import list and replace the old grammar instance with
 * the new one
 */
private void updateImportListWith(SchemaGrammar newGrammar) {
    SchemaGrammar[] schemaGrammars = fGrammarBucket.getGrammars();
    for (int i = 0; i < schemaGrammars.length; ++i) {
        SchemaGrammar sg = schemaGrammars[i];
        if (sg != newGrammar) {
            Vector importedGrammars = sg.getImportedGrammars();
            if (importedGrammars != null) {
                for (int j=0; j<importedGrammars.size(); j++) {
                    SchemaGrammar isg = (SchemaGrammar) importedGrammars.elementAt(j);
                    if (null2EmptyString(isg.getTargetNamespace()).equals(null2EmptyString(newGrammar.getTargetNamespace()))) {
                        if (isg != newGrammar) {
                            importedGrammars.set(j, newGrammar);
                        }
                        break;
                    }
                }
            }
        }
    }
}
 
Example 3
Source File: XSDHandler.java    From JDKSourceCode1.8 with MIT License 6 votes vote down vote up
/**
 * Namespace growth
 *
 * Go throuth the grammar bucket, and for each grammar in the bucket
 * check the import list. If there exists a grammar in import list
 * that has the same namespace as newGrammar, but a different instance,
 * then update the import list and replace the old grammar instance with
 * the new one
 */
private void updateImportListWith(SchemaGrammar newGrammar) {
    SchemaGrammar[] schemaGrammars = fGrammarBucket.getGrammars();
    for (int i = 0; i < schemaGrammars.length; ++i) {
        SchemaGrammar sg = schemaGrammars[i];
        if (sg != newGrammar) {
            Vector importedGrammars = sg.getImportedGrammars();
            if (importedGrammars != null) {
                for (int j=0; j<importedGrammars.size(); j++) {
                    SchemaGrammar isg = (SchemaGrammar) importedGrammars.elementAt(j);
                    if (null2EmptyString(isg.getTargetNamespace()).equals(null2EmptyString(newGrammar.getTargetNamespace()))) {
                        if (isg != newGrammar) {
                            importedGrammars.set(j, newGrammar);
                        }
                        break;
                    }
                }
            }
        }
    }
}
 
Example 4
Source File: XSDHandler.java    From openjdk-8 with GNU General Public License v2.0 6 votes vote down vote up
/**
 * Namespace growth
 *
 * Go throuth the grammar bucket, and for each grammar in the bucket
 * check the import list. If there exists a grammar in import list
 * that has the same namespace as newGrammar, but a different instance,
 * then update the import list and replace the old grammar instance with
 * the new one
 */
private void updateImportListWith(SchemaGrammar newGrammar) {
    SchemaGrammar[] schemaGrammars = fGrammarBucket.getGrammars();
    for (int i = 0; i < schemaGrammars.length; ++i) {
        SchemaGrammar sg = schemaGrammars[i];
        if (sg != newGrammar) {
            Vector importedGrammars = sg.getImportedGrammars();
            if (importedGrammars != null) {
                for (int j=0; j<importedGrammars.size(); j++) {
                    SchemaGrammar isg = (SchemaGrammar) importedGrammars.elementAt(j);
                    if (null2EmptyString(isg.getTargetNamespace()).equals(null2EmptyString(newGrammar.getTargetNamespace()))) {
                        if (isg != newGrammar) {
                            importedGrammars.set(j, newGrammar);
                        }
                        break;
                    }
                }
            }
        }
    }
}
 
Example 5
Source File: Catalog.java    From openjdk-jdk9 with GNU General Public License v2.0 6 votes vote down vote up
/**
 * Copies the reader list from the current Catalog to a new Catalog.
 *
 * <p>This method is used internally when constructing a new catalog.
 * It copies the current reader associations over to the new catalog.
 * </p>
 *
 * @param newCatalog The new Catalog.
 */
protected void copyReaders(Catalog newCatalog) {
  // Have to copy the readers in the right order...convert hash to arr
  Vector mapArr = new Vector(readerMap.size());

  // Pad the mapArr out to the right length
  for (int count = 0; count < readerMap.size(); count++) {
    mapArr.add(null);
  }

  for (Map.Entry<String, Integer> entry : readerMap.entrySet()) {
      mapArr.set(entry.getValue().intValue(), entry.getKey());
  }

  for (int count = 0; count < mapArr.size(); count++) {
    String mimeType = (String) mapArr.get(count);
    Integer pos = readerMap.get(mimeType);
    newCatalog.addReader(mimeType,
                         (CatalogReader)
                         readerArr.get(pos.intValue()));
  }
}
 
Example 6
Source File: HierarchicalModelIT.java    From laser with Apache License 2.0 6 votes vote down vote up
@Test
public void updateOfflineModel() {
	try {
		Object[] req = new Object[3];
		req[0] = new Vector<Float>(400);
		req[1] = new Vector<Float>(10000);
		Vector<Vector<Float>> quadratic = new Vector<Vector<Float>>(400);
		for (int i = 0; i < quadratic.size(); i++) {
			quadratic.set(i, new Vector<Float>(10000));
		}
		req[2] = quadratic;
		Boolean ret = (Boolean) client.write(req, "updateOfflineModel",
				Boolean.class);
		assertTrue(ret);

	} catch (Exception e) {
		e.printStackTrace();
		assertTrue(false);
	}
}
 
Example 7
Source File: TroveClassificationILDBBuilder.java    From jatecs with GNU General Public License v3.0 6 votes vote down vote up
protected void addCategoryHierarchicaly(int document, short category, boolean primary) {
    TIntArrayList docs = _classificationDB._categoriesDocuments.get(category);
    Vector<Boolean> docsPrimary = _classificationDB._categoriesDocumentsPrimary.get(category);
    int pos = docs.binarySearch(document);
    if (pos < 0) {
        docs.insert(-pos - 1, document);
        docsPrimary.insertElementAt(primary, -pos - 1);
    } else {
        if (primary) {
            docsPrimary.set(pos, true);
        }
    }

    IShortIterator parents = _classificationDB.getCategoryDB().getParentCategories(category);
    while (parents.hasNext())
        addCategoryHierarchicaly(document, parents.next(), primary);
}
 
Example 8
Source File: XSDHandler.java    From openjdk-jdk8u with GNU General Public License v2.0 5 votes vote down vote up
/**
 * Namespace growth
 *
 * Go through the import list of a given grammar and for each imported
 * grammar, check to see if the grammar bucket has a newer version.
 * If a new instance is found, we update the import list with the
 * newer version.
 */
private void updateImportListFor(SchemaGrammar grammar) {
    Vector importedGrammars = grammar.getImportedGrammars();
    if (importedGrammars != null) {
        for (int i=0; i<importedGrammars.size(); i++) {
            SchemaGrammar isg1 = (SchemaGrammar) importedGrammars.elementAt(i);
            SchemaGrammar isg2 = fGrammarBucket.getGrammar(isg1.getTargetNamespace());
            if (isg2 != null && isg1 != isg2) {
                importedGrammars.set(i, isg2);
            }
        }
    }
}
 
Example 9
Source File: Dominance.java    From KEEL with GNU General Public License v3.0 5 votes vote down vote up
static Vector<Integer> collocate(Vector<Interval> frente) throws IOException
{

	Vector<Integer> rules_collocate= new Vector<Integer>(frente.size());
	for(int i=0;i<frente.size();i++)
		rules_collocate.add(i, i);
		
		
	//order the front 
	Interval temporal = new Interval();
	for (int i = 0; i < frente.size(); i++) 
	{
		for (int j = 0; j < frente.size(); j++) 
		{
			if (frente.get(i).getmax() >frente.get(j).getmax()) 
			{
				temporal = frente.get(i);
				frente.set(i,frente.get(j));
				frente.set(j,temporal);
			
			}
		}
	}
	
	 for(int i=0;i<frente.size();i++) 
		{
		 rules_collocate.add(i,(int)frente.get(i).getmin());
		}
	return rules_collocate;
}
 
Example 10
Source File: BuildConfig.java    From openjdk-8 with GNU General Public License v2.0 5 votes vote down vote up
void extAttr(Vector receiver, String attr, String value) {
    int attr_pos=receiver.indexOf(attr) ;
    if ( attr_pos == -1) {
      // If attr IS NOT present in the Vector - add it
      receiver.add(attr); receiver.add(value);
    } else {
      // If attr IS present in the Vector - append value to it
      receiver.set(attr_pos+1,receiver.get(attr_pos+1)+value);
    }
}
 
Example 11
Source File: BuildConfig.java    From openjdk-8-source with GNU General Public License v2.0 5 votes vote down vote up
void extAttr(Vector receiver, String attr, String value) {
    int attr_pos=receiver.indexOf(attr) ;
    if ( attr_pos == -1) {
      // If attr IS NOT present in the Vector - add it
      receiver.add(attr); receiver.add(value);
    } else {
      // If attr IS present in the Vector - append value to it
      receiver.set(attr_pos+1,receiver.get(attr_pos+1)+value);
    }
}
 
Example 12
Source File: XSDHandler.java    From jdk8u60 with GNU General Public License v2.0 5 votes vote down vote up
/**
 * Namespace growth
 *
 * Go through the import list of a given grammar and for each imported
 * grammar, check to see if the grammar bucket has a newer version.
 * If a new instance is found, we update the import list with the
 * newer version.
 */
private void updateImportListFor(SchemaGrammar grammar) {
    Vector importedGrammars = grammar.getImportedGrammars();
    if (importedGrammars != null) {
        for (int i=0; i<importedGrammars.size(); i++) {
            SchemaGrammar isg1 = (SchemaGrammar) importedGrammars.elementAt(i);
            SchemaGrammar isg2 = fGrammarBucket.getGrammar(isg1.getTargetNamespace());
            if (isg2 != null && isg1 != isg2) {
                importedGrammars.set(i, isg2);
            }
        }
    }
}
 
Example 13
Source File: XSDHandler.java    From hottub with GNU General Public License v2.0 5 votes vote down vote up
/**
 * Namespace growth
 *
 * Go through the import list of a given grammar and for each imported
 * grammar, check to see if the grammar bucket has a newer version.
 * If a new instance is found, we update the import list with the
 * newer version.
 */
private void updateImportListFor(SchemaGrammar grammar) {
    Vector importedGrammars = grammar.getImportedGrammars();
    if (importedGrammars != null) {
        for (int i=0; i<importedGrammars.size(); i++) {
            SchemaGrammar isg1 = (SchemaGrammar) importedGrammars.elementAt(i);
            SchemaGrammar isg2 = fGrammarBucket.getGrammar(isg1.getTargetNamespace());
            if (isg2 != null && isg1 != isg2) {
                importedGrammars.set(i, isg2);
            }
        }
    }
}
 
Example 14
Source File: Mode.java    From JDKSourceCode1.8 with MIT License 5 votes vote down vote up
private int partition(Vector templates, int p, int r) {
    final Template x = (Template)templates.elementAt(p);
    int i = p - 1;
    int j = r + 1;
    while (true) {
        while (x.compareTo((Template)templates.elementAt(--j)) > 0);
        while (x.compareTo((Template)templates.elementAt(++i)) < 0);
        if (i < j) {
            templates.set(j, templates.set(i, templates.elementAt(j)));
        }
        else {
            return j;
        }
    }
}
 
Example 15
Source File: XSDHandler.java    From openjdk-8 with GNU General Public License v2.0 5 votes vote down vote up
/**
 * Namespace growth
 *
 * Go through the import list of a given grammar and for each imported
 * grammar, check to see if the grammar bucket has a newer version.
 * If a new instance is found, we update the import list with the
 * newer version.
 */
private void updateImportListFor(SchemaGrammar grammar) {
    Vector importedGrammars = grammar.getImportedGrammars();
    if (importedGrammars != null) {
        for (int i=0; i<importedGrammars.size(); i++) {
            SchemaGrammar isg1 = (SchemaGrammar) importedGrammars.elementAt(i);
            SchemaGrammar isg2 = fGrammarBucket.getGrammar(isg1.getTargetNamespace());
            if (isg2 != null && isg1 != isg2) {
                importedGrammars.set(i, isg2);
            }
        }
    }
}
 
Example 16
Source File: ConfigParser.java    From EasyVPN-Free with GNU General Public License v3.0 4 votes vote down vote up
public void parseConfig(Reader reader) throws IOException, ConfigParseError {

        HashMap<String, String> optionAliases = new HashMap<>();
        optionAliases.put("server-poll-timeout", "timeout-connect");

        BufferedReader br = new BufferedReader(reader);

        int lineno = 0;
        try {
            while (true) {
                String line = br.readLine();
                lineno++;
                if (line == null)
                    break;

                if (lineno == 1) {
                    if ((line.startsWith("PK\003\004")
                            || (line.startsWith("PK\007\008")))) {
                        throw new ConfigParseError("Input looks like a ZIP Archive. Import is only possible for OpenVPN config files (.ovpn/.conf)");
                    }
                    if (line.startsWith("\uFEFF")) {
                        line = line.substring(1);
                    }
                }

                // Check for OpenVPN Access Server Meta information
                if (line.startsWith("# OVPN_ACCESS_SERVER_")) {
                    Vector<String> metaarg = parsemeta(line);
                    meta.put(metaarg.get(0), metaarg);
                    continue;
                }
                Vector<String> args = parseline(line);

                if (args.size() == 0)
                    continue;


                if (args.get(0).startsWith("--"))
                    args.set(0, args.get(0).substring(2));

                checkinlinefile(args, br);

                String optionname = args.get(0);
                if (optionAliases.get(optionname)!=null)
                    optionname = optionAliases.get(optionname);

                if (!options.containsKey(optionname)) {
                    options.put(optionname, new Vector<Vector<String>>());
                }
                options.get(optionname).add(args);
            }
        } catch (java.lang.OutOfMemoryError memoryError) {
            throw new ConfigParseError("File too large to parse: " + memoryError.getLocalizedMessage());
        }
    }
 
Example 17
Source File: FordFulkerson.java    From Java with MIT License 4 votes vote down vote up
private static int networkFlow(int source, int sink) {
    flow = new int[V][V];
    int totalFlow = 0;
    while (true) {
        Vector<Integer> parent = new Vector<>(V);
        for (int i = 0; i < V; i++)
            parent.add(-1);
        Queue<Integer> q = new LinkedList<>();
        parent.set(source, source);
        q.add(source);
        while (!q.isEmpty() && parent.get(sink) == -1) {
            int here = q.peek();
            q.poll();
            for (int there = 0; there < V; ++there)
                if (capacity[here][there] - flow[here][there] > 0 && parent.get(there) == -1) {
                    q.add(there);
                    parent.set(there, here);
                }
        }
        if (parent.get(sink) == -1)
            break;

        int amount = INF;
        String printer = "path : ";
        StringBuilder sb = new StringBuilder();
        for (int p = sink; p != source; p = parent.get(p)) {
            amount = Math.min(capacity[parent.get(p)][p] - flow[parent.get(p)][p], amount);
            sb.append(p + "-");
        }
        sb.append(source);
        for (int p = sink; p != source; p = parent.get(p)) {
            flow[parent.get(p)][p] += amount;
            flow[p][parent.get(p)] -= amount;
        }
        totalFlow += amount;
        printer += sb.reverse() + " / max flow : " + totalFlow;
        System.out.println(printer);
    }

    return totalFlow;
}
 
Example 18
Source File: EditOneMotionObjectPanel.java    From opensim-gui with Apache License 2.0 4 votes vote down vote up
private void initComboBoxes() {
    // Body name combobox
    FrameList frameList = aModel.getFrameList();
    BodySet bodySet = aModel.getBodySet();
    populateBodyList(frameList, BodiesComboBox);
     BodiesComboBox.setSelectedItem(motionForce.getForceAppliedToBody());
     PointExpressedBodiesComboBox.setSelectedItem(motionForce.getPointExpressedInBody());
     ForceExpressedBodiesComboBox.setSelectedItem(motionForce.getForceExpressedInBodyName());
    // All other drop downs, populate with column names except time.
    Vector<String> colmnLabels = lbls.toVector();
    colmnLabels.set(0,""); // no default column & time shouldn't be permitted anyway'
    String[] colNames = new String[colmnLabels.size()];
    colmnLabels.toArray(colNames);
    // Force dropdowns
    jComboBoxFX.setModel(new javax.swing.DefaultComboBoxModel(colNames));
    jComboBoxFY.setModel(new javax.swing.DefaultComboBoxModel(colNames));
    jComboBoxFZ.setModel(new javax.swing.DefaultComboBoxModel(colNames));

    //externalForce.getForceFunctionNames(forceFunctionNames);
     if (motionForce.appliesForce()){
        String forceId = motionForce.getForceIdentifier();
        setComboBoxSelection(jComboBoxFX, forceId, 0);
        setComboBoxSelection(jComboBoxFY, forceId, 1);
        setComboBoxSelection(jComboBoxFZ, forceId, 2);
    }
    
    // Point dropdowns
    jComboBoxPX.setModel(new javax.swing.DefaultComboBoxModel(colNames));
    jComboBoxPY.setModel(new javax.swing.DefaultComboBoxModel(colNames));
    jComboBoxPZ.setModel(new javax.swing.DefaultComboBoxModel(colNames));
    //externalForce.getPointFunctionNames(pointFunctionNames);
    if (motionForce.specifiesPoint()){
        String pointId = motionForce.getPointIdentifier();
        setComboBoxSelection(jComboBoxPX, pointId, 0);
        setComboBoxSelection(jComboBoxPY, pointId, 1);
        setComboBoxSelection(jComboBoxPZ, pointId, 2);
        jRadioButtonApplyPointForce.setSelected(true);
    } else
        jRadioButtonApplyBodyForce.setSelected(true);
   //externalForce.getTorqueFunctionNames(torqueFunctionNames);
    populateBodyList(frameList, ForceExpressedBodiesComboBox);
    populateBodyList(frameList, PointExpressedBodiesComboBox);
    
    String dbg1 = motionForce.getForceExpressedInBodyName();
    ForceExpressedBodiesComboBox.setSelectedItem(motionForce.getForceExpressedInBodyName());
    
    String dbg2 = motionForce.getPointExpressedInBody();
    PointExpressedBodiesComboBox.setSelectedItem(motionForce.getPointExpressedInBody());
    //System.out.println("Component="+motionForce.getForceComponent());
    jComponentComboBox.setSelectedItem(motionForce.getForceComponent());
    jComboBoxTX.setModel(new javax.swing.DefaultComboBoxModel(colNames));
    jComboBoxTY.setModel(new javax.swing.DefaultComboBoxModel(colNames));
    jComboBoxTZ.setModel(new javax.swing.DefaultComboBoxModel(colNames));
    torqueSpecified = motionForce.isSpecifyTorque();
    if (torqueSpecified){
        String torqueId = motionForce.getTorqueIdentifier();
        setComboBoxSelection(jComboBoxTX, torqueId, 0);
        setComboBoxSelection(jComboBoxTY, torqueId, 1);
        setComboBoxSelection(jComboBoxTZ, torqueId, 2);
        jCheckBoxTorque.setSelected(true);
    }
}
 
Example 19
Source File: Main.java    From KEEL with GNU General Public License v3.0 2 votes vote down vote up
public static Vector<Float> order ( Vector<Float> CL, Vector<fuzzy> comp) throws IOException

	{

		 Vector<Float> Lcolocado= new  Vector<Float>();

		 for(int i=0;i<CL.size();i++)

			 Lcolocado.addElement(CL.get(i));

		 



		 fuzzy temporal = new fuzzy();

		 float tem=-1;

		 for (int i = 0; i < comp.size(); i++) 

			{

				for (int j = 0; j < comp.size(); j++) 

				{



					if(Ranking.wang(comp.get(i),comp.get(j))==0)

					{

						temporal = comp.get(i);

						comp.set(i,comp.get(j));

						comp.set(j,temporal);

						

						tem = Lcolocado.get(i);

						Lcolocado.set(i,Lcolocado.get(j));

						Lcolocado.set(j,tem);

					

					}

				}

			}

			

			

		

		 

		 return Lcolocado;

	}
 
Example 20
Source File: Main.java    From KEEL with GNU General Public License v3.0 2 votes vote down vote up
public static Vector<Float> ranking (Vector<fuzzy> costes, Vector<Float> valores) throws IOException

	{

		

		

	

		 fuzzy temporal = new fuzzy();

		 Vector<fuzzy> coste = new Vector<fuzzy>();

		 Vector<Float> valor = new Vector<Float>();

		 for(int i=0;i<valores.size();i++)

			 valor.addElement(valores.get(i));

		 for (int i = 0; i < costes.size(); i++) 

		 {

			 coste.addElement(costes.get(i));

		 }

		 

		 float tem=-1;

		 for (int i = 0; i < coste.size(); i++) 

			{

				for (int j = 0; j < coste.size(); j++) 

				{

					

					if(Ranking.wang(coste.get(i),coste.get(j))==1) 

					{

						

						temporal = coste.get(i);

						coste.set(i,coste.get(j));

						coste.set(j,temporal);

						

						tem = valor.get(i);

						valor.set(i,valor.get(j));

						valor.set(j,tem);

					

					}

				}

			}

			

		

		

		return valor;//.get(valor.size()-1);

	}