Collections.shuffle multiple times in a row
I got a little question about the Collections.shuffle() method.
Case:
I have 2 lists i need to shuffle, then union / merge them into one list,
then shuffle the new complete list. I have used the shuffle method with
the Random class - using system.nanoTime() as seed.
Code looks as below:
public List<PresentationArticle>
shuffleUnionShuffleLists(List<PresentationArticle> nykreditJobAdsList,
List<PresentationArticle> boxJobAdsList) {
shuffleList(nykreditJobAdsList);
shuffleList(boxJobAdsList);
List<PresentationArticle> resultList = //merge/union the two lists
shuffleList(resultList);
return resultList;
}
public void shuffleList(List<PresentationArticle> articleList) {
long seed = System.nanoTime();
Collections.shuffle(articleList, new Random(seed));
}
My question is: Will this be a proper random shuffling of the lists, when
the methods runs right after eachother, with a new Random object and a new
(but almost identical) seed?
The method shuffleUnionShuffleLists() will be run approximately every 3
minutes.
No comments:
Post a Comment