Here you can find the source of getClosestStore(ArrayList
public static int getClosestStore(ArrayList<Integer> storeIds, SparseArray<Float> distanceMap)
//package com.java2s; import android.util.SparseArray; import java.util.ArrayList; public class Main { public static int getClosestStore(ArrayList<Integer> storeIds, SparseArray<Float> distanceMap) { /*//w ww .java2 s .c om * storeIds: list of store_ids * distanceMap: <store_id, distance> * * Returns the store_id of the store with the minimal distance from the user's last known location */ float closestDistance = -1; int closestStore = 0; if (storeIds != null && distanceMap != null) { for (int j = 0; j < storeIds.size(); j++) { float nextDistance = distanceMap.get(storeIds.get(j)); if (closestDistance < 0 || nextDistance < closestDistance) { closestDistance = nextDistance; closestStore = storeIds.get(j); } } } return closestStore; } }