Here you can find the source of equalVectors(Vector aV1, Vector aV2)
Vector
instances.
Parameter | Description |
---|---|
aV1 | First Vector instance to compare. |
aV2 | Second Vector instance to compare. |
true
if Vector's are equal; false
otherwise.
public static boolean equalVectors(Vector aV1, Vector aV2)
//package com.java2s; /*********************************************************** Copyright (C) 2004 VeriSign, Inc.//from w w w . j av 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 { /** * compares two <code>Vector</code> instances. The Java 1.1 * <code>Vector</code> class does not implement the <code>equals</code> * methods, so <code>equalVectors</code> was written to implement * <code>equals</code> of two <code>Vectors</code> (aV1 and aV2). This * method is not need for Java 2. * * @param aV1 * First Vector instance to compare. * @param aV2 * Second Vector instance to compare. * @return <code>true</code> if Vector's are equal; <code>false</code> * otherwise. */ public static boolean equalVectors(Vector aV1, Vector aV2) { if ((aV1 == null) && (aV2 == null)) { return true; } else if ((aV1 != null) && (aV2 != null)) { if (aV1.size() != aV2.size()) { return false; } for (int i = 0; i < aV1.size(); i++) { Object elm1 = aV1.elementAt(i); Object elm2 = aV2.elementAt(i); if (!((elm1 == null) ? (elm2 == null) : elm1.equals(elm2))) { return false; } } return true; } else { return false; } } }