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

The following are Jave code examples for showing how to use indexOf() 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: ibench   File: RandomSourceSkolemToMappingGenerator.java   View Source Code Vote up 7 votes
/**
 * Picks all attributes to be the arguments of the skolem and adds their names and positions to the RandSrcSkolem object.
 * 
 * @param r
 * 			The relation which we are adding the skolem to
 * @param scenario
 * 			The scenario which contains the relation
 * @param rsk
 * 			The RandSrcSkolem object which we wish to add the arguments to
 * @param allAttrs
 * 			All attributes in the source relation we are looking at
 * 
 * @throws Exception
 * 
 * @author mdangelo
 */
private static void useAllAsArgument(RelationType r, RandSrcSkolem rsk, String[] allAttrs) throws Exception 
{
	if (log.isDebugEnabled()) {log.debug("Using SkolemKind.ALL Mode for " + rsk.getSkId());};

	Vector<String> skAtts = new Vector<String>();
	
	for (String att : allAttrs)
		skAtts.add(att);
	
	// ensure that we are not adding the attribute itself as an argument to the skolem
	for (int i = 0; i < allAttrs.length; i++) 
		if (skAtts.indexOf(rsk.getAttr()) != -1)
			skAtts.remove(skAtts.indexOf(rsk.getAttr()));
	
	if (log.isDebugEnabled()) {log.debug("All Argument Set: " + skAtts.toString());};
	
	rsk.setArgAttrs(Utils.convertVectorToStringArray(skAtts));
	rsk.setArgPositions(getAttrPositions(allAttrs, rsk.getArgAttrs()));
}
 
Example 2
Project: ramus   File: AbstractSector.java   View Source Code Vote up 7 votes
/**
 * Метод повертає масив під’єднаних до точки секторів, при чому всі сектори
 * знаходяться на одному функціональному блоці.
 *
 * @param crosspoint Точка перетену секторів.
 * @return Масив секторів, що під’єднані до точки.
 */

private void getConnectedOnFunction(final Crosspoint crosspoint,
                                    final Vector<Sector> v) {
    if (crosspoint == null)
        return;
    final Vector<Sector> ss = new Vector<Sector>();
    crosspoint.getSectors(ss);
    int i;
    final int n = ss.size();
    final int oLen = v.size();
    Sector s;
    for (i = 0; i < n; i++)
        if ((s = ss.get(i)).getFunction().equals(getFunction()))
            if (v.indexOf(s) < 0)
                v.add(s);
    final int len = v.size();
    for (i = oLen; i < len; i++)
        ((AbstractSector) v.get(i)).getConnectedOnFunction(v);
}
 
Example 3
Project: ramus   File: AbstractIEngineAccessor.java   View Source Code Vote up 6 votes
@Override
public boolean canDeleteElements(long[] elementIds) {
    Vector<Long> qualifierIds = new Vector<Long>();
    for (long elementId : elementIds) {
        Long qualifierId = engine.getQualifierIdForElement(elementId);
        if (qualifierIds.indexOf(qualifierId) < 0) {
            if (!canUpdateQualifier(qualifierId))
                return false;
            else
                qualifierIds.add(qualifierId);
        }
    }
    return true;
}
 
Example 4
Project: ramus   File: AbstractSector.java   View Source Code Vote up 6 votes
private void getStreamChilds(final Vector<Sector> v) {
    final Stream stream = getStream();
    final Vector<Sector> n = new Vector<Sector>(3);
    getChilds(getStart().getCrosspoint(), n);
    getChilds(getEnd().getCrosspoint(), n);
    for (final Sector s : n) {
        if ((s.getStream() == null || stream != null
                && stream.equals(s.getStream()))
                && (v.indexOf(s) < 0)) {
            v.add(s);
            ((AbstractSector) s).getStreamChilds(v);
        }
    }
}
 
Example 5
Project: PeSanKita-android   File: NodeImpl.java   View Source Code Vote up 6 votes
public Node getNextSibling() {
    if ((mParentNode != null) && (this != mParentNode.getLastChild())) {
        Vector<Node> siblings = ((NodeImpl)mParentNode).mChildNodes;
        int indexOfThis = siblings.indexOf(this);
        return siblings.elementAt(indexOfThis + 1);
    }
    return null;
}
 
Example 6
Project: ramus   File: AbstractSector.java   View Source Code Vote up 6 votes
protected void getParents(final Crosspoint point, final Vector<Sector> v) {
    if (point == null)
        return;
    final Sector[] s = point.getOppozite(this);
    if (s.length != 1)
        return;
    for (final Sector element : s)
        if (v.indexOf(element) < 0)
            v.add(element);
}
 
Example 7
Project: openjdk-jdk10   File: BuildConfig.java   View Source Code Vote up 6 votes
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 8
Project: QN-ACTR-Release   File: GraphArrivalPanel.java   View Source Code Vote up 6 votes
/**
 * Used when a spinne value is updated
 */
private void setBounds() {
	double xmin, xmax, ymin, ymax;
	Object val;
	String val1 = (String) Xmin.getValue();
	Vector v = (Vector) ((SpinnerListModel) Xmin.getModel()).getList();
	xmin = v.indexOf(val1) + 1;
	String val2 = (String) Xmax.getValue();
	Vector v2 = (Vector) ((SpinnerListModel) Xmax.getModel()).getList();
	xmax = v2.indexOf(val2) + 1;
	val = Ymin.getValue();
	if (val instanceof Number) {
		ymin = ((Number) val).doubleValue();
	} else {
		ymin = graph.getYRange()[0];
	}
	val = Ymax.getValue();
	if (val instanceof Number) {
		ymax = ((Number) val).doubleValue();
	} else {
		ymax = graph.getYRange()[1];
	}

	// Sets bounds
	graph.setXRange(xmin, xmax);
	graph.setYRange(ymin, ymax);
	graph.repaint();
}
 
Example 9
Project: ramus   File: MovingArea.java   View Source Code Vote up 6 votes
private void removeAddedSectors(final Function f) {
    final Vector<PaintSector> v = new Vector<PaintSector>();
    for (int i = 0; i < refactor.getSectorsCount(); i++) {
        final PaintSector s = refactor.getSector(i);
        if (f.equals(s.getSector().getStart().getFunction()))
            if (v.indexOf(s) < 0)
                v.add(s);
        if (f.equals(s.getSector().getEnd().getFunction()))
            if (v.indexOf(s) < 0)
                v.add(s);
    }
    for (int i = 0; i < v.size(); i++)
        v.get(i).remove();
}
 
Example 10
Project: ramus   File: ServerAccessRules.java   View Source Code Vote up 6 votes
@Override
public boolean canDeleteElements(long[] elementIds) {
    Vector<Long> vector = new Vector<Long>();
    for (long elementId : elementIds) {
        Long qualifierId = engine.getQualifierIdForElement(elementId);
        if (vector.indexOf(qualifierId) < 0) {
            if (!isHasAccess(qualifierId.longValue()))
                return false;
        }
        vector.add(qualifierId);
    }
    return true;
}
 
Example 11
Project: ramus   File: HTTPParser.java   View Source Code Vote up 6 votes
private Row[] getSelRows(Qualifier clasificator) {
    final Enumeration e = params.keys();
    Vector v = new Vector();
    final String base = params.get("base");
    if (base == null) {
        while (e.hasMoreElements()) {
            final Object key = e.nextElement();
            final GlobalId id = GlobalId.convert(key.toString());
            if (id != null) {
                if (!params.get(key).equals("")) {
                    final Row r = dataPlugin.findRowByGlobalId(id);
                    if (r != null)
                        v.add(r);
                }
            }
        }
        final Vector rec = dataPlugin.getRecChildren(clasificator);
        final Vector res = new Vector();
        Object tmp;
        for (int i = 0; i < rec.size(); i++)
            if (v.indexOf(tmp = rec.get(i)) >= 0)
                res.add(tmp);
        v = res;
    } else {
        try {
            final Row row = dataPlugin.findRowByGlobalId(GlobalId
                    .convert(base));
            v = dataPlugin.getRecChilds(row, true);
            v.insertElementAt(row, 0);
        } catch (final Exception ex) {

        }
    }
    final Row[] rows = new Row[v.size()];
    for (int i = 0; i < rows.length; i++)
        rows[i] = (Row) v.get(i);
    return rows;
}
 
Example 12
Project: ramus   File: Adder.java   View Source Code Vote up 6 votes
public Vector<Row> getLeft(final Row row) {
    final Vector<Row> res = a.getLeft(row);
    final Vector<Row> t = b.getLeft(row);
    for (int i = 0; i < t.size(); i++) {
        final Row r = t.get(i);
        if (res.indexOf(r) < 0)
            res.add(r);
    }
    return res;
}
 
Example 13
Project: ramus   File: Adder.java   View Source Code Vote up 6 votes
public Vector<Row> getRight(final Row row) {
    final Vector<Row> res = a.getRight(row);
    final Vector<Row> t = b.getRight(row);
    for (int i = 0; i < t.size(); i++) {
        final Row r = t.get(i);
        if (res.indexOf(r) < 0)
            res.add(r);
    }
    return res;
}
 
Example 14
Project: ramus   File: NFunction.java   View Source Code Vote up 6 votes
private void addRow(final Vector<Row> res, Vector<GlobalId> ids,
                    final Row row) {
    if (ids.indexOf(GlobalId.create(engine
            .getQualifierIdForElement(((com.ramussoft.database.common.Row) row)
                    .getElementId()))) >= 0)
        res.add(row);
}
 
Example 15
Project: ramus   File: AbstractSector.java   View Source Code Vote up 6 votes
/**
 * Повертає масив потоків пов’язаних з масивом секторів.
 *
 * @param sectors Масив секторів, з якого буде виділений масив потоків.
 * @return Масив потоків, виділений з масиву секторів.
 */

protected Stream[] getStreams(final Sector[] sectors) {
    final Vector<Stream> v = new Vector<Stream>();
    for (final Sector element : sectors)
        if (element.getStream() != null)
            if (v.indexOf(element.getStream()) < 0)
                v.add(element.getStream());
    final Stream[] streams = new Stream[v.size()];
    for (int i = 0; i < v.size(); i++)
        streams[i] = v.get(i);
    return streams;
}
 
Example 16
Project: jmt   File: QueueNetAnimation.java   View Source Code Vote up 5 votes
private Vector<Object> addElementToPath(Vector<Object> coveredPath, StationAnimation pathEnd) {
	Object lastElement = coveredPath.get(coveredPath.size() - 1);
	//If destination is reached, start building path in reverse order...
	if (lastElement.equals(pathEnd)) {
		//Do not accept degenerate (e.g. one step-) paths
		if (coveredPath.size() > 1) {
			return coveredPath;
		}
	}
	//Test if I'm on a cycle...
	if (coveredPath.indexOf(lastElement) != coveredPath.size() - 1) {
		return null;
	}
	//find which is successor node for lastelement
	Object obj = links.get(lastElement);
	//no successors, exploration failed!
	if (obj == null) {
		return null;
	}
	//if i am currently on a link, continue walking...
	if (lastElement instanceof EdgeAnimation) {
		coveredPath.add(obj);
		return addElementToPath(coveredPath, pathEnd);
	}
	/*until a dead end or a cycle (e.g. a station already contained in path) is not reached,
	keep exploring the net.*/
	if (obj instanceof Vector) {
		Vector v = (Vector) obj;
		//if lastElement is a dead end
		if (v.size() == 0) {
			return null;
		}
		//if lastElement has only one successor node, i can continue on that path, otherwise
		//I must fork execution and clone coveredPath to avoid aliasing.
		if (v.size() == 1) {
			coveredPath.add(v.get(v.size() - 1));
			return addElementToPath(coveredPath, pathEnd);
		} else {
			for (int i = 0; i < v.size(); i++) {
				Object newNode = v.get(i);
				//clone only when necessary!
				if (i != 0) {
					coveredPath = new Vector<Object>(coveredPath);
				}
				coveredPath.add(newNode);
				Vector<Object> returnValue = addElementToPath(coveredPath, pathEnd);
				if (returnValue != null) {
					return returnValue;
				}
			}
			return null;
		}
	}
	return null;
}
 
Example 17
Project: ramus   File: AbstractSector.java   View Source Code Vote up 5 votes
public boolean isConnectedOnFunction(final Sector sector) {
    final Vector<Sector> v = new Vector<Sector>();
    getConnectedOnFunction(v);
    return v.indexOf(sector) >= 0;
}
 
Example 18
Project: QN-ACTR-Release   File: QueueNetAnimation.java   View Source Code Vote up 5 votes
private Vector<Object> addElementToPath(Vector<Object> coveredPath, StationAnimation pathEnd) {
	Object lastElement = coveredPath.get(coveredPath.size() - 1);
	//If destination is reached, start building path in reverse order...
	if (lastElement.equals(pathEnd)) {
		//Don't accept degenerate (e.g. one step-) paths
		if (coveredPath.size() > 1) {
			return coveredPath;
		}
	}
	//Test if I'm on a cycle...
	if (coveredPath.indexOf(lastElement) != coveredPath.size() - 1) {
		return null;
	}
	//find which is successor node for lastelement
	Object obj = links.get(lastElement);
	//no successors, exploration failed!
	if (obj == null) {
		return null;
	}
	//if i am currently on a link, continue walking...
	if (lastElement instanceof EdgeAnimation) {
		coveredPath.add(obj);
		return addElementToPath(coveredPath, pathEnd);
	}
	/*until a dead end or a cycle (e.g. a station already contained in path) is not reached,
	keep exploring the net.*/
	if (obj instanceof Vector) {
		Vector v = (Vector) obj;
		//if lastElement is a dead end
		if (v.size() == 0) {
			return null;
		}
		//if lastElement has only one successor node, i can continue on that path, otherwise
		//I must fork execution and clone coveredPath to avoid aliasing.
		if (v.size() == 1) {
			coveredPath.add(v.get(v.size() - 1));
			return addElementToPath(coveredPath, pathEnd);
		} else {
			for (int i = 0; i < v.size(); i++) {
				Object newNode = v.get(i);
				//clone only when neccessary!
				if (i != 0) {
					coveredPath = new Vector<Object>(coveredPath);
				}
				coveredPath.add(newNode);
				Vector<Object> returnValue = addElementToPath(coveredPath, pathEnd);
				if (returnValue != null) {
					return returnValue;
				}
			}
			return null;
		}
	}
	return null;
}
 
Example 19
Project: openjdk-jdk10   File: CompoundType.java   View Source Code Vote up 5 votes
protected Vector updateParentClassMethods(ClassDefinition current,
                                          Vector currentMethods,
                                          boolean quiet,
                                          ContextStack stack)
    throws ClassNotFound {

    ClassDeclaration parentDecl = current.getSuperClass(env);

    while (parentDecl != null) {

        ClassDefinition parentDef = parentDecl.getClassDefinition(env);
        Identifier currentID = parentDecl.getName();

        if ( currentID == idJavaLangObject ) break;

        // Walk all members of this class and update any that
        // already exist in currentMethods...

        for (MemberDefinition member = parentDef.getFirstMember();
             member != null;
             member = member.getNextMember()) {

            if (member.isMethod() &&
                !member.isInitializer() &&
                !member.isConstructor() &&
                !member.isPrivate()) {

                // It's a method.  Is it valid?

                Method method;
                try {
                    method = new Method((CompoundType)this,member,quiet,stack);
                } catch (Exception e) {
                    // Don't report anything here, it's already been reported...
                    return null;
                }

                // Have we already seen it?

                int index = currentMethods.indexOf(method);
                if (index >= 0) {

                    // Yes, so update it...

                    Method currentMethod = (Method)currentMethods.elementAt(index);
                    currentMethod.setDeclaredBy(currentID);
                }
                else currentMethods.addElement(method);
            }
        }

        // Update parent and keep walking up the chain...

        parentDecl = parentDef.getSuperClass(env);
    }

    return currentMethods;
}
 
Example 20
Project: ramus   File: AbstractSector.java   View Source Code Vote up 4 votes
/**
 * Метод повертає набір дочірніх до сектора секторів.
 *
 * @param point Точка дочірні сектори з якої беруться.
 * @return Масив дочірніх то сектора секторів, які пов’язані через точку.
 */

protected void getChilds(final Crosspoint point, final Vector<Sector> v) {
    if (point == null || point.isChild(this))
        return;
    final Sector[] s = point.getOppozite(this);
    for (final Sector element : s)
        if (v.indexOf(element) < 0)
            v.add(element);
}