mirror of
				https://gitee.com/dromara/hutool.git
				synced 2025-10-26 18:59:23 +08:00 
			
		
		
		
	修复:RandomUtil的randomEleSet方法在某些情况下无法随机的情况
This commit is contained in:
		| @@ -8,7 +8,7 @@ import java.security.SecureRandom; | ||||
| import java.util.ArrayList; | ||||
| import java.util.Collection; | ||||
| import java.util.Date; | ||||
| import java.util.HashSet; | ||||
| import java.util.LinkedHashSet; | ||||
| import java.util.List; | ||||
| import java.util.Random; | ||||
| import java.util.Set; | ||||
| @@ -366,7 +366,7 @@ public class RandomUtil { | ||||
| 			throw new IllegalArgumentException("Count is larger than collection distinct size !"); | ||||
| 		} | ||||
|  | ||||
| 		final HashSet<T> result = new HashSet<>(count); | ||||
| 		final Set<T> result = new LinkedHashSet<>(count); | ||||
| 		int limit = source.size(); | ||||
| 		while (result.size() < count) { | ||||
| 			result.add(randomEle(source, limit)); | ||||
|   | ||||
		Reference in New Issue
	
	Block a user
	 NanCheung
					NanCheung