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

The following are Jave code examples for showing how to use containsAll() 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: mayfly-lang   File: ProgramValidator.java   View Source Code Vote up 6 votes
public static Vector<String> validateTaskGraph(Vector<TaskGraph> task_graphs) {
	// TODO validate multi source, multi sink task graphs
	// Make sure that inputs of the task match incoming edges data
	// This takes care of outputs as well
	// Check counts, types, NOT order, of input and output through graph
	Vector<String> errors = new Vector<String>();
	for( TaskGraph tg: task_graphs) {
		for(TaskDefinition td: tg.getSorted()) {
			Set<Edge> incoming_edges = tg.getGraph().incomingEdgesOf(td);
			Set<Edge> outgoing_edges = tg.getGraph().outgoingEdgesOf(td);
			// Cannot have more than 8 outgoing edges
			if(outgoing_edges.size() > 8) {
				errors.add("Line "+(td.getLine()+1)+": Task \""+td.getName()+"\" cannot have more than eight (8) outgoing edges, remove links.");
			}
			Iterator<Edge> itr = incoming_edges.iterator();
			Vector<Argument> task_inputs = td.getInput();
			while(itr.hasNext()) {
				TaskDefinition source_task = tg.getGraph().getEdgeSource(itr.next());
				Vector<Argument> incoming_data = source_task.getOutput();
				if(task_inputs.containsAll(incoming_data) == false) {
					errors.add("Line "+(td.getLine()+1)+": Input signature of \""+td.getName()+"\" does not match name, type, or count, of incoming edges, missing " + incoming_data);
				}
				
			}
			// Special case: if an incomming edge is a predicate, then this does not 
			// satisfy input match to output, as predicate is not guaranteed to always be originator / source
			
		}
	}
	return errors;
}
 
Example 2
Project: OpenJSharp   File: Stylesheet.java   View Source Code Vote up 5 votes
/**
 * This method returns a vector with variables/params and keys in the
 * order in which they are to be compiled for initialization. The order
 * is determined by analyzing the dependencies between them. The XSLT 1.0
 * spec does not allow a key to depend on a variable. However, for
 * compatibility with Xalan interpretive, that type of dependency is
 * allowed and, therefore, consider to determine the partial order.
 */
private Vector resolveDependencies(Vector input) {
    /* DEBUG CODE - INGORE
    for (int i = 0; i < input.size(); i++) {
        final TopLevelElement e = (TopLevelElement) input.elementAt(i);
        System.out.println("e = " + e + " depends on:");
        Vector dep = e.getDependencies();
        for (int j = 0; j < (dep != null ? dep.size() : 0); j++) {
            System.out.println("\t" + dep.elementAt(j));
        }
    }
    System.out.println("=================================");
    */

    Vector result = new Vector();
    while (input.size() > 0) {
        boolean changed = false;
        for (int i = 0; i < input.size(); ) {
            final TopLevelElement vde = (TopLevelElement) input.elementAt(i);
            final Vector dep = vde.getDependencies();
            if (dep == null || result.containsAll(dep)) {
                result.addElement(vde);
                input.remove(i);
                changed = true;
            }
            else {
                i++;
            }
        }

        // If nothing was changed in this pass then we have a circular ref
        if (!changed) {
            ErrorMsg err = new ErrorMsg(ErrorMsg.CIRCULAR_VARIABLE_ERR,
                                        input.toString(), this);
            getParser().reportError(Constants.ERROR, err);
            return(result);
        }
    }

    /* DEBUG CODE - INGORE
    System.out.println("=================================");
    for (int i = 0; i < result.size(); i++) {
        final TopLevelElement e = (TopLevelElement) result.elementAt(i);
        System.out.println("e = " + e);
    }
    */

    return result;
}
 
Example 3
Project: openjdk-jdk10   File: Stylesheet.java   View Source Code Vote up 5 votes
/**
 * This method returns a vector with variables/params and keys in the
 * order in which they are to be compiled for initialization. The order
 * is determined by analyzing the dependencies between them. The XSLT 1.0
 * spec does not allow a key to depend on a variable. However, for
 * compatibility with Xalan interpretive, that type of dependency is
 * allowed and, therefore, consider to determine the partial order.
 */
private Vector resolveDependencies(Vector input) {
    /* DEBUG CODE - INGORE
    for (int i = 0; i < input.size(); i++) {
        final TopLevelElement e = (TopLevelElement) input.elementAt(i);
        System.out.println("e = " + e + " depends on:");
        Vector dep = e.getDependencies();
        for (int j = 0; j < (dep != null ? dep.size() : 0); j++) {
            System.out.println("\t" + dep.elementAt(j));
        }
    }
    System.out.println("=================================");
    */

    Vector result = new Vector();
    while (input.size() > 0) {
        boolean changed = false;
        for (int i = 0; i < input.size(); ) {
            final TopLevelElement vde = (TopLevelElement) input.elementAt(i);
            final Vector dep = vde.getDependencies();
            if (dep == null || result.containsAll(dep)) {
                result.addElement(vde);
                input.remove(i);
                changed = true;
            }
            else {
                i++;
            }
        }

        // If nothing was changed in this pass then we have a circular ref
        if (!changed) {
            ErrorMsg err = new ErrorMsg(ErrorMsg.CIRCULAR_VARIABLE_ERR,
                                        input.toString(), this);
            getParser().reportError(Constants.ERROR, err);
            return(result);
        }
    }

    /* DEBUG CODE - INGORE
    System.out.println("=================================");
    for (int i = 0; i < result.size(); i++) {
        final TopLevelElement e = (TopLevelElement) result.elementAt(i);
        System.out.println("e = " + e);
    }
    */

    return result;
}