What does "shuffled" look like to you? There's no order for keys in HashMap
. You need a LinkedHashMap
to preserve insertion order.
Shuffling the Collection
of keys won't affect the Map
per se; you iterate over it to access the Map
keys.
See if this gives you a different ordering after you run it.
Map<Integer, GeoPoint> mapPoints = new HashMap<Integer, GeoPoint>();
System.out.println("before shuffle ");
Set<Integer> keys = mapPoints.keySet();
for (int key : keys) {
System.out.println("key : " + key + " value: " + mapPoints.get(key));
}
Collections.shuffle(keys); // don't know why multiple shuffles are required. deck of cards?
System.out.println("after shuffle ");
for (int key : keys) {
System.out.println("key : " + key + " value: " + mapPoints.get(key));
}