java.util.Collection#addAll ( )源码实例Demo

下面列出了java.util.Collection#addAll ( ) 实例代码,或者点击链接到github查看源代码,也可以在右侧发表评论。

源代码1 项目: dragonwell8_jdk   文件: Code.java
protected void visitRefs(int mode, Collection<ConstantPool.Entry> refs) {
    int verbose = getPackage().verbose;
    if (verbose > 2)
        System.out.println("Reference scan "+this);
    refs.addAll(Arrays.asList(handler_class));
    if (fixups != null) {
        fixups.visitRefs(refs);
    } else {
        // References (to a local cpMap) are embedded in the bytes.
        ConstantPool.Entry[] cpMap = getCPMap();
        for (Instruction i = instructionAt(0); i != null; i = i.next()) {
            if (verbose > 4)
                System.out.println(i);
            int cpref = i.getCPIndex();
            if (cpref >= 0) {
                refs.add(cpMap[cpref]);
            }
        }
    }
    // Handle attribute list:
    super.visitRefs(mode, refs);
}
 
源代码2 项目: AndroidStudyDemo   文件: DoubleKeyValueMap.java
public Collection<V> getAllValues() {
    Collection<V> result = null;
    Set<K1> k1Set = k1_k2V_map.keySet();
    if (k1Set != null) {
        result = new ArrayList<V>();
        for (K1 k1 : k1Set) {
            Collection<V> values = k1_k2V_map.get(k1).values();
            if (values != null) {
                result.addAll(values);
            }
        }
    }
    return result;
}
 
源代码3 项目: bazel   文件: SpawnInputExpanderTest.java
@Test
public void testRunfilesWithTreeArtifactsInSymlinks() throws Exception {
  SpecialArtifact treeArtifact = createTreeArtifact("treeArtifact");
  assertThat(treeArtifact.isTreeArtifact()).isTrue();
  TreeFileArtifact file1 = TreeFileArtifact.createTreeOutput(treeArtifact, "file1");
  TreeFileArtifact file2 = TreeFileArtifact.createTreeOutput(treeArtifact, "file2");
  FileSystemUtils.writeContentAsLatin1(file1.getPath(), "foo");
  FileSystemUtils.writeContentAsLatin1(file2.getPath(), "bar");
  Runfiles runfiles =
      new Runfiles.Builder("workspace")
          .addSymlink(PathFragment.create("symlink"), treeArtifact)
          .build();

  ArtifactExpander artifactExpander =
      (Artifact artifact, Collection<? super Artifact> output) -> {
        if (artifact.equals(treeArtifact)) {
          output.addAll(Arrays.asList(file1, file2));
        }
      };
  RunfilesSupplier supplier = new RunfilesSupplierImpl(PathFragment.create("runfiles"), runfiles);
  FakeActionInputFileCache fakeCache = new FakeActionInputFileCache();
  fakeCache.put(file1, FileArtifactValue.createForTesting(file1));
  fakeCache.put(file2, FileArtifactValue.createForTesting(file2));

  expander.addRunfilesToInputs(inputMappings, supplier, fakeCache, artifactExpander, true);
  assertThat(inputMappings).hasSize(2);
  assertThat(inputMappings)
      .containsEntry(PathFragment.create("runfiles/workspace/symlink/file1"), file1);
  assertThat(inputMappings)
      .containsEntry(PathFragment.create("runfiles/workspace/symlink/file2"), file2);
}
 
源代码4 项目: jdk8u_jdk   文件: Defaults.java
private static Collection<Object[]> makeRWMapsNoNulls() {
    Collection<Object[]> all = new ArrayList<>();

    all.addAll(makeRWNoNullKeysMaps(false));
    all.addAll(makeRWNoNullsMaps());

    return all;
}
 
源代码5 项目: codebase   文件: BpmnMessageFlow.java
@Override
public Collection<IDataNode> getReadWriteDocuments() {
	Collection<IDataNode> result = new ArrayList<IDataNode>();
	result.addAll(this.readDocuments);
	result.retainAll(this.writeDocuments);
	return result;
}
 
源代码6 项目: CodeScaner   文件: DecodeThread.java
DecodeThread(CaptureActivity activity,
             Collection<BarcodeFormat> decodeFormats,
             Map<DecodeHintType,?> baseHints,
             String characterSet,
             ResultPointCallback resultPointCallback) {

  this.activity = activity;
  handlerInitLatch = new CountDownLatch(1);

  hints = new EnumMap<>(DecodeHintType.class);
  if (baseHints != null) {
    hints.putAll(baseHints);
  }

  // The prefs can't change while the thread is running, so pick them up once here.
  if (decodeFormats == null || decodeFormats.isEmpty()) {
      decodeFormats = EnumSet.noneOf(BarcodeFormat.class);
      decodeFormats.addAll(DecodeFormatManager.PRODUCT_FORMATS);
      decodeFormats.addAll(DecodeFormatManager.INDUSTRIAL_FORMATS);
      decodeFormats.addAll(DecodeFormatManager.QR_CODE_FORMATS);
      decodeFormats.addAll(DecodeFormatManager.DATA_MATRIX_FORMATS);
      decodeFormats.addAll(DecodeFormatManager.AZTEC_FORMATS);
      decodeFormats.addAll(DecodeFormatManager.PDF417_FORMATS);
  }
  hints.put(DecodeHintType.POSSIBLE_FORMATS, decodeFormats);

  if (characterSet != null) {
    hints.put(DecodeHintType.CHARACTER_SET, characterSet);
  }
  hints.put(DecodeHintType.NEED_RESULT_POINT_CALLBACK, resultPointCallback);
  Log.i("DecodeThread", "Hints: " + hints);
}
 
源代码7 项目: triplea   文件: MustFightBattle.java
@Override
public void unitsLostInPrecedingBattle(
    final Collection<Unit> units, final IDelegateBridge bridge, final boolean withdrawn) {
  Collection<Unit> lost = new ArrayList<>(getDependentUnits(units));
  lost.addAll(CollectionUtils.intersection(units, attackingUnits));
  // if all the amphibious attacking land units are lost, then we are no longer a naval invasion
  amphibiousLandAttackers.removeAll(lost);
  if (amphibiousLandAttackers.isEmpty()) {
    isAmphibious = false;
    bombardingUnits.clear();
  }
  attackingUnits.removeAll(lost);
  // now that they are definitely removed from our attacking list, make sure that they were not
  // already removed from
  // the territory by the previous battle's remove method
  lost = CollectionUtils.getMatches(lost, Matches.unitIsInTerritory(battleSite));
  if (!withdrawn) {
    remove(lost, bridge, battleSite, false);
  }
  if (attackingUnits.isEmpty()) {
    final IntegerMap<UnitType> costs = TuvUtils.getCostsForTuv(attacker, gameData);
    final int tuvLostAttacker =
        (withdrawn ? 0 : TuvUtils.getTuv(lost, attacker, costs, gameData));
    attackerLostTuv += tuvLostAttacker;
    whoWon = WhoWon.DEFENDER;
    if (!headless) {
      battleTracker
          .getBattleRecords()
          .addResultToBattle(
              attacker,
              battleId,
              defender,
              attackerLostTuv,
              defenderLostTuv,
              BattleRecord.BattleResultDescription.LOST,
              new BattleResults(this, gameData));
    }
    battleTracker.removeBattle(this, gameData);
  }
}
 
源代码8 项目: APICloud-Studio   文件: CSSTaskDetector.java
/**
 * Method for detecting tasks in the root of a CSS AST. This is public for the HTML task detector to be able to
 * delegate to this for CSS as a sub-language.
 */
public Collection<IProblem> detectTasks(IParseRootNode rootNode, BuildContext context, IProgressMonitor monitor)
{
	if (context == null || rootNode == null)
	{
		return Collections.emptyList();
	}

	IParseNode[] comments = rootNode.getCommentNodes();
	if (ArrayUtil.isEmpty(comments))
	{
		return Collections.emptyList();
	}

	SubMonitor sub = SubMonitor.convert(monitor, comments.length);
	Collection<IProblem> tasks = new ArrayList<IProblem>(comments.length);
	try
	{
		String source = context.getContents();
		String filePath = context.getURI().toString();

		for (IParseNode commentNode : comments)
		{
			if (commentNode instanceof CSSCommentNode)
			{
				tasks.addAll(processCommentNode(filePath, source, 0, commentNode, COMMENT_ENDING));
			}
			sub.worked(1);
		}
	}
	finally
	{
		sub.done();
	}
	return tasks;
}
 
源代码9 项目: swift-t   文件: ForeachLoops.java
@Override
public Collection<Var> requiredVars(boolean forDeadCodeElim) {
  Collection<Var> res = new ArrayList<Var>();
  res.add(container);
  res.addAll(abstractForeachRequiredVars(forDeadCodeElim));
  return res;
}
 
源代码10 项目: TencentKona-8   文件: Defaults.java
private static Collection<Object[]> makeAllMapsWithNulls() {
    Collection<Object[]> all = new ArrayList<>();

    all.addAll(makeROMaps(true));
    all.addAll(makeRWMaps(true,true));

    return all;
}
 
源代码11 项目: bazel   文件: ConcurrentCollectionWrapper.java
/**
 * Removes 'value' from wrapped collection. Replacing this collection instance for ArrayList from
 * CompactHashSet.
 *
 * @return {@code true} if the collection was modified; {@code false} if the set collection not
 *     modified
 */
public synchronized boolean remove(T value) {

  Collection<T> collection = this.collection;
  if (collection == null) {
    // null
    return false;
  }

  int previousSize = collection.size();
  if (previousSize == 1) {
    if (collection.contains(value)) {
      // -> null
      this.collection = null;
      return true;
    } else {
      return false;
    }
  }
  // now remove the value
  if (collection.remove(value)) {
    // may need to change representation
    if (previousSize == 2) {
      // -> SingletonList
      List<T> list = Collections.singletonList(collection.iterator().next());
      this.collection = list;
      return true;
    } else if (previousSize == 1 + ARRAYLIST_THRESHOLD) {
      // -> ArrayList
      Collection<T> newArrayList = new ArrayList<>(ARRAYLIST_THRESHOLD);
      newArrayList.addAll(collection);
      this.collection = newArrayList;
      return true;
    }
    return true;
  }
  return false;
}
 
源代码12 项目: smallrye-graphql   文件: Bootstrap.java
public static Collection<Operation> findAllOperations(Schema schema) {
    Collection<Operation> operations = new ArrayList<>();
    operations.addAll(schema.getQueries());
    operations.addAll(schema.getMutations());

    for (final Type value : schema.getTypes().values()) {
        operations.addAll(value.getOperations());
    }

    return operations;
}
 
源代码13 项目: JVoiceXML   文件: DesktopTelephonySupport.java
/**
 * {@inheritDoc}
 */
@Override
public void disconnect(final ConnectionInformation client) {
    active = false;
    synchronized (listener) {
        final Collection<TelephonyListener> copy =
                new java.util.ArrayList<TelephonyListener>();
        copy.addAll(listener);
        final TelephonyEvent event = new TelephonyEvent(this,
                TelephonyEvent.HUNGUP);
        for (TelephonyListener current : copy) {
            current.telephonyCallHungup(event);
        }
    }
}
 
/**
 * Gather constraints associated with a set of compilation units.
 * @param referringCus
 * @param pm
 * @return the constraints
 */
private Collection<ITypeConstraint> getConstraints(ICompilationUnit[] referringCus, IProgressMonitor pm) {
	pm.beginTask(RefactoringCoreMessages.ChangeTypeRefactoring_analyzingMessage, referringCus.length);
	Collection<ITypeConstraint> result= new ArrayList<ITypeConstraint>();
	for (int i= 0; i < referringCus.length; i++) {
		result.addAll(getConstraints(referringCus[i]));
		pm.worked(1);
		if (pm.isCanceled())
			throw new OperationCanceledException();
	}
	pm.done();
	return result;
}
 
源代码15 项目: openjdk-8-source   文件: Defaults.java
@DataProvider(name = "MergeCases", parallel = true)
public Iterator<Object[]> mergeCasesProvider() {
    Collection<Object[]> cases = new ArrayList<>();

    cases.addAll(makeMergeTestCases());

    return cases.iterator();
}
 
源代码16 项目: scheduler   文件: IssuesTest.java
@Test
public static void testIssue89() throws Exception {
    final Model model = new DefaultModel();
    final Mapping mapping = model.getMapping();

    final Node node0 = model.newNode(0);
    final int[] ids0 = {1, 45, 43, 40, 39, 38, 82, 80, 79, 78, 30, 75, 18, 16, 15, 14, 60, 9, 55, 54, 50, 48};
    final Node node1 = model.newNode(1);
    final int[] ids1 = {84, 83, 81, 77, 73, 71, 64, 63, 62, 57, 53, 52, 47, 46, 44, 41, 34, 31, 28, 25, 13, 8, 6, 4, 3, 0};
    final Node node2 = model.newNode(2);
    final int[] ids2 = {21, 67, 42, 36, 35, 33, 76, 74, 23, 69, 68, 20, 61, 12, 11, 10, 5, 51};
    final Node node3 = model.newNode(3);
    final int[] ids3 = {2, 66, 86, 85, 37, 32, 29, 27, 26, 72, 24, 70, 22, 19, 65, 17, 59, 58, 56, 7, 49};

    final ShareableResource cpu = new ShareableResource("cpu", 45, 1);
    final ShareableResource mem = new ShareableResource("mem", 90, 2);

    populateNodeVm(model, mapping, node0, ids0);
    populateNodeVm(model, mapping, node1, ids1);
    populateNodeVm(model, mapping, node2, ids2);
    populateNodeVm(model, mapping, node3, ids3);
    model.attach(cpu);
    model.attach(mem);

    final Collection<SatConstraint> satConstraints =
            new ArrayList<>();
    // We want to cause Node 3 to go offline to see how the VMs hosted on that
    // node will get rebalanced.
    satConstraints.add(new Offline(node3));
    final OptConstraint optConstraint = new MinMTTR();
    DefaultChocoScheduler scheduler = new DefaultChocoScheduler();
    scheduler.doOptimize(false);
    scheduler.doRepair(true);
    scheduler.setTimeLimit(60000);
    ReconfigurationPlan plan = scheduler.solve(
            model, satConstraints, optConstraint);
    System.out.println(scheduler.getStatistics());
    Assert.assertTrue(plan.isApplyable());


    satConstraints.clear();
    // This is somewhat similar to making Node 3 going offline by ensuring that
    // all VMs can no longer get hosted on that node.
    satConstraints.addAll(mapping.getAllVMs().stream().map(vm -> new Ban(vm, Collections.singletonList(node3))).collect(Collectors.toList()));

    scheduler = new DefaultChocoScheduler();
    scheduler.doOptimize(false);
    scheduler.doRepair(true);
    plan = scheduler.solve(model, satConstraints, optConstraint);
    Assert.assertTrue(plan.isApplyable());
}
 
源代码17 项目: triplea   文件: AbstractPlaceDelegate.java
private void updateProducedMap(
    final Territory producer, final Collection<Unit> additionallyProducedUnits) {
  final Collection<Unit> newProducedUnits = getAlreadyProduced(producer);
  newProducedUnits.addAll(additionallyProducedUnits);
  produced.put(producer, newProducedUnits);
}
 
源代码18 项目: sql-layer   文件: TypesRegistry.java
public Collection<TClass> getTypeClasses() {
    Collection<TClass> result = new ArrayList<>();
    for (BundleEntry entry : bundlesByName.values())
        result.addAll(entry.typeClassByName.values());
    return result;
}
 
源代码19 项目: consulo-csharp   文件: CSharpNameSuggesterUtil.java
@Nonnull
@RequiredReadAction
public static Collection<String> getSuggestedVariableNames(final DotNetVariable variable)
{
	PsiElement parent = variable.getParent();

	Collection<String> suggestedNames = null;
	if(parent instanceof CSharpForeachStatementImpl)
	{
		DotNetExpression iterableExpression = ((CSharpForeachStatementImpl) parent).getIterableExpression();
		if(iterableExpression != null)
		{
			suggestedNames = getSuggestedNames(iterableExpression, Collections.emptyList(), variable);
		}
	}

	if(suggestedNames == null)
	{
		if(variable.toTypeRef(false) == DotNetTypeRef.AUTO_TYPE)
		{
			suggestedNames = ContainerUtil.newArrayList("v");
		}
		else
		{
			suggestedNames = getSuggestedNames(variable.toTypeRef(true), variable);
		}
	}

	DotNetExpression initializer = variable.getInitializer();
	if(initializer != null)
	{
		suggestedNames.addAll(getSuggestedNames(initializer, suggestedNames, variable));
	}

	if(variable instanceof CSharpPropertyDeclaration)
	{
		suggestedNames = ContainerUtil.map(suggestedNames, StringUtil::capitalize);
	}

	CSharpCodeGenerationSettings settings = CSharpCodeGenerationSettings.getInstance(variable.getProject());

	boolean isStatic = variable.hasModifier(DotNetModifier.STATIC);
	final String prefix;
	final String suffix;
	if(variable instanceof CSharpPropertyDeclaration)
	{
		prefix = isStatic ? settings.STATIC_PROPERTY_PREFIX : settings.PROPERTY_PREFIX;
		suffix = isStatic ? settings.STATIC_PROPERTY_SUFFIX : settings.PROPERTY_PREFIX;
	}
	else if(variable instanceof CSharpFieldDeclaration)
	{
		prefix = isStatic ? settings.STATIC_FIELD_PREFIX : settings.FIELD_PREFIX;
		suffix = isStatic ? settings.STATIC_FIELD_SUFFIX : settings.FIELD_SUFFIX;
	}
	else
	{
		prefix = null;
		suffix = null;
	}

	return ContainerUtil.map(suggestedNames, name ->
	{
		if(prefix == null && suffix == null)
		{
			return name;
		}
		if(StringUtil.isEmpty(prefix))
		{
			return name + StringUtil.notNullize(suffix);
		}
		return StringUtil.notNullize(prefix) + StringUtil.capitalize(name) + StringUtil.notNullize(suffix);
	});
}
 
源代码20 项目: AtlasForAndroid   文件: BundleClassLoader.java
protected Enumeration<URL> findResources(String str) {
    String stripTrailing = stripTrailing(str);
    Collection findOwnResources = findOwnResources(stripTrailing, true);
    findOwnResources.addAll(findImportedResources(stripTrailing, true));
    return Collections.enumeration(findOwnResources);
}