Java tutorial
//package com.java2s; //License from project: Open Source License import java.util.HashMap; public class Main { /** * The security value is the sum of deviations between the distance * of one specific place and all the other ones in the placeDistanceMap. * * @param distanceAtOnePlace the distance for one specific place * @param placeDistanceMap the place distance map that the single gets compared to * @return the double value of the sum of deviation, also called "security value" */ public static double securityValue(double distanceAtOnePlace, HashMap<String, Double> placeDistanceMap) { double sumDeviation = 0; for (String key : placeDistanceMap.keySet()) { sumDeviation += Math.abs(distanceAtOnePlace - placeDistanceMap.get(key)); } return sumDeviation; } }