iterator adapter to iterate just the values in a map?

Replacing the previous answer, in case anybody else finds this like I did. As of boost 1.43, there are some commonly used range adaptors provided. In this case, you want boost::adaptors::map_values. The relevant example: http://www.boost.org/doc/libs/1_46_0/libs/range/doc/html/range/reference/adaptors/reference/map_values.html#range.reference.adaptors.reference.map_values.map_values_example

Google Maps Android API v2 – Sample Code crashes

Follow the crib sheet very, very carefully: https://docs.google.com/document/pub?id=19nQzvKP-CVLd7_VrpwnHfl-AE9fjbJySowONZZtNHzw In particular, I think you need to: Import the actual source for the “google-play-services_lib” project and link it as an Android library. Do this through Project -> Properties -> Android -> Library, Add -> google-play-services_lib (you can right click on your project and choose Properties, then select … Read more

get latitude and longitude with geocoder and android Google Maps API v2

Try this solution using this example url: http://maps.google.com/maps/api/geocode/json?address=mumbai&sensor=false which returns data in json format with lat/lng of address. private class DataLongOperationAsynchTask extends AsyncTask<String, Void, String[]> { ProgressDialog dialog = new ProgressDialog(MainActivity.this); @Override protected void onPreExecute() { super.onPreExecute(); dialog.setMessage(“Please wait…”); dialog.setCanceledOnTouchOutside(false); dialog.show(); } @Override protected String[] doInBackground(String… params) { String response; try { response = getLatLongByURL(“http://maps.google.com/maps/api/geocode/json?address=mumbai&sensor=false”); … Read more

Calculate distance given 2 points, latitude and longitude [duplicate]

You can use the formula that calculates distances between two points. For example: function get_distance($latitude1, $longitude1, $latitude2, $longitude2, $unit=”Mi”) { $theta = $longitude1 – $longitude2; $distance = (sin(deg2rad($latitude1)) * sin(deg2rad($latitude2))) + (cos(deg2rad($latitude1)) * cos(deg2rad($latitude2)) * cos(deg2rad($theta))); $distance = acos($distance); $distance = rad2deg($distance); $distance = $distance * 60 * 1.1515; switch($unit) { case ‘Mi’: break; case … Read more

Accessing the last entry in a Map

To answer your question in one sentence: Per default, Maps don’t have a last entry, it’s not part of their contract. And a side note: it’s good practice to code against interfaces, not the implementation classes (see Effective Java by Joshua Bloch, Chapter 8, Item 52: Refer to objects by their interfaces). So your declaration … Read more