com.google.common.collect.Sets#union ( )源码实例Demo

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

源代码1 项目: theta   文件: DBM.java
public boolean isLeq(final DBM that, final Collection<? extends VarDecl<RatType>> activeVars) {
	final Set<VarDecl<RatType>> vars = Sets.union(this.signature.toSet(), that.signature.toSet());

	for (final VarDecl<RatType> x : vars) {
		if (!activeVars.contains(x)) {
			continue;
		}

		for (final VarDecl<RatType> y : vars) {
			if (!activeVars.contains(y)) {
				continue;
			}

			if (this.getOrDefault(x, y) > that.getOrDefault(x, y)) {
				return false;
			}

		}
	}
	return true;
}
 
源代码2 项目: armeria   文件: ServerBuilder.java
/**
 * Returns a list of {@link ServerPort}s which consists of distinct port numbers except for the port
 * {@code 0}. If there are the same port numbers with different {@link SessionProtocol}s,
 * their {@link SessionProtocol}s will be merged into a single {@link ServerPort} instance.
 * The returned list is sorted as the same order of the specified {@code ports}.
 */
private static List<ServerPort> resolveDistinctPorts(List<ServerPort> ports) {
    final List<ServerPort> distinctPorts = new ArrayList<>();
    for (final ServerPort p : ports) {
        boolean found = false;
        // Do not check the port number 0 because a user may want his or her server to be bound
        // on multiple arbitrary ports.
        if (p.localAddress().getPort() > 0) {
            for (int i = 0; i < distinctPorts.size(); i++) {
                final ServerPort port = distinctPorts.get(i);
                if (port.localAddress().equals(p.localAddress())) {
                    final ServerPort merged =
                            new ServerPort(port.localAddress(),
                                           Sets.union(port.protocols(), p.protocols()));
                    distinctPorts.set(i, merged);
                    found = true;
                    break;
                }
            }
        }
        if (!found) {
            distinctPorts.add(p);
        }
    }
    return Collections.unmodifiableList(distinctPorts);
}
 
源代码3 项目: bazel   文件: ConfigCommand.java
private static Map<String, Pair<Object, Object>> diffStarlarkOptions(
    BuildConfiguration config1, BuildConfiguration config2) {
  Map<Label, Object> starlarkOptions1 = config1.getOptions().getStarlarkOptions();
  Map<Label, Object> starlarkOptions2 = config2.getOptions().getStarlarkOptions();
  Map<String, Pair<Object, Object>> diffs = new HashMap<>();
  for (Label option : Sets.union(starlarkOptions1.keySet(), starlarkOptions2.keySet())) {
    Object value1 = starlarkOptions1.get(option);
    Object value2 = starlarkOptions2.get(option);
    if (!Objects.equals(value1, value2)) {
      diffs.put(option.toString(), Pair.of(value1, value2));
    }
  }
  return diffs;
}
 
源代码4 项目: codebuff   文件: AbstractConfigurableNetwork.java
@Override
public Set<E> adjacentEdges(Object edge) {
  Iterator<N> incidentNodesIterator = incidentNodes(edge).iterator();
  Set<E> endpointsIncidentEdges = incidentEdges(incidentNodesIterator.next());
  while (incidentNodesIterator.hasNext()) {
    endpointsIncidentEdges =
       Sets.union(incidentEdges(incidentNodesIterator.next()), endpointsIncidentEdges);
  }
  return Sets.difference(endpointsIncidentEdges, ImmutableSet.of(edge));
}
 
源代码5 项目: ProjectAres   文件: Team.java
@Override
public Set<MatchPlayer> getPlayers() {
    final Change change = CHANGE.get();
    if(change != null) {
        if(equals(change.oldTeam)) {
            return Sets.difference(super.getPlayers(), Collections.singleton(change.player));
        } else if(equals(change.newTeam)) {
            return Sets.union(super.getPlayers(), Collections.singleton(change.player));
        }
    }
    return super.getPlayers();
}
 
源代码6 项目: batfish   文件: ParboiledEnumSetSpecifier.java
EnumValueSets<T> union(EnumValueSets<T> sets2) {
  return new EnumValueSets<>(
      Sets.union(_including, sets2._including),
      Sets.union(_excluding, sets2._excluding),
      _allValues,
      _groupValues);
}
 
源代码7 项目: incubator-nemo   文件: BatchSchedulerUtils.java
static void retryTasksAndRequiredParents(final PlanStateManager planStateManager,
                                         final BlockManagerMaster blockManagerMaster,
                                         final Set<String> tasks) {
  final Set<String> requiredParents =
    recursivelyGetParentTasksForLostBlocks(planStateManager, blockManagerMaster, tasks);
  final Set<String> tasksToRetry = Sets.union(tasks, requiredParents);
  LOG.info("Will be retried: {}", tasksToRetry);
  tasksToRetry.forEach(
    taskToReExecute -> planStateManager.onTaskStateChanged(taskToReExecute, TaskState.State.SHOULD_RETRY));
}
 
源代码8 项目: theta   文件: DBM.java
public boolean isLeq(final DBM that) {
	final Set<VarDecl<RatType>> vars = Sets.union(this.signature.toSet(), that.signature.toSet());

	for (final VarDecl<RatType> x : vars) {
		for (final VarDecl<RatType> y : vars) {
			if (this.getOrDefault(x, y) > that.getOrDefault(x, y)) {
				return false;
			}

		}
	}
	return true;
}
 
private DefaultManifest mergeManifest(DefaultManifest baseManifest, DefaultManifest toMergeManifest, FileResolver fileResolver) {
    DefaultManifest mergedManifest = new DefaultManifest(fileResolver);
    mergeSection(null, mergedManifest, baseManifest.getAttributes(), toMergeManifest.getAttributes());
    Set<String> allSections = Sets.union(baseManifest.getSections().keySet(), toMergeManifest.getSections().keySet());
    for (String section : allSections) {
        mergeSection(section, mergedManifest,
                GUtil.elvis(baseManifest.getSections().get(section), new DefaultAttributes()),
                GUtil.elvis(toMergeManifest.getSections().get(section), new DefaultAttributes()));
    }
    return mergedManifest;
}
 
源代码10 项目: seldon-server   文件: ClientAlgorithmStore.java
private Set<ItemFilter> retrieveFilters(List<String> filters) {
    Set<ItemFilter> filterSet = new HashSet<>();
    if(filters==null) return alwaysOnFilters;
    for (String filter : filters){
        filterSet.add(applicationContext.getBean(filter, ItemFilter.class));
    }
    return Sets.union(filterSet, alwaysOnFilters);
}
 
源代码11 项目: Strata   文件: SecurityTokenEvaluator.java
@Override
public Set<String> tokens(Security security) {
  MetaBean metaBean = MetaBean.of(security.getClass());
  return Sets.union(
      Sets.union(metaBean.metaPropertyMap().keySet(), security.getInfo().propertyNames()),
      security.getInfo().getPriceInfo().propertyNames());
}
 
源代码12 项目: codebuff   文件: AbstractDirectedNodeConnections.java
@Override
public Set<N> adjacentNodes() {
  return Sets.union(predecessors(), successors());
}
 
源代码13 项目: ProjectAres   文件: Traceables.java
public static StackTrace computeStackTrace(Object obj, Set<Class<?>> skip) {
    return obj instanceof Traceable ? ((Traceable) obj).stackTrace()
                                    : new StackTrace(Sets.union(ImmutableSet.of(Traceables.class), skip));
}
 
源代码14 项目: batfish   文件: ParboiledNodeSpecifier.java
@Override
public Set<String> visitUnionNodeAstNode(UnionNodeAstNode unionNodeAstNode) {
  return Sets.union(
      unionNodeAstNode.getLeft().accept(this), unionNodeAstNode.getRight().accept(this));
}
 
源代码15 项目: ProjectAres   文件: PGMMapEnvironment.java
@Override
public Set<String> keySet() {
    return Sets.union(Sets.union(manual.keySet(), Holidays.keys()), permanent().getKeys(false));
}
 
private Set<String> extendedTags(final Set<String> tags, final Server server) {
  final String portTag = "httpPort-" + server.getPort();
  final String contextPathTag = "contextPath-" + server.getContextPath();
  return Sets.union(tags, Sets.newHashSet(contextPathTag, portTag));
}
 
源代码17 项目: codebuff   文件: AbstractDirectedNodeConnections.java
@Override
public Set<E> incidentEdges() {
  return Sets.union(inEdges(), outEdges());
}
 
源代码18 项目: ProjectAres   文件: StackTrace.java
public StackTrace(Set<Class<?>> skip) {
    this(new Throwable().getStackTrace(), Sets.union(ImmutableSet.of(StackTrace.class), skip));
}
 
源代码19 项目: incubator-gobblin   文件: QueryBasedSource.java
@Override
public List<WorkUnit> getWorkunits(SourceState state) {
  initLogger(state);
  lineageInfo = LineageInfo.getLineageInfo(state.getBroker());

  List<WorkUnit> workUnits = Lists.newArrayList();

  // Map<String, String> tableNameToEntityMap = Maps.newHashMap();
  Set<SourceEntity> entities = getFilteredSourceEntities(state);

  Map<SourceEntity, State> tableSpecificPropsMap = shouldObtainTablePropsFromConfigStore(state)
      ? getTableSpecificPropsFromConfigStore(entities, state)
      : getTableSpecificPropsFromState(entities, state);
  Map<SourceEntity, Long> prevWatermarksByTable = getPreviousWatermarksForAllTables(state);

  for (SourceEntity sourceEntity : Sets.union(entities, prevWatermarksByTable.keySet())) {

    log.info("Source entity to be processed: {}, carry-over from previous state: {} ",
             sourceEntity, !entities.contains(sourceEntity));

    SourceState combinedState = getCombinedState(state, tableSpecificPropsMap.get(sourceEntity));
    long previousWatermark = prevWatermarksByTable.containsKey(sourceEntity) ?
        prevWatermarksByTable.get(sourceEntity)
        : ConfigurationKeys.DEFAULT_WATERMARK_VALUE;

    // If a table name exists in prevWatermarksByTable (i.e., it has a previous watermark) but does not exist
    // in talbeNameToEntityMap, create an empty workunit for it, so that its previous watermark is preserved.
    // This is done by overriding the high watermark to be the same as the previous watermark.
    if (!entities.contains(sourceEntity)) {
      combinedState.setProp(ConfigurationKeys.SOURCE_QUERYBASED_END_VALUE, previousWatermark);
    }

    workUnits.addAll(generateWorkUnits(sourceEntity, combinedState, previousWatermark));
  }

  log.info("Total number of workunits for the current run: " + workUnits.size());
  List<WorkUnit> previousWorkUnits = this.getPreviousWorkUnitsForRetry(state);
  log.info("Total number of incomplete tasks from the previous run: " + previousWorkUnits.size());
  workUnits.addAll(previousWorkUnits);

  int numOfMultiWorkunits =
      state.getPropAsInt(ConfigurationKeys.MR_JOB_MAX_MAPPERS_KEY, ConfigurationKeys.DEFAULT_MR_JOB_MAX_MAPPERS);

  return pack(workUnits, numOfMultiWorkunits);
}
 
源代码20 项目: gatk-protected   文件: BaseGraph.java
/**
 * Get the set of vertices connected to v by incoming or outgoing edges
 * @param v a non-null vertex
 * @return a set of vertices {X} connected X -> v or v -> Y
 */
public final Set<V> neighboringVerticesOf(final V v) {
    Utils.nonNull(v);
    return Sets.union(incomingVerticesOf(v), outgoingVerticesOf(v));
}