没废话
/**
* 将list集合内容打散
*
* @param list
* 要打散的list
* @param n
* 要打散前n个
* @return 返回打散后的list
*/
private List<ImagePiece> createRandomList(List<ImagePiece> list, int n) {
Map<Integer, String> mmap = new HashMap<Integer, String>();
List<ImagePiece> mlistNew = new ArrayList<ImagePiece>();
while (mmap.size() < n) {
int random = (int) (Math.random() * list.size());
if (!mmap.containsKey(random)) {
mmap.put(random, "");
mlistNew.add(list.get(random));
}
}
return listNew;
}