Java Code Examples for java.util.Vector.size()

The following are Jave code examples for showing how to use size() of the java.util.Vector class. You can vote up the examples you like. Your votes will be used in our system to get more good examples.
+ Save this method
Example 1
Project: Neukoelln_SER316   File: NoteListImpl.java   View Source Code Vote up 7 votes
/**
    * @see net.sf.memoranda.NoteList#getMarkedNotes()
    */
   public Collection getMarkedNotes() {
       Vector v = new Vector();
       Elements yrs = _root.getChildElements("year");
       for (int yi = 0; yi < yrs.size(); yi++) {
           Year y = new Year(yrs.get(yi));
           Vector ms = y.getMonths();
           for (int mi = 0; mi < ms.size(); mi++) {
               Month m = (Month) ms.get(mi);
               Vector ds = m.getDays();
               for (int di = 0; di < ds.size(); di++) {
                   Day d = (Day) ds.get(di);
				Vector ns = d.getNotes();
				for(int ni = 0; ni < ns.size(); ni++) {
					NoteElement ne = (NoteElement) ns.get(ni);
					Note n = new NoteImpl(ne.getElement(), _project);
					if (n.isMarked()) v.add(n);
               }
           }
       }
   }
        return v;
}
 
Example 2
Project: geomapapp   File: UnknownDataSet.java   View Source Code Vote up 6 votes
public void bookmark(){
		if (desc.type >-1){
			Vector<DBDescription> bookmarks=new Vector<DBDescription>();
			File rt = GMARoot.getRoot();
			if (rt==null) return;
			String fs = System.getProperty("file.separator");
			File bm = new File(rt.getPath()+fs+"history"+fs+"db.bm");
			if (bm!=null) bookmarks = readVectors(bm);
			
			for (int i = Math.max(bookmarks.size()-10,0); i < bookmarks.size(); i++)
				if (desc.equals((bookmarks.get(i)))){

//					GMA 1.5.2: Corrected misspelling of "already"
//					JOptionPane.showMessageDialog(null, "Bookmark allready exists", "Bookmark exists", JOptionPane.INFORMATION_MESSAGE);
					JOptionPane.showMessageDialog(null, "Bookmark already exists", "Bookmark exists", JOptionPane.INFORMATION_MESSAGE);

					return;
				}

			bookmarks.add(desc);
			File hstD = new File(rt.getPath()+fs+"history");
			hstD.mkdir();
			try {
				ObjectOutputStream out = new ObjectOutputStream(new FileOutputStream(bm));
				for (int i = 0; i < bookmarks.size(); i++)
					out.writeObject(bookmarks.get(i));
				out.close();
				JOptionPane.showMessageDialog(null, "Bookmark created.", "Succesful", JOptionPane.INFORMATION_MESSAGE);
			} catch (IOException e) {JOptionPane.showMessageDialog(null, "Error Writing Bookmark:\n"+e.getMessage(), "Error", JOptionPane.ERROR_MESSAGE);}
		}
	}
 
Example 3
Project: MARF-for-Android   File: LPC.java   View Source Code Vote up 6 votes
/**
 * LPC Constructor.
 *
 * @param poPreprocessing Preprocessing module reference
 */
public LPC(IPreprocessing poPreprocessing) {
    super(poPreprocessing);
    setDefaults();

    // LPC-specific parameters, if any
    ModuleParams oModuleParams = MARF.getModuleParams();

    if (oModuleParams != null) {
        Vector oParams = oModuleParams.getFeatureExtractionParams();

        if (oParams.size() > 0) {
            this.iPoles = ((Integer) oParams.elementAt(0)).intValue();
            this.iWindowLen = ((Integer) oParams.elementAt(1)).intValue();
        }
    }
}
 
Example 4
Project: jmt   File: ParameterOptionPanel.java   View Source Code Vote up 6 votes
public Object getStationKey(String name) {
	Object key = null;
	Vector<Object> stations = sd.getStationKeys();
	for (int i = 0; i < stations.size(); i++) {
		if (sd.getStationName(stations.get(i)).equals(name)) {
			key = stations.get(i);
		}
	}
	return key;
}
 
Example 5
Project: ipack   File: NaccacheSternKeyPairGenerator.java   View Source Code Vote up 6 votes
/**
 * Generates a permuted ArrayList from the original one. The original List
 * is not modified
 * 
 * @param arr
 *            the ArrayList to be permuted
 * @param rand
 *            the source of Randomness for permutation
 * @return a new ArrayList with the permuted elements.
 */
private static Vector permuteList(
    Vector arr, 
    SecureRandom rand) 
{
    Vector retval = new Vector();
    Vector tmp = new Vector();
    for (int i = 0; i < arr.size(); i++) 
    {
        tmp.addElement(arr.elementAt(i));
    }
    retval.addElement(tmp.elementAt(0));
    tmp.removeElementAt(0);
    while (tmp.size() != 0) 
    {
        retval.insertElementAt(tmp.elementAt(0), getInt(rand, retval.size() + 1));
        tmp.removeElementAt(0);
    }
    return retval;
}
 
Example 6
Project: QN-ACTR-Release   File: ModelChecker.java   View Source Code Vote up 6 votes
/**
 * Check if there is at least one open class but there are no sinks. If a problem is found it raises
 * to "true" the corresponding position inside the problems array.
 */
private void checkForNoSinkWithOpenClassError() {
	//vector used to contain the set of open class keys
	Vector<Object> openClasses = new Vector<Object>(0, 1);
	//vector used to contain the complete set class keys
	Vector<Object> classes = class_def.getClassKeys();
	//for cicle used to collect the open class keys from the classes vector
	for (int i = 0; i < classes.size(); i++) {
		Object thisClassKey = classes.get(i);
		if (class_def.getClassType(thisClassKey) == CLASS_TYPE_OPEN) {
			openClasses.add(thisClassKey);
		}
	}
	//if there is at least one open class
	if (openClasses.size() > 0) {
		//variable counting the number of sink
		int nSink = 0;
		//vector containing the complete set of class keys
		Vector<Object> stations = station_def.getStationKeys();
		//for each station ...
		for (int i = 0; i < stations.size(); i++) {
			Object thisStationKey = stations.get(i);
			// ... check if it is a sink, in that case increase the nSink variable
			if (station_def.getStationType(thisStationKey).equals(STATION_TYPE_SINK)) {
				nSink++;
			}
		}
		//if no sink was found there is an error
		errors[NO_SINK_WITH_OPEN_CLASSES_ERROR] = nSink == 0;
	} else {
		errors[NO_SINK_WITH_OPEN_CLASSES_ERROR] = false;
	}
}
 
Example 7
Project: openjdk-jdk10   File: isSiteLocalAddress.java   View Source Code Vote up 6 votes
public static void main(String[] args) throws Exception {
    String[][] addrs =
    {{"9.255.255.255", "false"}, {"10.0.0.0", "true"},
     {"10.255.255.255", "true"}, {"11.0.0.0", "false"},
     {"172.15.255.255", "false"}, {"172.16.0.0", "true"},
     {"172.30.1.2", "true"}, {"172.31.255.255", "true"},
     {"172.32.0.0", "false"}, {"192.167.255.255", "false"},
     {"192.168.0.0", "true"}, {"192.168.255.255", "true"},
     {"192.169.0.0", "false"}};

    Vector v = new Vector();
    for (int i = 0; i < addrs.length; i++) {
        InetAddress addr = InetAddress.getByName(addrs[i][0]);
        boolean result = new Boolean(addrs[i][1]).booleanValue();
        if (addr.isSiteLocalAddress() != result) {
            v.add(addrs[i]);
        }
    }
    Iterator itr = v.iterator();
    while (itr.hasNext()) {
        String[] entry = (String[]) itr.next();
        System.out.println(entry[0] +" should return "+entry[1]
                           + " when calling isSiteLocalAddress()");
    }
    if (v.size() > 0) {
        throw new RuntimeException("InetAddress.isSiteLocalAddress() test failed");
    }
}
 
Example 8
Project: OpenJSharp   File: ClassLoader.java   View Source Code Vote up 6 votes
static long findNative(ClassLoader loader, String name) {
    Vector<NativeLibrary> libs =
        loader != null ? loader.nativeLibraries : systemNativeLibraries;
    synchronized (libs) {
        int size = libs.size();
        for (int i = 0; i < size; i++) {
            NativeLibrary lib = libs.elementAt(i);
            long entry = lib.find(name);
            if (entry != 0)
                return entry;
        }
    }
    return 0;
}
 
Example 9
Project: QN-ACTR-Release   File: ModelChecker.java   View Source Code Vote up 6 votes
/**
 * Checks if there are stations mot backward linked
 */
private void checkForNoBacwardLinkWarning() {
	Vector<Object> stations = station_def.getStationKeys();
	for (int i = 0; i < stations.size(); i++) {
		Object thisStationKey = stations.get(i);
		if ((!station_def.getStationType(thisStationKey).equals(STATION_TYPE_SOURCE))
				&& (!station_def.getStationType(thisStationKey).equals(STATION_TYPE_SINK))) {
			Vector<Object> backwardConnections = station_def.getBackwardConnections(thisStationKey);
			if (backwardConnections.size() == 0) {
				warnings[NO_BACKWARD_LINK_WARNING] = true;
				stationWithoutBackwardLinks.add(thisStationKey);
			}
		}
	}
}
 
Example 10
Project: QN-ACTR-Release   File: CommonModel.java   View Source Code Vote up 6 votes
/**
	 * Francesco D'Aquino
	 * Normalizes the routing probabilities for each station
	 */
	public void manageProbabilities() {
		//get the vector of the stations
		Vector<Object> stations = getStationKeys();
		//get the vector of the classes
		Vector<Object> classes = getClassKeys();
		//for each station ...
		for (int i = 0; i < stations.size(); i++) {
			//get the station at i from the station vector
			Object thisStation = stations.get(i);
			//if it isn't a sink...
			if (!getStationType(thisStation).equals(CommonConstants.STATION_TYPE_SINK)) {
				//Aboce :-^All stations have router except Sink
				//for each class...
				for (int j = 0; j < classes.size(); j++) {
					Object thisClass = classes.get(j);
					//check if the routing strategy in thisStation is ProbabilityRouting
					if (getRoutingStrategy(thisStation, thisClass) instanceof ProbabilityRouting) {
						//if it is so, normalize routing probabilities
						Vector<Object> outputKeys = getForwardConnections(thisStation);
						ProbabilityRouting pr = (ProbabilityRouting) getRoutingStrategy(thisStation, thisClass);
						Map<Object, Double> values = pr.getValues();
						
//						normalizeProbabilities(values, outputKeys, thisClass, thisStation); //QN-Java
						
					}
				}
			}
		}
	}
 
Example 11
Project: geomapapp   File: TableDB.java   View Source Code Vote up 6 votes
public TableDB( Vector headings, Vector rows, StringBuffer comments) {
	this.comments = comments;
	this.headings = headings;
	this.rows = rows;
	resolveLonLat();
	resolveClasses();
	columnOrder = new Vector();
	for( int k=0 ; k<headings.size() ; k++) columnOrder.add(new Integer(k));
}
 
Example 12
Project: jdk8u-jdk   File: CSS.java   View Source Code Vote up 6 votes
/**
 * @return an array of all the strings in <code>value</code>
 *         that are separated by whitespace.
 */
static String[] parseStrings(String value) {
    int         current, last;
    int         length = (value == null) ? 0 : value.length();
    Vector<String> temp = new Vector<String>(4);

    current = 0;
    while (current < length) {
        // Skip ws
        while (current < length && Character.isWhitespace
               (value.charAt(current))) {
            current++;
        }
        last = current;
        while (current < length && !Character.isWhitespace
               (value.charAt(current))) {
            current++;
        }
        if (last != current) {
            temp.addElement(value.substring(last, current));
        }
        current++;
    }
    String[] retValue = new String[temp.size()];
    temp.copyInto(retValue);
    return retValue;
}
 
Example 13
Project: parabuild-ci   File: WebForm.java   View Source Code Vote up 6 votes
/**
 * Returns an array containing the submit buttons defined for this form.
 **/
public SubmitButton[] getSubmitButtons() {
    if (_submitButtons == null) {
        Vector buttons = getSubmitButtonVector();
        _submitButtons = new SubmitButton[ buttons.size() ];
        buttons.copyInto( _submitButtons );
    }
    return _submitButtons;
}
 
Example 14
Project: creoson   File: JLFeature.java   View Source Code Vote up 6 votes
/**
     * Walk recursively through a hierarchy of sub-features and accumulate a list of suppress operations 
     * @param features The list of feature objects to check
     * @param featOps The output list of accumulated suppress operations
     * @param clip Whether to clip-suppress suppressed features to the end of the structure
     * @throws JLIException
     * @throws jxthrowable
     */
    private void suppressChildren(Vector<CallFeature> features, CallFeatureOperations featOps, boolean clip) throws JLIException,jxthrowable {
        if (features!=null) {
            int len = features.size();
            CallFeature feat;
            SuppressLooper2 subLooper;
            // loop through each input feature
            for (int i=0; i<len; i++) {
                feat = (CallFeature)features.elementAt(i);
                // use a looper to resume sub-features
                subLooper = new SuppressLooper2();
                subLooper.featOps = featOps;
                subLooper.clip = clip;
                
                subLooper.loop(feat);
                
                // restore this code if going with separate featOps
//                if (subLooper.featOps!=null && subLooper.featOps.getarraysize()>0) {
//                    parentSolid.ExecuteFeatureOps(subLooper.featOps, null);
//                }

                // if any new suppress operations were added in the looper, walk the children of this feature
                if (subLooper.featuresSuppressed!=null) {
                    suppressChildren(subLooper.featuresSuppressed, subLooper.featOps, clip);
                }
            }
        }
    }
 
Example 15
Project: jmt   File: XMLWriter.java   View Source Code Vote up 6 votes
static protected void writeSourceSection(Document doc, Node node,
		CommonModel model, Object stationKey) {
	Element elem = doc.createElement(XML_E_STATION_SECTION);
	elem.setAttribute(XML_A_STATION_SECTION_CLASSNAME, CLASSNAME_SOURCE);
	node.appendChild(elem);
	Vector<Object> classes = model.getClassKeys();
	// obtain classes that must be generated by this source
	Vector<Object> refClasses = getClassesForSource(model, stationKey);
	XMLParameter[] distrParams = new XMLParameter[classes.size()];
	for (int i = 0; i < distrParams.length; i++) {
		// if current class must be generated by this source
		Object currentClass = classes.get(i);
		if (refClasses.contains(currentClass)) {
			distrParams[i] = DistributionWriter
					.getDistributionParameter((Distribution) model
							.getClassDistribution(currentClass), model,
							currentClass);
		} else {
			// otherwise write a null parameter
			String name = "ServiceTimeStrategy";
			distrParams[i] = new XMLParameter(name, strategiesClasspathBase
					+ serviceStrategiesSuffix + name,
					model.getClassName(currentClass), "null", true);
		}
	}
	// creating global service strategy parameter
	String gspName = "ServiceStrategy";
	XMLParameter globalStrategyParameter = new XMLParameter(gspName,
			strategiesClasspathBase + gspName, null, distrParams, false);
	// finally, create node from parameters and append it to the section
	// element
	globalStrategyParameter.appendParameterElement(doc, elem);
}
 
Example 16
Project: geomapapp   File: DBTableModel.java   View Source Code Vote up 5 votes
public synchronized void setArea( Rectangle2D bounds, double zoom ) {
	if (bounds.equals(rect)) return;
	rect = bounds;

	Vector<Integer> v = new Vector<Integer>();
	int[] s = ds.dataT.getSelectedRows(); 

	for (int i=0;i<s.length;i++)
		s[i] = displayToDataIndex.get(s[i]);

	displayToDataIndex.removeAllElements();
	double xMin = bounds.getX();
	double xMax = xMin+bounds.getWidth();
	double yMin = bounds.getY();
	double yMax = yMin+bounds.getHeight();
	double wrap = ds.map.getWrap();
	int z = 0;
	for(int i=0 ; i<ds.data.size() ; i++) {
		UnknownData d = ds.data.get(i);

		boolean inBounds = checkDataBounds(d, xMin, xMax, yMin, yMax, wrap);
		if (!inBounds) inBounds = checkPolygonBounds(d, bounds, wrap);
		if (!inBounds) { 
			if (z<s.length&&i==s[z]) z++;
			continue;
		}

		displayToDataIndex.add(i);
		if (z<s.length&&i==s[z]) {
			v.add(displayToDataIndex.size()-1);
			z++;
		}
	}
	displayToDataIndex.trimToSize();

	ds.dataT.getSelectionModel().removeListSelectionListener(ds);

	// Each time we change the displayIndex we need to update
	// the sort as well
	if (lastSortedCol != -1) {
		ascent = !ascent;
		sortByColumn(lastSortedCol);
	}
	else {
		updateRowToDisplayIndex();
		fireTableDataChanged();
	}
	for (int i=0;i<v.size();i++) {
		z = v.get(i).intValue();
		ds.dataT.getSelectionModel().addSelectionInterval(z, z);
	}
	ds.dataT.getSelectionModel().addListSelectionListener(ds);
}
 
Example 17
Project: openjdk-jdk10   File: ImplementationType.java   View Source Code Vote up 5 votes
/**
 * Initialize this instance.
 */
private boolean initialize (ContextStack stack, boolean quiet) {

    boolean result = false;
    ClassDefinition theClass = getClassDefinition();

    if (initParents(stack)) {

        // Make up our collections...

        Vector directInterfaces = new Vector();
        Vector directMethods = new Vector();

        // Check interfaces...

        try {
            if (addRemoteInterfaces(directInterfaces,true,stack) != null) {

                boolean haveRemote = false;

                // Get methods from all interfaces...

                for (int i = 0; i < directInterfaces.size(); i++) {
                    InterfaceType theInt = (InterfaceType) directInterfaces.elementAt(i);
                    if (theInt.isType(TYPE_REMOTE) ||
                        theInt.isType(TYPE_JAVA_RMI_REMOTE)) {
                        haveRemote = true;
                    }

                    copyRemoteMethods(theInt,directMethods);
                }

                // Make sure we have at least one remote interface...

                if (!haveRemote) {
                    failedConstraint(8,quiet,stack,getQualifiedName());
                    return false;
                }

                // Now check the methods to ensure we have the
                // correct throws clauses...

                if (checkMethods(theClass,directMethods,stack,quiet)) {

                    // We're ok, so pass 'em up...

                    result = initialize(directInterfaces,directMethods,null,stack,quiet);
                }
            }
        } catch (ClassNotFound e) {
            classNotFound(stack,e);
        }
    }

    return result;
}
 
Example 18
Project: CoverageGA   File: GeneticAlgorithmUtility.java   View Source Code Vote up 5 votes
public void applyMovement(final Vector<Sensor> sensors, final Movement[] movement) {
	for (int i = 0; i < sensors.size(); i++) {
		sensors.set(i, applyMovement(sensors.get(i), movement[i]));
	}
}
 
Example 19
Project: openjdk-jdk10   File: RemoteType.java   View Source Code Vote up 5 votes
/**
 * Check to ensure that the interface and all it's methods and arguments
 * conforms to the RMI/IDL java subset for remote interfaces as defined
 * by the "Java to IDL Mapping" specification, section 4.
 * @param directInterfaces All directly implmented interfaces will be
 *   added to this list.
 * @param directMethods All directly implemented methods (other than
 *  constructors and initializers) will be added to this list.
 * @param directConstants All constants defined by theInterface will be
 *  added to this list.
 * @param quiet True if should not report constraint failures.
 * @return true if constraints satisfied, false otherwise.
 */
private boolean isConformingRemoteInterface (       Vector directInterfaces,
                                                    Vector directMethods,
                                                    Vector directConstants,
                                                    boolean quiet,
                                                    ContextStack stack) {

    ClassDefinition theInterface = getClassDefinition();

    try {

        // Get all remote interfaces...

        if (addRemoteInterfaces(directInterfaces,false,stack) == null ) {
            return false;
        }

        // Make sure all constants are conforming...

        if (!addAllMembers(directConstants,true,quiet,stack)) {
            return false;
        }

        // Now, collect up all methods...

        if (addAllMethods(theInterface,directMethods,true,quiet,stack) == null) {
            // Failed a constraint check...
            return false;
        }

        // Now walk 'em, ensuring each is a valid remote method...

        boolean methodsConform = true;
        for (int i = 0; i < directMethods.size(); i++) {
            if (! isConformingRemoteMethod((Method) directMethods.elementAt(i),quiet)) {
                methodsConform = false;
            }
        }
        if (!methodsConform) {
            return false;
        }
    } catch (ClassNotFound e) {
        classNotFound(stack,e);
        return false;
    }

    return true;
}
 
Example 20
Project: AgentWorkbench   File: NetworkComponentAdapter4Ontology.java   View Source Code Vote up 4 votes
@Override
public Vector<String> getDataModelBase64Encoded(Object dataModel) {
	Vector<String> base64Vector = this.getXML64FromInstances((Object[]) dataModel);
	if (base64Vector.size()==0) {
		base64Vector=null;
	}
	return base64Vector;
}