java.util.ArrayList.retainAll()方法的使用及代码示例

x33g5p2x  于2022-01-15 转载在 其他  
字(5.2k)|赞(0)|评价(0)|浏览(219)

本文整理了Java中java.util.ArrayList.retainAll()方法的一些代码示例,展示了ArrayList.retainAll()的具体用法。这些代码示例主要来源于Github/Stackoverflow/Maven等平台,是从一些精选项目中提取出来的代码,具有较强的参考意义,能在一定程度帮忙到你。ArrayList.retainAll()方法的具体详情如下:
包路径:java.util.ArrayList
类名称:ArrayList
方法名:retainAll

ArrayList.retainAll介绍

[英]Retains only the elements in this list that are contained in the specified collection. In other words, removes from this list all of its elements that are not contained in the specified collection.
[中]仅保留此列表中包含在指定集合中的元素。换句话说,从该列表中删除指定集合中不包含的所有元素。

代码示例

代码示例来源:origin: ltsopensource/light-task-scheduler

public boolean retainAll(Collection<?> c) {
  return list.retainAll(c);
}

代码示例来源:origin: ltsopensource/light-task-scheduler

public boolean retainAll(Collection<?> c) {
  return list.retainAll(c);
}

代码示例来源:origin: Sable/soot

/**
 * {@inheritDoc}
 */
public boolean retainAll(Collection c) {
 return worklist.retainAll(c);
}

代码示例来源:origin: ReactiveX/RxJava

@Override
public boolean retainAll(Collection<?> c) {
  boolean b = list.retainAll(c);
  lazySet(list.size());
  return b;
}

代码示例来源:origin: commons-collections/commons-collections

/**
 * Remove from this collection all of its elements except those that are
 * contained in the specified collection.
 *
 * @param collection Collection containing elements to be retained
 *
 * @exception UnsupportedOperationException if this optional operation
 *  is not supported by this list
 */
public boolean retainAll(Collection collection) {
  if (fast) {
    synchronized (this) {
      ArrayList temp = (ArrayList) list.clone();
      boolean result = temp.retainAll(collection);
      list = temp;
      return (result);
    }
  } else {
    synchronized (list) {
      return (list.retainAll(collection));
    }
  }
}

代码示例来源:origin: apache/hbase

@Override
public synchronized boolean retainAll(Collection<?> c) {
 ArrayList<E> newList = new ArrayList<>(list);
 // Removals in ArrayList won't break sorting
 boolean changed = newList.retainAll(c);
 list = Collections.unmodifiableList(newList);
 return changed;
}

代码示例来源:origin: wildfly/wildfly

/**
 * Remove from this collection all of its elements except those that are
 * contained in the specified collection.
 *
 * @param collection Collection containing elements to be retained
 *
 * @exception UnsupportedOperationException if this optional operation
 *  is not supported by this list
 */
public boolean retainAll(Collection collection) {
  if (fast) {
    synchronized (this) {
      ArrayList temp = (ArrayList) list.clone();
      boolean result = temp.retainAll(collection);
      list = temp;
      return (result);
    }
  } else {
    synchronized (list) {
      return (list.retainAll(collection));
    }
  }
}

代码示例来源:origin: redisson/redisson

@Override
public boolean retainAll(Collection<?> c) {
  boolean b = list.retainAll(c);
  lazySet(list.size());
  return b;
}

代码示例来源:origin: org.jsoup/jsoup

@Override
public boolean retainAll(Collection<?> c) {
  onContentsChanged();
  return super.retainAll(c);
}

代码示例来源:origin: org.apache.avro/avro

public boolean retainAll(Collection<?> c) {
 ensureUnlocked();
 return super.retainAll(c);
}

代码示例来源:origin: apache/avro

public boolean retainAll(Collection<?> c) {
 ensureUnlocked();
 return super.retainAll(c);
}

代码示例来源:origin: igniterealtime/Smack

commonAudioPtsHere.retainAll(remoteAudioPts);
commonAudioPtsThere.retainAll(localAudioPts);

代码示例来源:origin: jankotek/mapdb

ArrayList iteratedAndRemoved = new ArrayList(iterated);
ArrayList spliteratedAndRemoved = new ArrayList(spliterated);
iteratedAndRemoved.retainAll(removed);
spliteratedAndRemoved.retainAll(removed);
assertTrue(iteratedAndRemoved.size() <= 1);
assertTrue(spliteratedAndRemoved.size() <= 1);

代码示例来源:origin: geotools/geotools

/**
 * Retains only the elements in this list that are contained in the specified collection.
 *
 * @throws UnsupportedOperationException if this collection is unmodifiable.
 */
@Override
public boolean retainAll(Collection<?> c) throws UnsupportedOperationException {
  synchronized (getLock()) {
    checkWritePermission();
    return super.retainAll(c);
  }
}

代码示例来源:origin: org.netbeans.api/org-netbeans-modules-java-source-base

@Override
public boolean retainAll(Collection c) {
  Map<RelativePosition, List<Comment>> orig = trackFirstChange() ? getOrigMap() : null;
  boolean r = super.retainAll(c);
  if (orig != null && r) {
    origMap = orig;
  }
  changed |= r;
  return r;
}

代码示例来源:origin: ibinti/bugvm

/**
 * {@inheritDoc}
 */
public boolean retainAll(Collection c) {
  return worklist.retainAll(c);
}

代码示例来源:origin: org.netbeans.modules/org-netbeans-modules-dlight-indicators

private boolean hasInfoToPaint(TimeSeriesDescriptor graph, Collection<Column> providedColumns){
  TimeSeriesDescriptorAccessor accessor = TimeSeriesDescriptorAccessor.getDefault();
  if (providedColumns == null || providedColumns.isEmpty() ||
      accessor.getSourceColumns(graph) == null || accessor.getSourceColumns(graph) .isEmpty()){
    return true;
  }
  //if the  intersection is not empty - returns tru
  ArrayList<Column> list = new ArrayList<Column>(providedColumns);
  list.retainAll(accessor.getSourceColumns(graph));
  return !list.isEmpty();
}

代码示例来源:origin: org.apache.openjpa/openjpa-kernel

public boolean retainAll(Collection paramCollection) {
  if (_directAccess) {
    return super.retainAll(paramCollection);
  }
  if (isDelayLoad()) {
    load();
  }
  return ProxyCollections.retainAll(this, paramCollection);
}

代码示例来源:origin: org.apache.openejb.patch/openjpa-kernel

public boolean retainAll(Collection paramCollection) {
  if (_directAccess) {
    return super.retainAll(paramCollection);
  }
  if (isDelayLoad()) {
    load();
  }
  return ProxyCollections.retainAll(this, paramCollection);
}

代码示例来源:origin: org.seqdoop/htsjdk

@Override
public boolean retainAll(final Collection<?> objects) {
  checkImmutability();
  invalidateSampleNameMap();
  invalidateSampleOrdering();
  return getGenotypes().retainAll(objects);
}

相关文章