So I have a hashmap that has keys and objects. I was wondering if it was possible to create a number of permutations with the keys. So for example if i had:
1 - Object1 2 - Object2 3 - Object3 4 - Object4
To get a random order. So one outcome may be:
3 - Object3 1 - Object1 2 - Object2 4 - Object4
So far i have:
Map<Integer, GeoPoint> mapPoints = new HashMap<Integer, GeoPoint>();
Map<Integer, GeoPoint> mapPointsShuffle = new HashMap<Integer, GeoPoint>();
for (int t =0; t < 50; t ++){
Collections.shuffle((List<?>) mapPoints);
mapPointsShuffle.putAll(mapPoints);
}
So the idea is to give me 50 random permutations. But it comes back with :
09-26 11:15:27.813: E/AndroidRuntime(20434): java.lang.ClassCastException: java.util.HashMap cannot be cast to java.util.List
Any ideas?