Package java.util

Examples of java.util.HashSet.retainAll()


    public static boolean isIntersectionEmpty(Set<?> a, Set<?> b) {
        if (a != null && b != null) {
            Set<?> aTemp = new HashSet(a);
            Set<?> bTemp = new HashSet(b);
            aTemp.retainAll(bTemp);
            bTemp.retainAll(aTemp);
            return !(aTemp.size() > 0 && bTemp.size() > 0);
        }
        return true;
    }
}
View Full Code Here


    protected Token _add(Token rightArgument) throws IllegalActionException {
        RecordToken recordToken = (RecordToken) rightArgument;

        Set intersectionSet = new HashSet();
        intersectionSet.addAll(_fields.keySet());
        intersectionSet.retainAll(recordToken._fields.keySet());

        Iterator labels = intersectionSet.iterator();
        int size = intersectionSet.size();
        String[] newLabels = new String[size];
        Token[] newValues = new Token[size];
View Full Code Here

    protected Token _divide(Token rightArgument) throws IllegalActionException {
        RecordToken recordToken = (RecordToken) rightArgument;

        Set intersectionSet = new HashSet();
        intersectionSet.addAll(_fields.keySet());
        intersectionSet.retainAll(recordToken._fields.keySet());

        Iterator labels = intersectionSet.iterator();
        int size = intersectionSet.size();
        String[] newLabels = new String[size];
        Token[] newValues = new Token[size];
View Full Code Here

    protected Token _modulo(Token rightArgument) throws IllegalActionException {
        RecordToken recordToken = (RecordToken) rightArgument;

        Set intersectionSet = new HashSet();
        intersectionSet.addAll(_fields.keySet());
        intersectionSet.retainAll(recordToken._fields.keySet());

        Iterator labels = intersectionSet.iterator();
        int size = intersectionSet.size();
        String[] newLabels = new String[size];
        Token[] newValues = new Token[size];
View Full Code Here

            throws IllegalActionException {
        RecordToken recordToken = (RecordToken) rightArgument;

        Set intersectionSet = new HashSet();
        intersectionSet.addAll(_fields.keySet());
        intersectionSet.retainAll(recordToken._fields.keySet());

        Iterator labels = intersectionSet.iterator();
        int size = intersectionSet.size();
        String[] newLabels = new String[size];
        Token[] newValues = new Token[size];
View Full Code Here

            throws IllegalActionException {
        RecordToken recordToken = (RecordToken) rightArgument;

        Set intersectionSet = new HashSet();
        intersectionSet.addAll(_fields.keySet());
        intersectionSet.retainAll(recordToken._fields.keySet());

        Iterator labels = intersectionSet.iterator();
        int size = intersectionSet.size();
        String[] newLabels = new String[size];
        Token[] newValues = new Token[size];
View Full Code Here

        Set intersectionSet = new HashSet();
        Set myLabelSet = _fields.keySet();
        Set argLabelSet = recordType._fields.keySet();

        intersectionSet.addAll(myLabelSet);
        intersectionSet.retainAll(argLabelSet);

        // construct the GLB RecordToken
        Object[] labelArray = intersectionSet.toArray();
        int size = labelArray.length;
        String[] labels = new String[size];
View Full Code Here

        Set intersectionSet = new HashSet();
        Set myLabelSet = _fields.keySet();
        Set argLabelSet = unionType._fields.keySet();

        intersectionSet.addAll(myLabelSet);
        intersectionSet.retainAll(argLabelSet);

        // construct the GLB UnionToken
        Object[] labelArray = intersectionSet.toArray();
        int size = labelArray.length;
        String[] labels = new String[size];
View Full Code Here

     @return A RecordToken containing the result.
     */
    public static Token intersect(RecordToken record1, RecordToken record2)
            throws IllegalActionException {
        Set commonNames = new HashSet(record1.labelSet());
        commonNames.retainAll(record2.labelSet());

        Token[] values = new Token[commonNames.size()];
        String[] names = new String[values.length];
        int i = 0;

View Full Code Here

                        Object oa = ((ObjectToken) a).getValue();
                        Object ob = ((ObjectToken) b).getValue();

                        if (oa instanceof Set && ob instanceof Collection) {
                            Set result = new HashSet((Set) oa);
                            result.retainAll((Collection) ob);
                            return new ObjectToken(result);
                        } else {
                            throw new InterpreterException(
                                    "Unknown object types: expected Set and Collection.");
                        }
View Full Code Here

TOP
Copyright © 2018 www.massapi.com. All rights reserved.
All source code are property of their respective owners. Java is a trademark of Sun Microsystems, Inc and owned by ORACLE Inc. Contact coftware#gmail.com.