This commit is contained in:
looly
2021-11-30 17:05:57 +08:00
parent 5ba1dde50d
commit cc72350385
4 changed files with 10 additions and 8 deletions

View File

@@ -1299,14 +1299,14 @@ public class CollUtil {
* @param <E> 集合元素类型
* @param resultCollection 存放移除结果的集合
* @param targetCollection 被操作移除元素的集合
* @param filter 用于是否移除判断的过滤器
* @param predicate 用于是否移除判断的过滤器
*/
public static <T extends Collection<E>, E> T removeWithAddIf(T targetCollection, T resultCollection, Predicate<? super E> filter) {
Objects.requireNonNull(filter);
public static <T extends Collection<E>, E> T removeWithAddIf(T targetCollection, T resultCollection, Predicate<? super E> predicate) {
Objects.requireNonNull(predicate);
final Iterator<E> each = targetCollection.iterator();
while (each.hasNext()) {
E next = each.next();
if (filter.test(next)) {
if (predicate.test(next)) {
resultCollection.add(next);
each.remove();
}

View File

@@ -56,7 +56,8 @@ public class RingIndexUtil {
}
/**
* 通过cas操作 实现对指定值内的回环累加
* 通过cas操作 实现对指定值内的回环累加<br>
* 此方法一般用于大量数据完成回环累加如数据库中的值大于int最大值
*
* @param modulo 回环周期值
* @param atomicLong 原子操作类