I have a HashMap and I\'d like to iterate they key-value pairs in a different random order each time i get the iterator. Conceptually I\'d like to \"shuffle\" the map before
Reshuffling a large collection is always going to be expensive. You are going to need at least one reference per entry. e.g. for 1 million entries you will need approx 4 MB.
Note; the shuffle operation is O(N)
I would use
Map map =
List> list = new ArrayList>(map.entrySet());
// each time you want a different order.
Collections.shuffle(list);
for(Map.Entry entry: list) { /* ... */ }