Java Vector vectorSubset(Vector aV1, Vector aV2)

Here you can find the source of vectorSubset(Vector aV1, Vector aV2)

Description

Determines if one Vector is a subset of another Vector.

License

Open Source License

Parameter

Parameter Description
aV1 Subset <code>Vector</code> to compare against <code>aV2</code>
aV2 Superset <code>Vector</code> to compare against <code>aV1</code>

Return

true if aV1 is a subset of aV2; false otherwise.

Declaration

public static boolean vectorSubset(Vector aV1, Vector aV2) 

Method Source Code

//package com.java2s;
/***********************************************************
 Copyright (C) 2004 VeriSign, Inc.//from   w  w  w  .  ja  v  a 2 s.c o m

 This library is free software; you can redistribute it and/or
 modify it under the terms of the GNU Lesser General Public
 License as published by the Free Software Foundation; either
 version 2.1 of the License, or (at your option) any later version.

 This library is distributed in the hope that it will be useful,
 but WITHOUT ANY WARRANTY; without even the implied warranty of
 MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU
 Lesser General Public License for more details.

 You should have received a copy of the GNU Lesser General Public
 License along with this library; if not, write to the Free Software
 Foundation, Inc., 59 Temple Place, Suite 330, Boston, MA 02111-1307 USA

 http://www.verisign.com/nds/naming/namestore/techdocs.html
 ***********************************************************/

import java.util.*;

public class Main {
    /**
     * Determines if one <code>Vector</code> is a subset of another
     * <code>Vector</code>. If every element in <code>aV1</code> is in
     * <code>aV2</code> return <code>true</code>; otherwise return
     * <code>false</code>.
     * 
     * @param aV1
     *            Subset <code>Vector</code> to compare against <code>aV2</code>
     * @param aV2
     *            Superset <code>Vector</code> to compare against
     *            <code>aV1</code>
     * @return <code>true</code> if <code>aV1</code> is a subset of
     *         <code>aV2</code>; <code>false</code> otherwise.
     */
    public static boolean vectorSubset(Vector aV1, Vector aV2) {
        Enumeration v1Enum = aV1.elements();

        while (v1Enum.hasMoreElements()) {
            if (!aV2.contains(v1Enum.nextElement())) {
                return false;
            }
        }

        return true;
    }
}

Related

  1. vectorL2Norm(double[] v)
  2. vectorLog10(double v1[])
  3. vectorMagnitude4D(float[][][][] vec4D)
  4. vectorSimilarity(float[] wordVector1, float[] wordVector2)
  5. vectorSizeToBucketNum(int vectorSize)
  6. vectorValue(double[] x)