Main.java Source code

Java tutorial

Introduction

Here is the source code for Main.java

Source

//package com.java2s;
//License from project: Open Source License 

import java.util.HashMap;

import java.util.Map;

public class Main {
    /**
     * Returns the minimum entry of the placeDistanceMap
     *
     * @param placeDistanceMap the map containing the distance to all
     *                         places from the last position of the measurement
     * @return the minimum entry of the placeDistanceMap
     */
    public static Map.Entry<String, Double> minMapValue(HashMap<String, Double> placeDistanceMap) {
        Map.Entry<String, Double> min = null;
        if (placeDistanceMap != null) {
            for (Map.Entry<String, Double> entry : placeDistanceMap.entrySet()) {
                if (min == null || min.getValue() > entry.getValue()) {
                    if (entry.getValue() != 0) {
                        min = entry;
                    }
                }

            }
        }
        return min;
    }
}