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

x33g5p2x  于2022-01-29 转载在 其他  
字(6.6k)|赞(0)|评价(0)|浏览(122)

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

SortedSet.retainAll介绍

暂无

代码示例

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

commonNodes.retainAll(v2Nodes);

代码示例来源:origin: google/guava

public void testElementSetSubsetRetainAll() {
 TreeMultiset<String> ms = TreeMultiset.create();
 ms.add("a", 1);
 ms.add("b", 3);
 ms.add("c", 2);
 ms.add("d", 1);
 ms.add("e", 3);
 ms.add("f", 2);
 SortedSet<String> elementSet = ms.elementSet();
 assertThat(elementSet).containsExactly("a", "b", "c", "d", "e", "f").inOrder();
 SortedSet<String> subset = elementSet.subSet("b", "f");
 assertThat(subset).containsExactly("b", "c", "d", "e").inOrder();
 assertTrue(subset.retainAll(Arrays.asList("a", "c")));
 assertThat(elementSet).containsExactly("a", "c", "f").inOrder();
 assertThat(subset).containsExactly("c");
 assertEquals(5, ms.size());
}

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

merged.retainAll( results );

代码示例来源:origin: com.aol.cyclops/cyclops-core

/**
 * @param c
 * @return
 * @see java.util.AbstractCollection#retainAll(java.util.Collection)
 */
public boolean retainAll(Collection<?> c) {
  return set.retainAll(c);
}

代码示例来源:origin: org.terracotta/product-upgradability-testing-utils

@Override
public boolean retainAll(Collection<?> clctn) {
 return sortedSet.retainAll(clctn);
}

代码示例来源:origin: com.google.guava/guava-testlib-jdk5

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

代码示例来源:origin: harbby/presto-connectors

@Override
public synchronized boolean retainAll(Collection<?> c) {
 SortedSet<E> newSet = new TreeSet<E>(internalSet);
 boolean changed = newSet.retainAll(c);
 internalSet = newSet;
 return changed;
}

代码示例来源:origin: co.cask.hbase/hbase

@Override
public synchronized boolean retainAll(Collection<?> c) {
 SortedSet<E> newSet = new TreeSet<E>(internalSet);
 boolean changed = newSet.retainAll(c);
 internalSet = newSet;
 return changed;
}

代码示例来源:origin: NationalSecurityAgency/datawave

@Override
public boolean retainAll(Collection<?> c) {
  if (persisted) {
    throw new IllegalStateException("Unable to modify a persisted FileSortedSet.  Please call load() first.");
  } else {
    return set.retainAll(c);
  }
}

代码示例来源:origin: FenixEdu/fenixedu-academic

public void setMobilityGroupsAsList(List<OutboundMobilityCandidacyContestGroup> mobilityGroupsAsList) {
  this.mobilityGroups.retainAll(mobilityGroupsAsList);
  this.mobilityGroups.addAll(mobilityGroupsAsList);
}

代码示例来源:origin: ujmp/universal-java-matrix-package

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

代码示例来源:origin: FenixEdu/fenixedu-academic

public void setCandidacyPeriodsAsList(List<OutboundMobilityCandidacyPeriod> candidacyPeriodsAsList) {
  this.candidacyPeriods.retainAll(candidacyPeriodsAsList);
  this.candidacyPeriods.addAll(candidacyPeriodsAsList);
}

代码示例来源:origin: FenixEdu/fenixedu-academic

public void setMobilityProgramsAsList(List<MobilityProgram> mobilityProgramsAsList) {
  this.mobilityPrograms.retainAll(mobilityProgramsAsList);
  this.mobilityPrograms.addAll(mobilityProgramsAsList);
}

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

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

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

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

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

/**
 * Returns the attribute Definitions which are shared by all subclasses of this JavaBaseClass
 *
 * @return attributes
 */
public PuzzlePieceSet getBaseAttributes() {
  SortedSet<PuzzlePiece> attributes = new TreeSet<PuzzlePiece>(mSubelements.last().getAttributes());
  for (PuzzlePiece subelement : mSubelements.headSet(mSubelements.last())) {
    attributes.retainAll(subelement.getAttributes());
  }
  return new PuzzlePieceSet(attributes);
}

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

/**
 * Returns the attribute Definitions which are shared by all subclasses of this JavaBaseClass
 *
 * @return attributes
 */
public PuzzlePieceSet getBaseAttributes() {
  SortedSet<PuzzlePiece> attributes = new TreeSet<PuzzlePiece>(mSubelements.last().getAttributes());
  for (PuzzlePiece subelement : mSubelements.headSet(mSubelements.last())) {
    attributes.retainAll(subelement.getAttributes());
  }
  return new PuzzlePieceSet(attributes);
}

代码示例来源:origin: girtel/Net2Plan

/** Returns the set of the optical slots ids that are idle in ALL the fibers provided 
 * @param wdmLinks the set of fibers
 * @return see above
 */
public SortedSet<Integer> getAvailableSlotIds (Collection<WFiber> wdmLinks)
{
  if (wdmLinks.isEmpty()) throw new Net2PlanException ("No WDM links");
  final SortedSet<Integer> validSlotIds = this.getIdleOpticalSlotIds(wdmLinks.iterator().next());
  final Iterator<WFiber> itLink = wdmLinks.iterator();
  itLink.next();
  while (itLink.hasNext())
    validSlotIds.retainAll(this.getIdleOpticalSlotIds(itLink.next()));
  return validSlotIds;
}

代码示例来源:origin: UKPLab/argument-reasoning-comprehension-task

private static double computeKappa(SortedMap<String, String> expert1Labels,
      SortedMap<String, String> expert2Labels)
      throws IOException
  {
    // intersection
    SortedSet<String> intersectionIDs = new TreeSet<>();
    intersectionIDs.addAll(expert1Labels.keySet());
    intersectionIDs.retainAll(expert2Labels.keySet());

    CodingAnnotationStudy study = new CodingAnnotationStudy(2);

    for (String id : intersectionIDs) {
      String expert1 = expert1Labels.get(id);
      String expert2 = expert2Labels.get(id);
      study.addItem(expert1, expert2);
    }

    CohenKappaAgreement kappa = new CohenKappaAgreement(study);

    return kappa.calculateCategoryAgreement("3");
  }
}

代码示例来源:origin: com.google.guava/guava-tests

public void testElementSetSubsetRetainAll() {
 TreeMultiset<String> ms = TreeMultiset.create();
 ms.add("a", 1);
 ms.add("b", 3);
 ms.add("c", 2);
 ms.add("d", 1);
 ms.add("e", 3);
 ms.add("f", 2);
 SortedSet<String> elementSet = ms.elementSet();
 assertThat(elementSet).containsExactly("a", "b", "c", "d", "e", "f").inOrder();
 SortedSet<String> subset = elementSet.subSet("b", "f");
 assertThat(subset).containsExactly("b", "c", "d", "e").inOrder();
 assertTrue(subset.retainAll(Arrays.asList("a", "c")));
 assertThat(elementSet).containsExactly("a", "c", "f").inOrder();
 assertThat(subset).containsExactly("c");
 assertEquals(5, ms.size());
}

相关文章