Android Distance Calculate hammingDistance(String sourceHashCode, String hashCode)

Here you can find the source of hammingDistance(String sourceHashCode, String hashCode)

Description

hamming Distance

License

Apache License

Declaration

public static int hammingDistance(String sourceHashCode, String hashCode) 

Method Source Code

//package com.java2s;
/*/*from   w  w  w  .  j a  va2  s. co m*/
 * Copyright (C) 2013 www.418log.org
 * 
 * Licensed under the Apache License, Version 2.0 (the "License");
 * you may not use this file except in compliance with the License.
 * You may obtain a copy of the License at
 *
 *     http://www.apache.org/licenses/LICENSE-2.0
 *
 * Unless required by applicable law or agreed to in writing, software
 * distributed under the License is distributed on an "AS IS" BASIS,
 * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
 * See the License for the specific language governing permissions and
 * limitations under the License.
 */

public class Main {

    public static int hammingDistance(String sourceHashCode, String hashCode) {
        int difference = 0;
        int len = sourceHashCode.length();
        for (int i = 0; i < len; i++) {
            if (sourceHashCode.charAt(i) != hashCode.charAt(i)) {
                difference++;
            }
        }
        return difference;
    }
}

Related

  1. distanceInMeters(float distance)
  2. distanceBetweenTwoPoints(double lat1, double lng1, double lat2, double lng2)
  3. KmToMiles(int distance)
  4. getTempsTrajetBus(int distance)
  5. getTempsTrajetPied(int distance)
  6. getMessageForDistance(long distance)
  7. calculateEte(boolean useBearing, double distance, double speed, double bearing, double heading)
  8. fetchRawEte(boolean useBearing, double distance, double speed, double bearing, double heading)
  9. distance(double lat1, double lon1, double lat2, double lon2, char unit)