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

The following are Jave code examples for showing how to use clone() 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: jmt   File: EngineConvex2D.java   View Source Code Vote up 7 votes
/**
 * Costructor of the life
 * @param allPoints All the point of the graph
 * @param sd3 The sector of saturation
 */
public EngineConvex2D(Vector<Point2D> allPoints, Vector<Object> sd3) {
	this.allPoints = (Vector<Point2D>) allPoints.clone();
	allConvex = new Vector<Point2D>();
	allImperant = (Vector<Point2D>) allPoints.clone();
	allDominates = new Vector<Point2D>();

	filtDominants = new Vector<Point2D>();
	filtDominates = new Vector<Point2D>();
	filtPoints = new Vector<DPoint>();
	filtConvex = new Vector<Point2D>();

	filtArea = new Area();

	separator();
	//calcConvex();
	calcConvex(sd3);

	dominates = (Vector<Point2D>) allDominates.clone();
	imperant = (Vector<Point2D>) allImperant.clone();
	convex = (Vector<Point2D>) allConvex.clone();
	points = (Vector<Point2D>) this.allPoints.clone();
}
 
Example 2
Project: jmt   File: EngineConvex2D.java   View Source Code Vote up 7 votes
/**
 * This function return a vector that contains the same point of the parameter one but
 * the points are ordered from the point with the biggest X to the point with the smallest X
 * @param v The vector to order
 * @return The vector ordered
 */
private Vector<Point2D> orderByX(Vector<Point2D> v) {
	Vector<Point2D> r = (Vector<Point2D>) v.clone();
	boolean again = true;

	while (again) {
		again = false;
		for (int k = 0; k < r.size() - 1; k++) {
			//Take the points
			Point2D p1 = r.get(k);
			Point2D p2 = r.get(k + 1);

			if (p1.getX() < p2.getX()) {
				//swap
				r.remove(k);
				r.insertElementAt(p2, k);
				r.remove(k + 1);
				r.insertElementAt(p1, k + 1);
				again = true;
			}
		}
	}
	return r;
}
 
Example 3
Project: QN-ACTR-Release   File: EngineConvex2D.java   View Source Code Vote up 7 votes
/**
 * Costructor of the life
 * @param allPoints All the point of the graph
 * @param sd3 The sector of saturation
 */
public EngineConvex2D(Vector<Point2D> allPoints, Vector<Object> sd3) {
	this.allPoints = (Vector<Point2D>) allPoints.clone();
	allConvex = new Vector<Point2D>();
	allImperant = (Vector<Point2D>) allPoints.clone();
	allDominates = new Vector<Point2D>();

	filtDominants = new Vector<Point2D>();
	filtDominates = new Vector<Point2D>();
	filtPoints = new Vector<DPoint>();
	filtConvex = new Vector<Point2D>();

	filtArea = new Area();

	separator();
	//calcConvex();
	calcConvex(sd3);

	dominates = (Vector<Point2D>) allDominates.clone();
	imperant = (Vector<Point2D>) allImperant.clone();
	convex = (Vector<Point2D>) allConvex.clone();
	points = (Vector<Point2D>) this.allPoints.clone();
}
 
Example 4
Project: QN-ACTR-Release   File: EngineConvex2D.java   View Source Code Vote up 7 votes
/**
 * This function return a vector that contains the same point of the parameter one but
 * the points are orderet from the point whith the biggest X to the point whith the smallest X
 * @param v The vector to order
 * @return The vector ordered
 */
private Vector<Point2D> orderByX(Vector<Point2D> v) {
	Vector<Point2D> r = (Vector<Point2D>) v.clone();
	boolean again = true;

	while (again) {
		again = false;
		for (int k = 0; k < r.size() - 1; k++) {
			//Take the points
			Point2D p1 = r.get(k);
			Point2D p2 = r.get(k + 1);

			if (p1.getX() < p2.getX()) {
				//swap
				r.remove(k);
				r.insertElementAt(p2, k);
				r.remove(k + 1);
				r.insertElementAt(p1, k + 1);
				again = true;
			}
		}
	}
	return r;
}
 
Example 5
Project: OpenJSharp   File: EventSupport.java   View Source Code Vote up 7 votes
/**
 * Add the event and vector of listeners to the queue to be delivered.
 * An event dispatcher thread dequeues events from the queue and dispatches
 * them to the registered listeners.
 * Package private; used by NamingEventNotifier to fire events
 */
synchronized void queueEvent(EventObject event,
                             Vector<? extends NamingListener> vector) {
    if (eventQueue == null)
        eventQueue = new EventQueue();

    /*
     * Copy the vector in order to freeze the state of the set
     * of EventListeners the event should be delivered to prior
     * to delivery.  This ensures that any changes made to the
     * Vector from a target listener's method during the delivery
     * of this event will not take effect until after the event is
     * delivered.
     */
    @SuppressWarnings("unchecked") // clone()
    Vector<NamingListener> v =
            (Vector<NamingListener>)vector.clone();
    eventQueue.enqueue(event, v);
}
 
Example 6
Project: jdk8u-jdk   File: EventSupport.java   View Source Code Vote up 7 votes
/**
 * Add the event and vector of listeners to the queue to be delivered.
 * An event dispatcher thread dequeues events from the queue and dispatches
 * them to the registered listeners.
 * Package private; used by NamingEventNotifier to fire events
 */
synchronized void queueEvent(EventObject event,
                             Vector<? extends NamingListener> vector) {
    if (eventQueue == null)
        eventQueue = new EventQueue();

    /*
     * Copy the vector in order to freeze the state of the set
     * of EventListeners the event should be delivered to prior
     * to delivery.  This ensures that any changes made to the
     * Vector from a target listener's method during the delivery
     * of this event will not take effect until after the event is
     * delivered.
     */
    @SuppressWarnings("unchecked") // clone()
    Vector<NamingListener> v =
            (Vector<NamingListener>)vector.clone();
    eventQueue.enqueue(event, v);
}
 
Example 7
Project: openjdk-jdk10   File: EventSupport.java   View Source Code Vote up 7 votes
/**
 * Add the event and vector of listeners to the queue to be delivered.
 * An event dispatcher thread dequeues events from the queue and dispatches
 * them to the registered listeners.
 * Package private; used by NamingEventNotifier to fire events
 */
synchronized void queueEvent(EventObject event,
                             Vector<? extends NamingListener> vector) {
    if (eventQueue == null)
        eventQueue = new EventQueue();

    /*
     * Copy the vector in order to freeze the state of the set
     * of EventListeners the event should be delivered to prior
     * to delivery.  This ensures that any changes made to the
     * Vector from a target listener's method during the delivery
     * of this event will not take effect until after the event is
     * delivered.
     */
    @SuppressWarnings("unchecked") // clone()
    Vector<NamingListener> v =
            (Vector<NamingListener>)vector.clone();
    eventQueue.enqueue(event, v);
}
 
Example 8
Project: BRjLibs   File: ClasspathScanner.java   View Source Code Vote up 6 votes
/**
 * Scans the classpath for classes, returning those accepted by the given {@link Predicate}
 *
 * @param classLoader The classloader to look for classes and define classes if they're not found
 * @param scanJar If the current jar should be scanned (Also scans classes in IntelliJ runs) or only the current classloader
 * @param predicate Returns if a class should be added or not to the {@link Set}
 * @return The classes located
 */
@SuppressWarnings("unchecked")
public static Set<Class<?>> find(ClassLoader classLoader, boolean scanJar, Predicate<String> predicate) {
    Set<Class<?>> set = new HashSet<>();
    Vector<Class<?>> vector = GET_CLASSES.apply(classLoader);
    for(Class<?> c : (Vector<Class>)vector.clone()) {
        CLASS_CACHE.putIfAbsent(c.getName(), c);
        if(predicate.test(c.getName())) set.add(c);
    }
    if(scanJar) {
        jar(classLoader, set, predicate);
    }
    return Collections.unmodifiableSet(set);
}
 
Example 9
Project: openjdk-jdk10   File: XSDHandler.java   View Source Code Vote up 6 votes
private void addNewImportedGrammars(SchemaGrammar srcGrammar, SchemaGrammar dstGrammar) {
    final Vector igs1 = srcGrammar.getImportedGrammars();
    if (igs1 != null) {
        Vector igs2 = dstGrammar.getImportedGrammars();

        if (igs2 == null) {
            igs2 = ((Vector) igs1.clone());
            dstGrammar.setImportedGrammars(igs2);
        }
        else {
            updateImportList(igs1, igs2);
        }
    }
}
 
Example 10
Project: OpenJSharp   File: LdapName.java   View Source Code Vote up 5 votes
@SuppressWarnings("unchecked") // clone()
private LdapName(String name, Vector<Rdn> rdns) {
    unparsed = name;
    this.rdns = (Vector<Rdn>)rdns.clone();
}
 
Example 11
Project: OpenJSharp   File: XSGrammarBucket.java   View Source Code Vote up 5 votes
/**
 * put a schema grammar and any grammars imported by it (directly or
 * inderectly) into the registry. when a grammar with the same target
 * namespace is already in the bucket, and different from the one being
 * added, it's an error, and no grammar will be added into the bucket.
 *
 * @param grammar   the grammar to put in the registry
 * @param deep      whether to add imported grammars
 * @return          whether the process succeeded
 */
public boolean putGrammar(SchemaGrammar grammar, boolean deep) {
    // whether there is one with the same tns
    SchemaGrammar sg = getGrammar(grammar.fTargetNamespace);
    if (sg != null) {
        // if the one we have is different from the one passed, it's an error
        return sg == grammar;
    }
    // not deep import, then just add this one grammar
    if (!deep) {
        putGrammar(grammar);
        return true;
    }

    // get all imported grammars, and make a copy of the Vector, so that
    // we can recursively process the grammars, and add distinct ones
    // to the same vector
    Vector currGrammars = (Vector)grammar.getImportedGrammars();
    if (currGrammars == null) {
        putGrammar(grammar);
        return true;
    }

    Vector grammars = ((Vector)currGrammars.clone());
    SchemaGrammar sg1, sg2;
    Vector gs;
    // for all (recursively) imported grammars
    for (int i = 0; i < grammars.size(); i++) {
        // get the grammar
        sg1 = (SchemaGrammar)grammars.elementAt(i);
        // check whether the bucket has one with the same tns
        sg2 = getGrammar(sg1.fTargetNamespace);
        if (sg2 == null) {
            // we need to add grammars imported by sg1 too
            gs = sg1.getImportedGrammars();
            // for all grammars imported by sg2, but not in the vector
            // we add them to the vector
            if(gs == null) continue;
            for (int j = gs.size() - 1; j >= 0; j--) {
                sg2 = (SchemaGrammar)gs.elementAt(j);
                if (!grammars.contains(sg2))
                    grammars.addElement(sg2);
            }
        }
        // we found one with the same target namespace
        // if the two grammars are not the same object, then it's an error
        else if (sg2 != sg1) {
            return false;
        }
    }

    // now we have all imported grammars stored in the vector. add them
    putGrammar(grammar);
    for (int i = grammars.size() - 1; i >= 0; i--)
        putGrammar((SchemaGrammar)grammars.elementAt(i));

    return true;
}
 
Example 12
Project: OpenJSharp   File: XSGrammarBucket.java   View Source Code Vote up 5 votes
/**
 * put a schema grammar and any grammars imported by it (directly or
 * inderectly) into the registry. when a grammar with the same target
 * namespace is already in the bucket, and different from the one being
 * added, no grammar will be added into the bucket.
 *
 * @param grammar        the grammar to put in the registry
 * @param deep           whether to add imported grammars
 * @param ignoreConflict whether to ignore grammars that already exist in the grammar
 *                       bucket or not - including 'grammar' parameter.
 * @return               whether the process succeeded
 */
public boolean putGrammar(SchemaGrammar grammar, boolean deep, boolean ignoreConflict) {
    if (!ignoreConflict) {
        return putGrammar(grammar, deep);
    }

    // if grammar already exist in the bucket, we ignore the request
    SchemaGrammar sg = getGrammar(grammar.fTargetNamespace);
    if (sg == null) {
        putGrammar(grammar);
    }

    // not adding the imported grammars
    if (!deep) {
        return true;
    }

    // get all imported grammars, and make a copy of the Vector, so that
    // we can recursively process the grammars, and add distinct ones
    // to the same vector
    Vector currGrammars = (Vector)grammar.getImportedGrammars();
    if (currGrammars == null) {
        return true;
    }

    Vector grammars = ((Vector)currGrammars.clone());
    SchemaGrammar sg1, sg2;
    Vector gs;
    // for all (recursively) imported grammars
    for (int i = 0; i < grammars.size(); i++) {
        // get the grammar
        sg1 = (SchemaGrammar)grammars.elementAt(i);
        // check whether the bucket has one with the same tns
        sg2 = getGrammar(sg1.fTargetNamespace);
        if (sg2 == null) {
            // we need to add grammars imported by sg1 too
            gs = sg1.getImportedGrammars();
            // for all grammars imported by sg2, but not in the vector
            // we add them to the vector
            if(gs == null) continue;
            for (int j = gs.size() - 1; j >= 0; j--) {
                sg2 = (SchemaGrammar)gs.elementAt(j);
                if (!grammars.contains(sg2))
                    grammars.addElement(sg2);
            }
        }
        // we found one with the same target namespace, ignore it
        else  {
            grammars.remove(sg1);
        }
    }

    // now we have all imported grammars stored in the vector. add them
    for (int i = grammars.size() - 1; i >= 0; i--) {
        putGrammar((SchemaGrammar)grammars.elementAt(i));
    }

    return true;
}
 
Example 13
Project: fdt   File: TransportManager.java   View Source Code Vote up 5 votes
public void setConnectionMonitors(Vector monitors) {
    synchronized (this) {
        connectionMonitors = (Vector) monitors.clone();
    }
}
 
Example 14
Project: parabuild-ci   File: ClassDef.java   View Source Code Vote up 5 votes
public void addUnprocessedImports(Vector aImports) {
    unprocessedImports = (Vector) (aImports.clone());
}
 
Example 15
Project: jdk8u-jdk   File: RuleBasedBreakIteratorBuilder.java   View Source Code Vote up 5 votes
/**
 * This function is used to update the list of current loooping states (i.e.,
 * states that are controlled by a *? construct).  It backfills values from
 * the looping states into unpopulated cells of the states that are currently
 * marked for backfilling, and then updates the list of looping states to be
 * the new list
 * @param newLoopingStates The list of new looping states
 * @param endStates The list of states to treat as end states (states that
 * can exit the loop).
 */
private void setLoopingStates(Vector<Integer> newLoopingStates,
                              Vector<Integer> endStates) {

    // if the current list of looping states isn't empty, we have to backfill
    // values from the looping states into the states that are waiting to be
    // backfilled
    if (!loopingStates.isEmpty()) {
        int loopingState = loopingStates.lastElement().intValue();
        int rowNum;

        // don't backfill into an end state OR any state reachable from an end state
        // (since the search for reachable states is recursive, it's split out into
        // a separate function, eliminateBackfillStates(), below)
        for (int i = 0; i < endStates.size(); i++) {
            eliminateBackfillStates(endStates.elementAt(i).intValue());
        }

        // we DON'T actually backfill the states that need to be backfilled here.
        // Instead, we MARK them for backfilling.  The reason for this is that if
        // there are multiple rules in the state-table description, the looping
        // states may have some of their values changed by a succeeding rule, and
        // this wouldn't be reflected in the backfilled states.  We mark a state
        // for backfilling by putting the row number of the state to copy from
        // into the flag cell at the end of the row
        for (int i = 0; i < statesToBackfill.size(); i++) {
            rowNum = statesToBackfill.elementAt(i).intValue();
            short[] state = tempStateTable.elementAt(rowNum);
            state[numCategories] =
                (short)((state[numCategories] & ALL_FLAGS) | loopingState);
        }
        statesToBackfill.removeAllElements();
        loopingStates.removeAllElements();
    }

    if (newLoopingStates != null) {
        @SuppressWarnings("unchecked")
        Vector<Integer> clone = (Vector<Integer>)newLoopingStates.clone();
        loopingStates = clone;
    }
}
 
Example 16
Project: jdk8u-jdk   File: LdapName.java   View Source Code Vote up 5 votes
@SuppressWarnings("unchecked") // clone()
private LdapName(String name, Vector<Rdn> rdns) {
    unparsed = name;
    this.rdns = (Vector<Rdn>)rdns.clone();
}
 
Example 17
Project: openjdk-jdk10   File: RuleBasedBreakIteratorBuilder.java   View Source Code Vote up 5 votes
/**
 * This function is used to update the list of current loooping states (i.e.,
 * states that are controlled by a *? construct).  It backfills values from
 * the looping states into unpopulated cells of the states that are currently
 * marked for backfilling, and then updates the list of looping states to be
 * the new list
 * @param newLoopingStates The list of new looping states
 * @param endStates The list of states to treat as end states (states that
 * can exit the loop).
 */
private void setLoopingStates(Vector<Integer> newLoopingStates,
                              Vector<Integer> endStates) {

    // if the current list of looping states isn't empty, we have to backfill
    // values from the looping states into the states that are waiting to be
    // backfilled
    if (!loopingStates.isEmpty()) {
        int loopingState = loopingStates.lastElement().intValue();
        int rowNum;

        // don't backfill into an end state OR any state reachable from an end state
        // (since the search for reachable states is recursive, it's split out into
        // a separate function, eliminateBackfillStates(), below)
        for (int i = 0; i < endStates.size(); i++) {
            eliminateBackfillStates(endStates.elementAt(i).intValue());
        }

        // we DON'T actually backfill the states that need to be backfilled here.
        // Instead, we MARK them for backfilling.  The reason for this is that if
        // there are multiple rules in the state-table description, the looping
        // states may have some of their values changed by a succeeding rule, and
        // this wouldn't be reflected in the backfilled states.  We mark a state
        // for backfilling by putting the row number of the state to copy from
        // into the flag cell at the end of the row
        for (int i = 0; i < statesToBackfill.size(); i++) {
            rowNum = statesToBackfill.elementAt(i).intValue();
            short[] state = tempStateTable.elementAt(rowNum);
            state[numCategories] =
                (short)((state[numCategories] & ALL_FLAGS) | loopingState);
        }
        statesToBackfill.removeAllElements();
        loopingStates.removeAllElements();
    }

    if (newLoopingStates != null) {
        @SuppressWarnings("unchecked")
        Vector<Integer> clone = (Vector<Integer>)newLoopingStates.clone();
        loopingStates = clone;
    }
}
 
Example 18
Project: openjdk-jdk10   File: LdapName.java   View Source Code Vote up 5 votes
@SuppressWarnings("unchecked") // clone()
private LdapName(String name, Vector<Rdn> rdns) {
    unparsed = name;
    this.rdns = (Vector<Rdn>)rdns.clone();
}
 
Example 19
Project: openjdk-jdk10   File: XSGrammarBucket.java   View Source Code Vote up 5 votes
/**
 * put a schema grammar and any grammars imported by it (directly or
 * inderectly) into the registry. when a grammar with the same target
 * namespace is already in the bucket, and different from the one being
 * added, it's an error, and no grammar will be added into the bucket.
 *
 * @param grammar   the grammar to put in the registry
 * @param deep      whether to add imported grammars
 * @return          whether the process succeeded
 */
public boolean putGrammar(SchemaGrammar grammar, boolean deep) {
    // whether there is one with the same tns
    SchemaGrammar sg = getGrammar(grammar.fTargetNamespace);
    if (sg != null) {
        // if the one we have is different from the one passed, it's an error
        return sg == grammar;
    }
    // not deep import, then just add this one grammar
    if (!deep) {
        putGrammar(grammar);
        return true;
    }

    // get all imported grammars, and make a copy of the Vector, so that
    // we can recursively process the grammars, and add distinct ones
    // to the same vector
    Vector currGrammars = (Vector)grammar.getImportedGrammars();
    if (currGrammars == null) {
        putGrammar(grammar);
        return true;
    }

    Vector grammars = ((Vector)currGrammars.clone());
    SchemaGrammar sg1, sg2;
    Vector gs;
    // for all (recursively) imported grammars
    for (int i = 0; i < grammars.size(); i++) {
        // get the grammar
        sg1 = (SchemaGrammar)grammars.elementAt(i);
        // check whether the bucket has one with the same tns
        sg2 = getGrammar(sg1.fTargetNamespace);
        if (sg2 == null) {
            // we need to add grammars imported by sg1 too
            gs = sg1.getImportedGrammars();
            // for all grammars imported by sg2, but not in the vector
            // we add them to the vector
            if(gs == null) continue;
            for (int j = gs.size() - 1; j >= 0; j--) {
                sg2 = (SchemaGrammar)gs.elementAt(j);
                if (!grammars.contains(sg2))
                    grammars.addElement(sg2);
            }
        }
        // we found one with the same target namespace
        // if the two grammars are not the same object, then it's an error
        else if (sg2 != sg1) {
            return false;
        }
    }

    // now we have all imported grammars stored in the vector. add them
    putGrammar(grammar);
    for (int i = grammars.size() - 1; i >= 0; i--)
        putGrammar((SchemaGrammar)grammars.elementAt(i));

    return true;
}
 
Example 20
Project: openjdk-jdk10   File: XSGrammarBucket.java   View Source Code Vote up 5 votes
/**
 * put a schema grammar and any grammars imported by it (directly or
 * inderectly) into the registry. when a grammar with the same target
 * namespace is already in the bucket, and different from the one being
 * added, no grammar will be added into the bucket.
 *
 * @param grammar        the grammar to put in the registry
 * @param deep           whether to add imported grammars
 * @param ignoreConflict whether to ignore grammars that already exist in the grammar
 *                       bucket or not - including 'grammar' parameter.
 * @return               whether the process succeeded
 */
public boolean putGrammar(SchemaGrammar grammar, boolean deep, boolean ignoreConflict) {
    if (!ignoreConflict) {
        return putGrammar(grammar, deep);
    }

    // if grammar already exist in the bucket, we ignore the request
    SchemaGrammar sg = getGrammar(grammar.fTargetNamespace);
    if (sg == null) {
        putGrammar(grammar);
    }

    // not adding the imported grammars
    if (!deep) {
        return true;
    }

    // get all imported grammars, and make a copy of the Vector, so that
    // we can recursively process the grammars, and add distinct ones
    // to the same vector
    Vector currGrammars = (Vector)grammar.getImportedGrammars();
    if (currGrammars == null) {
        return true;
    }

    Vector grammars = ((Vector)currGrammars.clone());
    SchemaGrammar sg1, sg2;
    Vector gs;
    // for all (recursively) imported grammars
    for (int i = 0; i < grammars.size(); i++) {
        // get the grammar
        sg1 = (SchemaGrammar)grammars.elementAt(i);
        // check whether the bucket has one with the same tns
        sg2 = getGrammar(sg1.fTargetNamespace);
        if (sg2 == null) {
            // we need to add grammars imported by sg1 too
            gs = sg1.getImportedGrammars();
            // for all grammars imported by sg2, but not in the vector
            // we add them to the vector
            if(gs == null) continue;
            for (int j = gs.size() - 1; j >= 0; j--) {
                sg2 = (SchemaGrammar)gs.elementAt(j);
                if (!grammars.contains(sg2))
                    grammars.addElement(sg2);
            }
        }
        // we found one with the same target namespace, ignore it
        else  {
            grammars.remove(sg1);
        }
    }

    // now we have all imported grammars stored in the vector. add them
    for (int i = grammars.size() - 1; i >= 0; i--) {
        putGrammar((SchemaGrammar)grammars.elementAt(i));
    }

    return true;
}