com.google.common.collect.LinkedHashMultimap#putAll ( )源码实例Demo

下面列出了com.google.common.collect.LinkedHashMultimap#putAll ( ) 实例代码,或者点击链接到github查看源代码,也可以在右侧发表评论。

源代码1 项目: swellrt   文件: SimpleSearchProviderImpl.java
private LinkedHashMultimap<WaveId, WaveletId> createWavesViewToFilter(final ParticipantId user,
    final boolean isAllQuery) {
  LinkedHashMultimap<WaveId, WaveletId> currentUserWavesView;
  currentUserWavesView = LinkedHashMultimap.create();
  currentUserWavesView.putAll(waveViewProvider.retrievePerUserWaveView(user));
  if (isAllQuery) {
    // If it is the "all" query - we need to include also waves view of the
    // shared domain participant.
    currentUserWavesView.putAll(waveViewProvider.retrievePerUserWaveView(sharedDomainParticipantId));
  }

  if(LOG.isFineLoggable()) {
    for (Map.Entry<WaveId, WaveletId> e : currentUserWavesView.entries()) {
      LOG.fine("unfiltered view contains: " + e.getKey() + " " + e.getValue());
    }
  }

  return currentUserWavesView;
}
 
private LinkedHashMultimap<WaveId, WaveletId> createWavesViewToFilter(final ParticipantId user,
    final boolean isAllQuery) {
  LinkedHashMultimap<WaveId, WaveletId> currentUserWavesView;
  currentUserWavesView = LinkedHashMultimap.create();
  currentUserWavesView.putAll(waveViewProvider.retrievePerUserWaveView(user));
  if (isAllQuery) {
    // If it is the "all" query - we need to include also waves view of the
    // shared domain participant.
    currentUserWavesView.putAll(waveViewProvider.retrievePerUserWaveView(sharedDomainParticipantId));
  }

  if(LOG.isFineLoggable()) {
    for (Map.Entry<WaveId, WaveletId> e : currentUserWavesView.entries()) {
      LOG.fine("unfiltered view contains: " + e.getKey() + " " + e.getValue());
    }
  }

  return currentUserWavesView;
}
 
源代码3 项目: buck   文件: TargetSpecResolver.java
private ImmutableList<ImmutableSet<BuildTarget>> collectTargets(
    int specsCount,
    List<ListenableFuture<Entry<Integer, ImmutableSet<BuildTarget>>>> targetFutures)
    throws InterruptedException {
  // Walk through and resolve all the futures, and place their results in a multimap that
  // is indexed by the integer representing the input target spec order.
  LinkedHashMultimap<Integer, BuildTarget> targetsMap = LinkedHashMultimap.create();
  try {
    for (ListenableFuture<Map.Entry<Integer, ImmutableSet<BuildTarget>>> targetFuture :
        targetFutures) {
      Map.Entry<Integer, ImmutableSet<BuildTarget>> result = targetFuture.get();
      targetsMap.putAll(result.getKey(), result.getValue());
    }
  } catch (ExecutionException e) {
    MoreThrowables.throwIfAnyCauseInstanceOf(e, InterruptedException.class);
    HumanReadableExceptions.throwIfHumanReadableUnchecked(e.getCause());
    throw new RuntimeException(e);
  }
  // Finally, pull out the final build target results in input target spec order, and place them
  // into a list of sets that exactly matches the ihput order.
  ImmutableList.Builder<ImmutableSet<BuildTarget>> targets = ImmutableList.builder();
  for (int index = 0; index < specsCount; index++) {
    targets.add(ImmutableSet.copyOf(targetsMap.get(index)));
  }
  return targets.build();
}
 
源代码4 项目: datawave   文件: ExpandCompositeTerms.java
/**
 * This function is to order collections by size, this is useful so building composites can skip shorter composites ex. if KEY1_KEY2_KEY3 existed we would
 * not want to create KEY1_KEY2 or KEY1_KEY3 so could be skipped.
 * 
 * @param mm
 *            Multimap to sort by size of the {@code collection<v>}
 * @param <K>
 *            Key type for mm, not relevant to sort
 * @param <V>
 *            Value type for mm, not relevant to sort
 * @return Sorted linked hash multimap to keep order
 */
private <K,V> LinkedHashMultimap<K,V> orderByCollectionSize(Multimap<K,V> mm) {
    List<Entry<K,Collection<V>>> orderedCompositeToFieldMap = new ArrayList<>(mm.asMap().entrySet());
    Collections.sort(orderedCompositeToFieldMap, (o1, o2) -> Integer.compare(o2.getValue().size(), o1.getValue().size()));
    
    LinkedHashMultimap<K,V> orderedMm = LinkedHashMultimap.create();
    for (Map.Entry<K,Collection<V>> foundEntry : orderedCompositeToFieldMap) {
        orderedMm.putAll(foundEntry.getKey(), foundEntry.getValue());
    }
    return orderedMm;
}