当前位置: 首页>>代码示例>>C#>>正文


C# ISet.UnionWith方法代码示例

本文整理汇总了C#中ISet.UnionWith方法的典型用法代码示例。如果您正苦于以下问题:C# ISet.UnionWith方法的具体用法?C# ISet.UnionWith怎么用?C# ISet.UnionWith使用的例子?那么恭喜您, 这里精选的方法代码示例或许可以为您提供帮助。您也可以进一步了解该方法所在ISet的用法示例。


在下文中一共展示了ISet.UnionWith方法的15个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于系统推荐出更棒的C#代码示例。

示例1: ReplaceCapturedVariablesVisitor

        public ReplaceCapturedVariablesVisitor(IEnumerable<string> locals,
            IEnumerable<string> formalParams,
            IEnumerable<string> classFields,
            IEnumerable<string> classMethods,
            IEnumerable<string> classProperties,
            IEnumerable<string> unitGlobals,
            IDictionary<string, string> localsMap,
            IDictionary<string, string> formalParamsMap,
            bool isInClassMethod)
        {
            CollectedLocals = new HashSet<string>(locals);
            CollectedFormalParams = new HashSet<string>(formalParams);
            CollectedClassFields = new HashSet<string>(classFields);
            CollectedUnitGlobals = new HashSet<string>(unitGlobals);

            CapturedLocalsMap = new Dictionary<string, string>(localsMap);
            CapturedFormalParamsMap = new Dictionary<string, string>(formalParamsMap);

            IsInClassMethod = isInClassMethod;

            // Methods hack
            CollectedClassFields.UnionWith(classMethods);
            // Properties hack
            CollectedClassFields.UnionWith(classProperties);
        }
开发者ID:PascalABC-CompilerLaboratory,项目名称:ParsePABC,代码行数:25,代码来源:ReplaceCapturedVariablesVisitor.cs

示例2: GetDependencies

        public override void GetDependencies(ISet<Binding> injectDependencies, ISet<Binding> propertyDependencies)
        {
            injectDependencies.UnionWith(ctorBindings);
            propertyDependencies.UnionWith(propertyBindings);

            if (baseTypeBinding != null) {
                propertyDependencies.Add(baseTypeBinding);
            }
        }
开发者ID:paulcbetts,项目名称:stiletto,代码行数:9,代码来源:CompilerBinding.cs

示例3: GetDependencies

 public override void GetDependencies(ISet<Binding> injectDependencies, ISet<Binding> propertyDependencies)
 {
     injectDependencies.UnionWith(paramBindings);
 }
开发者ID:benjamin-bader,项目名称:stiletto,代码行数:4,代码来源:CompilerProvidesBinding.cs

示例4: CollectUnitGlobalsNames

 private void CollectUnitGlobalsNames(procedure_definition pd, ISet<string> collectedUnitGlobalsName)
 {
     var cu = UpperTo<compilation_unit>();
     if ((object)cu != null)
     {
         var ugVis = new CollectUnitGlobalsVisitor();
         cu.visit(ugVis);
         // Collect
         collectedUnitGlobalsName.UnionWith(ugVis.CollectedGlobals.Select(id => id.name));
     }
 }
开发者ID:PascalABC-CompilerLaboratory,项目名称:ParsePABC,代码行数:11,代码来源:ProcessYieldsCapturedVars.cs

示例5: CollectFormalParamsNames

 private void CollectFormalParamsNames(procedure_definition pd, ISet<string> collectedFormalParamsNames)
 {
     if ((object)pd.proc_header.parameters != null)
         collectedFormalParamsNames.UnionWith(pd.proc_header.parameters.params_list.SelectMany(tp => tp.idents.idents).Select(id => id.name));
 }
开发者ID:PascalABC-CompilerLaboratory,项目名称:ParsePABC,代码行数:5,代码来源:ProcessYieldsCapturedVars.cs

示例6: CollectFormalParams

 private void CollectFormalParams(procedure_definition pd, ISet<var_def_statement> collectedFormalParams)
 {
     if ((object)pd.proc_header.parameters != null)
         collectedFormalParams.UnionWith(pd.proc_header.parameters.params_list.Select(tp => new var_def_statement(tp.idents, tp.vars_type)));
 }
开发者ID:PascalABC-CompilerLaboratory,项目名称:ParsePABC,代码行数:5,代码来源:ProcessYieldsCapturedVars.cs

示例7: CollectClassPropertiesNames

        private void CollectClassPropertiesNames(procedure_definition pd, ISet<string> collectedProperties)
        {
            ident className = GetClassName(pd);

            if ((object)className != null)
            {
                CollectClassPropertiesVisitor propertiesVis = new CollectClassPropertiesVisitor(className);
                var cu = UpperTo<compilation_unit>();
                if ((object)cu != null)
                {
                    cu.visit(propertiesVis);
                    // Collect
                    collectedProperties.UnionWith(propertiesVis.CollectedProperties.Select(id => id.name));
                }
            }
        }
开发者ID:PascalABC-CompilerLaboratory,项目名称:ParsePABC,代码行数:16,代码来源:ProcessYieldsCapturedVars.cs

示例8: StepTerm

		/// <summary>
		/// Eliminate rules with nonsolitary terminals
		/// </summary>
		/// <param name="productions"></param>
		private void StepTerm(ISet<Production> productions) {
			var newProductions = new List<Production>();
			var lookup = new Dictionary<Terminal, Nonterminal>();
			foreach (var production in productions) {
				if (production.Rhs.Count < 2) {
					continue;
				}
				for (int i = 0; i < production.Rhs.Count; i++) {
					var word = production.Rhs[i];
					if (word.IsNonterminal) {
						continue;
					}
					Terminal terminal = (Terminal)word;
					Nonterminal fresh;
					if (!lookup.TryGetValue(terminal, out fresh)) {
						fresh = GetFresh();
						lookup[terminal] = fresh;
						newProductions.Add(
							new Production(fresh, new Sentence { terminal })
						);
					}
					production.Rhs[i] = fresh;
				}
			}
			productions.UnionWith(newProductions);
		}
开发者ID:ellisonch,项目名称:CFGLib,代码行数:30,代码来源:CFGtoCNF.cs

示例9: StepUnit

		/// <summary>
		/// Eliminate unit rules (e.g., &lt;X> -> &lt;Y>)
		/// </summary>
		/// <param name="productions"></param>
		private void StepUnit(ISet<Production> productions) {
			// TODO: maybe we shouldn't allow self loops?
			RemoveSelfLoops(productions);

			var toRemove = BaseGrammar.RemoveDuplicatesHelper(productions);
			foreach (var production in toRemove) {
				productions.Remove(production);
			}

			var finalProductions = RemoveUnits(productions);
			productions.Clear();
			productions.UnionWith(finalProductions);
		}
开发者ID:ellisonch,项目名称:CFGLib,代码行数:17,代码来源:CFGtoCNF.cs

示例10: StepDel

		/// <summary>
		/// Eliminate ε-rules
		/// </summary>
		/// <param name="productions"></param>
		// TODO: Does not preserve weights
		private void StepDel(ISet<Production> productions) {
			var nullableProbabilities = GrammarHelpers.GetNullable(productions);
			var newRules = new List<Production>();
			foreach (var production in productions) {
				var toAdd = Nullate(production, nullableProbabilities);
				RemoveExtraneousNulls(toAdd);
				newRules.AddRange(toAdd);
			}
			productions.Clear();
			productions.UnionWith(newRules);
		}
开发者ID:ellisonch,项目名称:CFGLib,代码行数:16,代码来源:CFGtoCNF.cs

示例11: StepBin

		/// <summary>
		/// Eliminate right-hand sides with more than 2 nonterminals
		/// </summary>
		/// <param name="productions"></param>
		private void StepBin(ISet<Production> productions) {
			List<Production> finalProductions = new List<Production>();
			foreach (var production in productions) {
				if (production.Rhs.Count < 3) {
					finalProductions.Add(production);
					continue;
				}
				var rhs = production.Rhs;
				var curr = production.Lhs;
				for (int i = 0; i < rhs.Count - 2; i++) {
					var weight = (curr == production.Lhs) ? production.Weight : 1.0;
					var left = rhs[i];
					var newFresh = GetFresh();
					finalProductions.Add(
						new Production(curr, new Sentence { left, newFresh }, weight)
					);
					curr = newFresh;
				}
				finalProductions.Add(
					new Production(curr, new Sentence { rhs[rhs.Count - 2], rhs[rhs.Count - 1] })
				);
			}
			productions.Clear();
			productions.UnionWith(finalProductions);
		}
开发者ID:ellisonch,项目名称:CFGLib,代码行数:29,代码来源:CFGtoCNF.cs

示例12: CollectClassMethodsNames

        private void CollectClassMethodsNames(procedure_definition pd, ISet<string> collectedMethods)
        {
            ident className = GetClassName(pd);

            if (className != null)
            {
                CollectClassMethodsVisitor methodsVis = new CollectClassMethodsVisitor(className);
                var cu = UpperTo<compilation_unit>();
                if (cu != null)
                {
                    cu.visit(methodsVis);
                    // Collect
                    collectedMethods.UnionWith(methodsVis.CollectedMethods.Select(id => id.name));
                }
            }
        }
开发者ID:Slav76,项目名称:pascalabcnet,代码行数:16,代码来源:ProcessYieldsCapturedVars.cs

示例13: ModuloNewSetIntoMultiDictionary

 /// <summary>
 /// Inserts a set into a dictionary, such that all set entries are keys that point to the set. If, however, 
 /// the dictionary contains keys already that match any of the inserted keys, then any entries in the sets these keys 
 /// point to, will also be added to the set, and those entries will also point to the new set.
 /// If the following conditions hold before executing the method, they will also hold afterwards:
 ///     - every key in the dictionary will point to a set that contains itself and possible other keys,
 ///     - every key will exist in only one of the value sets of the dictionary.
 /// </summary>
 /// <param name="listOfAllAliases">A dictionary of sets (every key maps to a set)</param>
 /// <param name="foundAliases">A set that will be inserted</param>
 private static void ModuloNewSetIntoMultiDictionary(IDictionary<string, ISet<string>> listOfAllAliases, ISet<string> foundAliases)
 {
     var listOfOtherAliasSets = foundAliases
                                 .Where(alias => listOfAllAliases.ContainsKey(alias))
                                 .Select(alias => listOfAllAliases[alias])
                                 .Distinct()
                                 .ToList();      // modifying foundAliases is not allowed without ToList()
     foreach (ISet<string> otherAliasSet in listOfOtherAliasSets)
         foundAliases.UnionWith(otherAliasSet);
     foreach (string alias in foundAliases)
         listOfAllAliases[alias] = foundAliases;
 }
开发者ID:paluno,项目名称:GitHistoryAnalyzer,代码行数:22,代码来源:AliasFinder.cs

示例14: GetFollowSet

        public ISet<TokenGrammarElement> GetFollowSet()
        {
            if (_followSet != null)
                return _followSet;

            _followSet = new HashSet<TokenGrammarElement>();

            foreach (var reduction in Parents)
            {
                var index = reduction.Sequence.IndexOf(this);
                if (index != -1)
                {
                    bool containsEpsilon = true;

                    // Union all first sets after the current element. This also includes
                    // first sets after epsilons (e.g. firsts sets of optional grammar expressions).
                    while (containsEpsilon && index < reduction.Sequence.Count - 1)
                    {
                        var firstSet = new HashSet<TokenGrammarElement>(reduction.Sequence[index + 1].GetFirstSet());
                        containsEpsilon = firstSet.Remove(Grammar.Epsilon);
                        _followSet.UnionWith(firstSet);
                        index++;
                    }

                    // If the last added first set still contained an epsilon, we need
                    // to union the follow set with the follow set of the product as well.
                    if (containsEpsilon && index == reduction.Sequence.Count - 1)
                        _followSet.UnionWith(reduction.Product.GetFollowSet());
                }
            }

            return _followSet;
        }
开发者ID:JerreS,项目名称:AbstractCode,代码行数:33,代码来源:GrammarCompiler.cs

示例15: CollectClassFieldsNames

        private void CollectClassFieldsNames(procedure_definition pd, ISet<string> collectedFields, out bool isInClassMethod)
        {
            isInClassMethod = false;

            ident className = null;
            if ((object)pd.proc_header.name.class_name != null)
            {
                // Объявление вне класса его метода
                className = pd.proc_header.name.class_name;
            }
            else
            {
                // Объявление функции в классе?
                var classDef = UpperNode(3) as class_definition;
                if ((object)(UpperNode(3) as class_definition) != null)
                {
                    var td = UpperNode(4) as type_declaration;
                    if ((object)td != null)
                    {
                        className = td.type_name;
                    }
                }
            }

            if ((object)className != null)
            {
                isInClassMethod = true;

                CollectClassFieldsVisitor fieldsVis = new CollectClassFieldsVisitor(className);
                var cu = UpperTo<compilation_unit>();
                if ((object)cu != null)
                {
                    cu.visit(fieldsVis);
                    // Collect
                    collectedFields.UnionWith(fieldsVis.CollectedFields.Select(id => id.name));
                }
            }
        }
开发者ID:PascalABC-CompilerLaboratory,项目名称:ParsePABC,代码行数:38,代码来源:JustTestVisitor.cs


注:本文中的ISet.UnionWith方法示例由纯净天空整理自Github/MSDocs等开源代码及文档管理平台,相关代码片段筛选自各路编程大神贡献的开源项目,源码版权归原作者所有,传播和使用请参考对应项目的License;未经允许,请勿转载。