当前位置: 首页>>代码示例>>Java>>正文


Java Vector.removeAllElements方法代码示例

本文整理汇总了Java中java.util.Vector.removeAllElements方法的典型用法代码示例。如果您正苦于以下问题:Java Vector.removeAllElements方法的具体用法?Java Vector.removeAllElements怎么用?Java Vector.removeAllElements使用的例子?那么恭喜您, 这里精选的方法代码示例或许可以为您提供帮助。您也可以进一步了解该方法所在java.util.Vector的用法示例。


在下文中一共展示了Vector.removeAllElements方法的12个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于系统推荐出更棒的Java代码示例。

示例1: stripJavaPackage

import java.util.Vector; //导入方法依赖的package包/类
/**
 * Strip Java #pragma prefix and/or -pkgPrefix prefix package names from
 * given IDLEntity ct.
 * Strip any package prefix which may have been added by comparing with
 * repository id. For example in Java package fake.omega:
 *   repid = IDL:phoney.pfix/omega/Juliet:1.0 gives { "omega" }
 * @param ct CompoundType containing given IDLEntity.
 * @param vec Returned Vector of stripped IDL module names.
 */
protected void stripJavaPackage(
                                CompoundType ct,
                                Vector vec ) {
    vec.removeAllElements();
    if ( ! ct.isIDLEntity() ) return;

    String repID = ct.getRepositoryID().substring( 4 );
    StringTokenizer rept = new StringTokenizer( repID,"/" );
    if ( rept.countTokens() < 2 ) return;

    while ( rept.hasMoreTokens() )
        vec.addElement( rept.nextToken() );
    vec.removeElementAt( vec.size() - 1 );

    String pName = ct.getPackageName();         //start from Java package names
    if ( pName == null ) return;
    Vector pVec = new Vector();
    StringTokenizer pt = new StringTokenizer( pName,"." );
    while ( pt.hasMoreTokens() ) pVec.addElement( pt.nextToken() );

    int i1 = vec.size() - 1;
    int i2 = pVec.size() - 1;
    while ( i1 >= 0 && i2 >= 0 ) {                      //go R->L till mismatch
        String rep = (String)( vec.elementAt( i1 ) );
        String pkg = (String)( pVec.elementAt( i2 ) );
        if ( ! pkg.equals( rep ) ) break;
        i1--; i2--;
    }
    for ( int i3 = 0; i3 <= i1; i3++ )
        vec.removeElementAt( 0 );                                  //strip prefix
}
 
开发者ID:SunburstApps,项目名称:OpenJSharp,代码行数:41,代码来源:IDLGenerator.java

示例2: getSimilarity

import java.util.Vector; //导入方法依赖的package包/类
public double getSimilarity(String sentence1, String sentence2) throws SLIB_Exception, IOException {
    String[] sentence1_split = sentence1.split("\\s+");
    String[] sentence2_split = sentence2.split("\\s+");

    Vector<Double> avgVec1 = new Vector<Double>();
    Vector<Double> avgVec2 = new Vector<Double>();

    Vector<Double> vector1 = new Vector<Double>();
    Vector<Double> vector2 = new Vector<Double>();

    int count1=0, count2=0;
    for(String s1: sentence1_split){
        if(wordvector.containsKey(s1)){
            vector1 = wordvector.get(s1);
        }
        else vector1.removeAllElements();
    }

    CosineSimilarity similarityMeasure = new CosineSimilarity(vector1, vector2);
    double similarityScore = similarityMeasure.calculateDistanceAmongVectors();
    return similarityScore;

}
 
开发者ID:gizemsogancioglu,项目名称:biosses,代码行数:24,代码来源:WordVectorConstructor.java

示例3: main

import java.util.Vector; //导入方法依赖的package包/类
public static void main(String[] args) {
	try {
		Vector v = new Vector();
		v.removeAllElements();
		v.firstElement();
	} catch (Exception e) {
		e.printStackTrace();
	}
}
 
开发者ID:themaplelab,项目名称:ideal,代码行数:10,代码来源:VectorTarget4.java

示例4: oneRound

import java.util.Vector; //导入方法依赖的package包/类
void oneRound(String url, String user,
              String password) throws InterruptedException, SQLException {

    Vector      vClient  = new Vector();
    Thread      Client   = null;
    Enumeration e        = null;
    Connection  guardian = null;

    //
    start_time = System.currentTimeMillis();

    for (int i = 0; i < n_clients; i++) {
        if (useStoredProcedure) {
            Client = new ClientThreadProcedure(
                n_txn_per_client, url, user, password,
                Connection.TRANSACTION_READ_COMMITTED);
        } else {
            Client =
                new ClientThread(n_txn_per_client, url, user, password,
                                 Connection.TRANSACTION_READ_COMMITTED);
        }

        Client.start();
        vClient.addElement(Client);
    }

    /*
     ** Barrier to complete this test session
     */
    e = vClient.elements();

    while (e.hasMoreElements()) {
        Client = (Thread) e.nextElement();

        Client.join();
    }

    vClient.removeAllElements();
    reportDone();

    guardian = connect(url, user, password);

    if (count_results) {
        checkSums(guardian);
    }

    connectClose(guardian);
}
 
开发者ID:tiweGH,项目名称:OpenDiabetes,代码行数:49,代码来源:TestBench.java

示例5: oneRound

import java.util.Vector; //导入方法依赖的package包/类
void oneRound(String url, String user, String password,
              boolean transactions,
              boolean prepared) throws InterruptedException, SQLException {

    Vector      vClient  = new Vector();
    Thread      Client   = null;
    Enumeration e        = null;
    Connection  guardian = null;

    //
    this.transactions  = transactions;
    this.prepared_stmt = prepared;
    start_time         = System.currentTimeMillis();

    for (int i = 0; i < n_clients; i++) {
        Client = new ClientThread(n_txn_per_client, url, user, password,
                                  Connection.TRANSACTION_READ_COMMITTED);

        Client.start();
        vClient.addElement(Client);
    }

    /*
     ** Barrier to complete this test session
     */
    e = vClient.elements();

    while (e.hasMoreElements()) {
        Client = (Thread) e.nextElement();

        Client.join();
    }

    vClient.removeAllElements();
    reportDone();

    guardian = connect(url, user, password);

    checkSums(guardian);
    connectClose(guardian);
}
 
开发者ID:tiweGH,项目名称:OpenDiabetes,代码行数:42,代码来源:JDBCBench.java

示例6: checkForRoutingError

import java.util.Vector; //导入方法依赖的package包/类
/**
 * Checks that no closed classes may be routed into a Sink. If a problem is found it raises
 * to "true" the corresponding position inside the errors array.
 */
private void checkForRoutingError() {
	//vector collecting all the station keys where routing problems occour
	// for this close class
	Vector<Object> problemsPerClass = new Vector<Object>(0, 1);
	Vector<Object> closedClassKeys = class_def.getClosedClassKeys();
	Vector<Object> startingPoints = new Vector<Object>(0, 1);
	//get the vector of the possible starting points
	Vector<Object> noSourceSink = station_def.getStationKeysNoSourceSink();
	for (int i = 0; i < closedClassKeys.size(); i++) {
		//remove all elements from the problemsPerClass vector
		problemsPerClass.removeAllElements();
		//create the vector containing the already visited station keys
		Vector<Object> alreadyVisited = new Vector<Object>(0, 1);
		//get the class at i
		Object thisClassKey = closedClassKeys.get(i);
		//checks for each possible starting point if there are preloaded jobs for the class i.
		//In that case put it into the startingPoints vector
		for (int j = 0; j < noSourceSink.size(); j++) {
			Object thisElementKey = noSourceSink.get(j);
			int preloadedJobs = simulation_def.getPreloadedJobs(thisElementKey, thisClassKey).intValue();
			if (preloadedJobs > 0) {
				startingPoints.add(thisElementKey);
			}
		}
		//start the explore algorithm for each of the station containing some preloaded jobs for class i
		for (int j = 0; j < startingPoints.size(); j++) {
			//get the element at j
			Object thisStartingPoint = startingPoints.get(j);
			//if this possible starting point has not been visited yet
			if (!alreadyVisited.contains(thisStartingPoint)) {
				alreadyVisited.add(thisStartingPoint);
				Vector<Object> problemsForThisStartingPoint = exploreForRoutingProblems(thisClassKey, thisStartingPoint, alreadyVisited);
				for (int k = 0; k < problemsForThisStartingPoint.size(); k++) {
					problemsPerClass.add(problemsForThisStartingPoint.get(k));
				}
			}
		}
		if (!problemsPerClass.isEmpty()) {
			routingErrors.put(thisClassKey, (Vector<Object>) problemsPerClass.clone());
			errors[ROUTING_ERROR] = true;
		}
	}
}
 
开发者ID:HOMlab,项目名称:QN-ACTR-Release,代码行数:48,代码来源:ModelChecker.java

示例7: checkForAllForwardStationsAreSinkError

import java.util.Vector; //导入方法依赖的package包/类
/**
 * Checks that no closed classes may be routed into a station whose forward station(s) are
 * all sink. If a problem is found it raises to "true" the corresponding position inside
 * the errors array.
 */
private void checkForAllForwardStationsAreSinkError() {
	//vector collecting all the station keys where errors occour
	// for this close class
	Vector<Object> problemsPerClass = new Vector<Object>(0, 1);
	Vector<Object> closedClassKeys = class_def.getClosedClassKeys();
	Vector<Object> startingPoints = new Vector<Object>(0, 1);
	//get the vector of the possible starting points
	Vector<Object> noSourceSink = station_def.getStationKeysNoSourceSink();
	for (int i = 0; i < closedClassKeys.size(); i++) {
		//remove all elements from the problemsPerClass vector
		problemsPerClass.removeAllElements();
		//create the vector containing the already visited station keys
		Vector<Object> alreadyVisited = new Vector<Object>(0, 1);
		//get the class at i
		Object thisClassKey = closedClassKeys.get(i);
		//checks for each possible starting point if there are preloaded jobs for the class i.
		//In that case put it into the startingPoints vector
		for (int j = 0; j < noSourceSink.size(); j++) {
			Object thisElementKey = noSourceSink.get(j);
			int preloadedJobs = simulation_def.getPreloadedJobs(thisElementKey, thisClassKey).intValue();
			if (preloadedJobs > 0) {
				startingPoints.add(thisElementKey);
			}
		}
		//start the explore algorithm for each of the station containing some preloaded jobs for class i
		for (int j = 0; j < startingPoints.size(); j++) {
			//get the element at j
			Object thisStartingPoint = startingPoints.get(j);
			//if this possible starting point has not been visited yet
			if (!alreadyVisited.contains(thisStartingPoint)) {
				alreadyVisited.add(thisStartingPoint);
				Vector<Object> problemsForThisStartingPoint = this.exploreForAllForwardStationAreSink(thisClassKey, thisStartingPoint,
						alreadyVisited);
				for (int k = 0; k < problemsForThisStartingPoint.size(); k++) {
					problemsPerClass.add(problemsForThisStartingPoint.get(k));
				}
			}
		}
		if (!problemsPerClass.isEmpty()) {
			allForwardStationsAreSinkErrors.put(thisClassKey, (Vector<Object>) problemsPerClass.clone());
			errors[ALL_FORWARD_STATION_ARE_SINK_ERROR] = true;
		}
	}
}
 
开发者ID:HOMlab,项目名称:QN-ACTR-Release,代码行数:50,代码来源:ModelChecker.java

示例8: translateJavaPackage

import java.util.Vector; //导入方法依赖的package包/类
/**
 * Apply user specified -idlModule translation to package names of given
 * IDLEntity ct. Example:
 *   -idlModule foo.bar real::mod::nesting
 * @param ct CompoundType containing given IDLEntity.
 * @param vec Returned Vector of translated IDL module names.
 * @return boolean true if any translation was done.
 */
protected boolean translateJavaPackage(
                                       CompoundType ct,
                                       Vector vec ) {
    vec.removeAllElements();
    boolean ret = false;
    String fc = null;
    if ( ! ct.isIDLEntity() ) return ret;

    String pName = ct.getPackageName();         //start from Java package names
    if ( pName == null ) return ret;
    StringTokenizer pt = new StringTokenizer( pName,"." );
    while ( pt.hasMoreTokens() ) vec.addElement( pt.nextToken() );

    if ( imHash.size() > 0 ) {           //any -idlModule translation to apply?
        Enumeration k = imHash.keys();

    nextModule:
        while ( k.hasMoreElements() ) {      //loop thro user-defined -idlModules
            String from = (String)k.nextElement();                  //from String..
            StringTokenizer ft = new StringTokenizer( from,"." );
            int vecLen = vec.size();
            int ifr;
            for ( ifr = 0; ifr < vecLen && ft.hasMoreTokens(); ifr++ )
                if ( ! vec.elementAt(ifr).equals( ft.nextToken() ) )
                    continue nextModule;                                  //..no match

            if ( ft.hasMoreTokens() ) {                          //matched so far..
                fc = ft.nextToken();                         //a 'from' token remains
                if ( ! ct.getName().equals( fc ) ||             //matches class name?
                     ft.hasMoreTokens() )
                    continue nextModule;                                   //..no match
            }

            ret = true;                                             //found a match
            for ( int i4 = 0; i4 < ifr; i4++ )
                vec.removeElementAt( 0 );                     //remove 'from' package

            String to = (String)imHash.get( from );                   //..to String
            StringTokenizer tt = new StringTokenizer( to,IDL_NAME_SEPARATOR );

            int itoco = tt.countTokens();
            int ito = 0;
            if ( fc != null ) itoco--;               //user may have given IDL type
            for ( ito = 0; ito < itoco; ito++ )
                vec.insertElementAt( tt.nextToken(),ito );      //insert 'to' modules
            if ( fc != null ) {
                String tc = tt.nextToken();
                if ( ! ct.getName().equals( tc ) )           //not the IDL type, so..
                    vec.insertElementAt( tc,ito );           //insert final 'to' module
            }
        }
    }
    return ret;
}
 
开发者ID:SunburstApps,项目名称:OpenJSharp,代码行数:63,代码来源:IDLGenerator.java

示例9: prioritizeRules

import java.util.Vector; //导入方法依赖的package包/类
/**
 * Orders a set or rules by priority, removes redundant rules and rules
 * that are shadowed by stronger, contradicting rules.
 */
private static int prioritizeRules(Vector rules) {
    WhitespaceRule currentRule;
    int defaultAction = PRESERVE_SPACE;

    // Sort all rules with regard to priority
    quicksort(rules, 0, rules.size()-1);

    // Check if there are any "xsl:strip-space" elements at all.
    // If there are no xsl:strip elements we can ignore all xsl:preserve
    // elements and signal that all whitespaces should be preserved
    boolean strip = false;
    for (int i = 0; i < rules.size(); i++) {
        currentRule = (WhitespaceRule)rules.elementAt(i);
        if (currentRule.getAction() == STRIP_SPACE) {
            strip = true;
        }
    }
    // Return with default action: PRESERVE_SPACE
    if (!strip) {
        rules.removeAllElements();
        return PRESERVE_SPACE;
    }

    // Remove all rules that are contradicted by rules with higher priority
    for (int idx = 0; idx < rules.size(); ) {
        currentRule = (WhitespaceRule)rules.elementAt(idx);

        // Remove this single rule if it has no purpose
        if (findContradictingRule(rules,currentRule) != null) {
            rules.remove(idx);
        }
        else {
            // Remove all following rules if this one overrides all
            if (currentRule.getStrength() == RULE_ALL) {
                defaultAction = currentRule.getAction();
                for (int i = idx; i < rules.size(); i++) {
                    rules.removeElementAt(i);
                }
            }
            // Skip to next rule (there might not be any)...
            idx++;
        }
    }

    // The rules vector could be empty if first rule has strength RULE_ALL
    if (rules.size() == 0) {
        return defaultAction;
    }

    // Now work backwards and strip away all rules that have the same
    // action as the default rule (no reason the check them at the end).
    do {
        currentRule = (WhitespaceRule)rules.lastElement();
        if (currentRule.getAction() == defaultAction) {
            rules.removeElementAt(rules.size() - 1);
        }
        else {
            break;
        }
    } while (rules.size() > 0);

    // Signal that whitespace detection predicate must be used.
    return defaultAction;
}
 
开发者ID:SunburstApps,项目名称:OpenJSharp,代码行数:69,代码来源:Whitespace.java

示例10: buildLocationPath

import java.util.Vector; //导入方法依赖的package包/类
/**
 * Used by the {@link #parseExpression(NamespaceContext)} method
 * to build a {@link LocationPath} object from the accumulated
 * {@link Step}s.
 */
private LocationPath buildLocationPath( Vector stepsVector ) throws XPathException {
    int size = stepsVector.size();
    check(size!=0);
    Step[] steps = new Step[size];
    stepsVector.copyInto(steps);
    stepsVector.removeAllElements();

    return new LocationPath(steps);
}
 
开发者ID:SunburstApps,项目名称:OpenJSharp,代码行数:15,代码来源:XPath.java

示例11: transform

import java.util.Vector; //导入方法依赖的package包/类
@SuppressWarnings("unused") 
   public SingleConstraintSet transform(SingleConstraintSet constraintSet) {
// check if any Assignments are already contained or if any Assignments
// can be read of trivially and insert the assignments into the
// remaining constraints
Vector<Assignment> assignments = new Vector<Assignment>();
Vector<SingleConstraint> checkedConstraints = new Vector<SingleConstraint>();
Vector<SingleConstraint> uncheckedConstraints = new Vector<SingleConstraint>();
for (int i = 0; i < constraintSet.getConstraintCount(); i++)
    uncheckedConstraints.add(constraintSet.getConstraint(i));
while (!uncheckedConstraints.isEmpty()){
    SingleConstraint constraint = uncheckedConstraints.remove(0);
    if (constraint instanceof Assignment){
	assignments.add((Assignment)constraint);
	uncheckedConstraints.addAll(checkedConstraints);
	checkedConstraints.removeAllElements();
    } else{
	for (int assignmentIdx = 0; assignmentIdx < assignments.size(); assignmentIdx++)
	    constraint = constraint.insert(assignments.get(assignmentIdx));
	Solution solution = null; //constraint.getUniqueSolution();
	if (solution != null){
	    if (solution == Solution.NOSOLUTION)
		return new SingleConstraintSet(BooleanConstant.FALSE);
	    for (Variable variable: solution.variables()){
		Constant value = solution.getValue(variable);
		Assignment assignment = new Assignment(variable, value);
		constraint = constraint.insert(assignment);
		assignments.add(assignment);
	    }
	    uncheckedConstraints.addAll(checkedConstraints);
	    checkedConstraints.removeAllElements();
	}
	combineConditions(checkedConstraints, uncheckedConstraints, assignments, constraint);
    }
}

SingleConstraintSet result = new SingleConstraintSet();
for (int i = 0; i < checkedConstraints.size(); i++)
    result.add(checkedConstraints.get(i));
for (int i = 0; i < assignments.size(); i++)
    result.add(assignments.get(i));
return result;
   }
 
开发者ID:wwu-pi,项目名称:tap17-muggl-javaee,代码行数:44,代码来源:SimpleConstraintSetOptimizer.java

示例12: init

import java.util.Vector; //导入方法依赖的package包/类
/**
 * Description of the Method
 */
public void init() {
    firePropertyChange("play", null, "stop");

    int maxwait = 10;
    while (isRefreshing() && maxwait-- > 0) {
        try {
            Thread.currentThread();
            Thread.sleep(100);
        } catch (Exception ignored) {
        }
    }

    int[] minmax = getHeightRange();
    minHeight = minmax[0];
    maxHeight = minmax[1];

    Enumeration<YassTable> et = tables.elements();
    for (Enumeration<Vector<YassRectangle>> e = rects.elements(); e
            .hasMoreElements() && et.hasMoreElements(); ) {
        Vector<YassRectangle> r = e.nextElement();
        YassTable t = et.nextElement();

        // System.out.println("Sheet-Init start singleton");
        // synchronized (YassSingleton.getInstance()) {
        r.removeAllElements();
        int n = t.getRowCount();
        for (int i = 0; i < n; i++) {
            r.addElement(new YassRectangle());
        }
        // }
        // System.out.println("Sheet-Init finish singleton");
    }

    if (isValid()) {
        updateHeight();
        update();
        repaint();
    }
}
 
开发者ID:SarutaSan72,项目名称:Yass,代码行数:43,代码来源:YassSheet.java


注:本文中的java.util.Vector.removeAllElements方法示例由纯净天空整理自Github/MSDocs等开源代码及文档管理平台,相关代码片段筛选自各路编程大神贡献的开源项目,源码版权归原作者所有,传播和使用请参考对应项目的License;未经允许,请勿转载。