public static System.Reflection.Assembly GenerateCode(ITextTemplatingEngineHost host, ParsedTemplate pt, TemplateSettings settings, CodeCompileUnit ccu) { CompilerParameters pars = new CompilerParameters (); pars.GenerateExecutable = false; if (settings.Debug) { pars.GenerateInMemory = false; pars.IncludeDebugInformation = true; pars.TempFiles.KeepFiles = true; } else { pars.GenerateInMemory = true; pars.IncludeDebugInformation = false; } //resolve and add assembly references HashSet<string> assemblies = new HashSet<string> (); assemblies.UnionWith (settings.Assemblies); assemblies.UnionWith (host.StandardAssemblyReferences); foreach (string assem in assemblies) { string resolvedAssem = host.ResolveAssemblyReference (assem); if (!String.IsNullOrEmpty (resolvedAssem)) { pars.ReferencedAssemblies.Add (resolvedAssem); } else { pt.LogError ("Could not resolve assembly reference '" + assem + "'"); return null; } } CompilerResults results = settings.Provider.CompileAssemblyFromDom (pars, ccu); pt.Errors.AddRange (results.Errors); if (pt.Errors.HasErrors) return null; return results.CompiledAssembly; }
static void Main() { InitializeWordsByChar(); int textLinesCount = int.Parse(Console.ReadLine().ToLower()); for (int i = 0; i < textLinesCount; i++) { GetWords(Console.ReadLine().ToLower()); } int wordsCount = int.Parse(Console.ReadLine()); for (int i = 0; i < wordsCount; i++) { string word = Console.ReadLine(); string wordLowerCase = word.ToLower(); HashSet<string> currentWords = new HashSet<string>(); currentWords.UnionWith(wordsByChar[wordLowerCase[0]]); for (int j = 1; j < wordLowerCase.Length; j++) { currentWords.IntersectWith(wordsByChar[wordLowerCase[j]]); } Console.WriteLine("{0} -> {1}", word, currentWords.Count); } }
/// <summary> /// Gather member which provide continuity with the specified member /// </summary> /// <param name="Member"></param> /// <returns></returns> public static IEnumerable<Member> GatherParallelMembers(Member Member, Node LastNode = null, bool MoveDownstream = false) { Node currentNode; Member nextMember; IEnumerable<Member> connectedParallelMembers; HashSet<Member> parallelMembers; parallelMembers = new HashSet<Member>(); if (MoveDownstream) parallelMembers.Add(Member); // Determine which will be the next node currentNode = MemberHelpers.DetermineNextNode(Member, LastNode, MoveDownstream); connectedParallelMembers = currentNode.ConnectedBeams.Select(b => b.Member).Where(m => m != null && m != Member && m.DetermineMemberRelation(Member) == MEMBERRELATION.PARALLEL); if (connectedParallelMembers.Any()) { nextMember = connectedParallelMembers.First(); parallelMembers.UnionWith(GatherParallelMembers(nextMember, currentNode, MoveDownstream)); } else { if (!MoveDownstream) parallelMembers.UnionWith(GatherParallelMembers(Member, currentNode, true)); } return parallelMembers; }
public ISet<int> GetNodes() { var retVal = new HashSet<int>(); retVal.UnionWith(playerZeroNodes); retVal.UnionWith(playerOneNodes); return retVal; }
private HashSet<string> GetUserAssemblies(string managedDir) { HashSet<string> stringSet = new HashSet<string>(); stringSet.UnionWith(this.FilterUserAssemblies((IEnumerable<string>) this.m_RuntimeClassRegistry.GetUserAssemblies(), new Predicate<string>(this.m_RuntimeClassRegistry.IsDLLUsed), managedDir)); stringSet.UnionWith(this.FilterUserAssemblies((IEnumerable<string>) Directory.GetFiles(managedDir, "I18N*.dll", SearchOption.TopDirectoryOnly), (Predicate<string>) (assembly => true), managedDir)); return stringSet; }
static AssignmentStatementParser() { COLON_EQUALS_SET = new HashSet<TokenType>(); COLON_EQUALS_SET.Add(TokenType.COLON_EQUALS); COLON_EQUALS_SET.UnionWith(ExpressionParser.EXPR_START_SET); COLON_EQUALS_SET.UnionWith(StatementParser.STMT_FOLLOW_SET); }
/// <summary> /// Gather beams which provide continuity with the specified beam /// </summary> /// <param name="Beam">The start beam around which to contruct the chain</param> /// <returns></returns> public static IEnumerable<Beam> GatherParallelBeams(Beam Beam, Node LastNode = null, bool MoveDownstream = false) { Node currentNode; Beam nextBeam; IEnumerable<Beam> connectedParallelBeams; HashSet<Beam> parallelBeams; parallelBeams = new HashSet<Beam>(); if (MoveDownstream) parallelBeams.Add(Beam); // Determine which will be the next node depending on the beam orientation and direction of travel currentNode = BeamHelpers.DetermineNextNode(Beam, LastNode, MoveDownstream); // Check if the are any parallel beams among the connected beams and start gathering the beams depending on the direction of travel connectedParallelBeams = currentNode.ConnectedBeams.Where(b => b != null && b != Beam && b.DetermineBeamRelationship(Beam) == BEAMRELATION.PARALLEL); if (connectedParallelBeams.Any()) { nextBeam = connectedParallelBeams.First(); parallelBeams.UnionWith(GatherParallelBeams(nextBeam, currentNode, MoveDownstream)); } else { if (!MoveDownstream) parallelBeams.UnionWith(GatherParallelBeams(Beam, currentNode, true)); } return parallelBeams; }
public ICollection<Type> GetControllerTypes(string controllerName, HashSet<string> namespaces) { HashSet<Type> matchingTypes = new HashSet<Type>(); ILookup<string, Type> nsLookup; if (_cache.TryGetValue(controllerName, out nsLookup)) { // this friendly name was located in the cache, now cycle through namespaces if (namespaces != null) { foreach (string requestedNamespace in namespaces) { foreach (var targetNamespaceGrouping in nsLookup) { if (IsNamespaceMatch(requestedNamespace, targetNamespaceGrouping.Key)) { matchingTypes.UnionWith(targetNamespaceGrouping); } } } } else { // if the namespaces parameter is null, search *every* namespace foreach (var nsGroup in nsLookup) { matchingTypes.UnionWith(nsGroup); } } } return matchingTypes; }
public static HashSet<string> iu_cs_sinalling_relation_delegate_imsi(List<streamMessagePool._stream_message> ml, string imsi, bool sFlag) { //哈希表收集关联因子 HashSet<string> hs = new HashSet<string>(); hs.Add(imsi); //lr关联收集sccp连接串slr IEnumerable<string> l_slr_opc = from n in ml where n.message_gsm_a_imsi == imsi & n.message_sccp_slr != null select n.message_sccp_slr + n.message_source into m where m.Contains("0x") select m; hs.UnionWith(l_slr_opc); if (l_slr_opc.Any()) foreach (string slr_opc in l_slr_opc) hs.UnionWith(iu_cs_sinalling_relation_delegate_lr(ml, slr_opc, sFlag)); //lr关联收集sccp连接串dlr IEnumerable<string> l_dlr_dpc = from n in ml where n.message_gsm_a_imsi == imsi & n.message_sccp_dlr != null select n.message_sccp_dlr + n.message_destination into m where m.Contains("0x") select m; hs.UnionWith(l_dlr_dpc); if (l_dlr_dpc.Any()) foreach (string dlr_dpc in l_dlr_dpc) hs.UnionWith(iu_cs_sinalling_relation_delegate_lr(ml, dlr_dpc, sFlag)); return hs; }
public HashSet<KeyCode> getKeysHandled() { HashSet<KeyCode> keyCodes = new HashSet<KeyCode>(); keyCodes.UnionWith(getKeyDownHandlers().Keys); keyCodes.UnionWith(getKeyUpHandlers().Keys); keyCodes.UnionWith(getKeyHandlers().Keys); return keyCodes; }
/// <summary>List of cell ids for cells in the same context as the provided cell.</summary> /// <remarks>The "context" is the union of the Row, Column, and Shape for the provided cell.</remarks> /// <param name="cell">The cell id to find others in the same context.</param> /// <returns>The cell ids of all other cells in the same context.</returns> public virtual IEnumerable<int> Context(int cell) { HashSet<Cell> cells = new HashSet<Cell>(); cells.UnionWith(GetRowRegionForCell(cell).Cells); cells.UnionWith(GetColumnRegionForCell(cell).Cells); cells.UnionWith(GetShapeRegionForCell(cell).Cells); return EnumerateIds(cells, cell); }
public HashSet<Node> getAllEdges() { HashSet<Node> allEdges = new HashSet<Node>(); allEdges.UnionWith(_taxiEdges); allEdges.UnionWith(_busEdges); allEdges.UnionWith(_ugEdges); return allEdges; }
public async Task<CodeGenResult> CodeGen(Workspace workspace, Project project) { CompilationUnitSyntax cu = SF.CompilationUnit(); var usings = new HashSet<string>(); bool copyUsings = false; foreach (Document document in project.Documents) { SyntaxTree syntaxTree = await document.GetSyntaxTreeAsync(); _semanticModel = await document.GetSemanticModelAsync(); IEnumerable<ClassDeclarationSyntax> classes = syntaxTree.GetRoot().DescendantNodes().OfType<ClassDeclarationSyntax>(); foreach (var classNode in classes) { if (!RoslynUtils.IsPublic(classNode)) continue; ITypeSymbol swmrInterface = FindSwmrInterface(classNode); if (swmrInterface == null) { continue; } var namespaceNode = classNode.Parent as NamespaceDeclarationSyntax; if (namespaceNode == null) { throw new Exception("A grain must be declared inside a namespace"); } usings.UnionWith(syntaxTree.GetRoot().DescendantNodes().OfType<UsingDirectiveSyntax>().Select(usingDirective => usingDirective.Name.ToString())); int replicaCount = GetReadReplicaCount(swmrInterface); NamespaceDeclarationSyntax namespaceDclr = SF.NamespaceDeclaration(SF.IdentifierName(namespaceNode.Name.ToString())).WithUsings(namespaceNode.Usings); namespaceDclr = namespaceDclr.AddMembers( GenerateWriteGrain(classNode, swmrInterface, replicaCount), GenerateReadGrain(classNode, swmrInterface, replicaCount), GenerateReadReplicaGrain(classNode, swmrInterface) ); usings.UnionWith(namespaceNode.Usings.Select(@using => @using.Name.ToString())); cu = cu.AddMembers(namespaceDclr); // only copy the usings if at least one class was generated copyUsings = true; } } if (copyUsings) { usings.UnionWith(GetCommonUsings()); } return new CodeGenResult(Formatter.Format(cu, workspace).ToString(), usings); }
/// <summary> /// Returns a HashSet of the two pockets and all of their contents. /// </summary> /// <returns> /// a HashSet of the two pockets and all of their contents. /// </returns> public HashSet<Thing> GetRecursiveContents() { HashSet<Thing> temp = new HashSet<Thing>(); temp.Add(leftPocket); temp.Add(rightPocket); temp.UnionWith( leftPocket.GetRecursiveContents()); temp.UnionWith(rightPocket.GetRecursiveContents()); return temp; }
public HashSet<char> GetVariables() { HashSet<char> variables = new HashSet<char>(); variables.UnionWith(baseOfPower.GetVariables()); variables.UnionWith(exponent.GetVariables()); return variables; }
public HashSet<char> GetVariables() { HashSet<char> variables = new HashSet<char>(); variables.UnionWith(baseOfLogarithm.GetVariables()); variables.UnionWith(number.GetVariables()); return variables; }
public HashSet<string> MergeAll() { var results = new HashSet<string>(); results.UnionWith(OnlyInSource); results.UnionWith(OnlyInTarget); results.UnionWith(DifferentContents); results.UnionWith(IdenticalContents); return results; }
public HashSet<EntityId> GetIds() { var set = new HashSet<EntityId>(); set.UnionWith(_phoneDictionary.Select(x=>x.Key)); set.UnionWith(_businessDictionary.Select(x=>x.Key)); set.UnionWith(_personDictionary.Select(x=>x.Key)); set.UnionWith(_locationDictionary.Select(x=>x.Key)); return set; }
public IEnumerable<IWatcher> Materialize(KeeperState state, EventType type, string clientPath) { HashSet<IWatcher> result = new HashSet<IWatcher>(); switch (type) { case EventType.None: result.Add(defaultWatcher); foreach (var ws in dataWatches.Values) { result.UnionWith(ws); } foreach (var ws in existWatches.Values) { result.UnionWith(ws); } foreach(var ws in childWatches.Values) { result.UnionWith(ws); } // clear the watches if auto watch reset is not enabled if (ClientConnection.DisableAutoWatchReset && state != KeeperState.SyncConnected) { dataWatches.Clear(); existWatches.Clear(); childWatches.Clear(); } return result; case EventType.NodeDataChanged: case EventType.NodeCreated: AddTo(dataWatches.GetAndRemove(clientPath), result); AddTo(existWatches.GetAndRemove(clientPath), result); break; case EventType.NodeChildrenChanged: AddTo(childWatches.GetAndRemove(clientPath), result); break; case EventType.NodeDeleted: AddTo(dataWatches.GetAndRemove(clientPath), result); // XXX This shouldn't be needed, but just in case HashSet<IWatcher> list = existWatches.GetAndRemove(clientPath); if (list != null) { AddTo(existWatches.GetAndRemove(clientPath), result); #if !NET_CORE LOG.Warn("We are triggering an exists watch for delete! Shouldn't happen!"); #endif } AddTo(childWatches.GetAndRemove(clientPath), result); break; default: var msg = new StringBuilder("Unhandled watch event type ").Append(type).Append(" with state ").Append(state).Append(" on path ").Append(clientPath).ToString(); #if !NET_CORE LOG.Error(msg); #endif throw new InvalidOperationException(msg); } return result; }
public IEnumerable<PhonebookEntry> Find(string name) { HashSet<PhonebookEntry> matched = new HashSet<PhonebookEntry>(); matched.UnionWith(this.byFirstName[name]); matched.UnionWith(this.byMiddleName[name]); matched.UnionWith(this.byLastName[name]); matched.UnionWith(this.byNickname[name]); return matched; }
public HashSet<char> GetVariables() { HashSet<char> variables = new HashSet<char>(); variables.UnionWith(nthRoot.GetVariables()); variables.UnionWith(baseOfRoot.GetVariables()); return variables; }
public IEnumerable<IContact> GetSameContactsAs(IContact c) { var hash = new HashSet<IContact>(); hash.UnionWith(GetContactsFor(c.FullName)); foreach (string email in c.Emails) { hash.UnionWith(GetContactsFor(email)); } return hash; }
private static IEnumerable<Type> MergeKnownTypesWithDynamicProxyTypes(IEnumerable<Type> knownTypes) { var tmp = new HashSet<Type>(); if (knownTypes != null) tmp.UnionWith(knownTypes); tmp.UnionWith(EfDynamicProxyAssemblies.GetTypes()); return tmp; }
/// <summary> /// Find all the possible implementations of the given type. /// </summary> public IEnumerable<Type> GetAllConcreteTypes(Type serviceType) { var types = new HashSet<Type>(); if (mappings.ContainsKey(serviceType)) types.UnionWith(mappings[serviceType]); if(Parent != null) types.UnionWith(Parent.GetAllConcreteTypes(serviceType)); return types; }
public IEnumerable<PhonebookEntry> Find(string name, string town) { HashSet<PhonebookEntry> matchedByName = new HashSet<PhonebookEntry>(); matchedByName.UnionWith(this.byFirstName[name]); matchedByName.UnionWith(this.byMiddleName[name]); matchedByName.UnionWith(this.byLastName[name]); matchedByName.UnionWith(this.byNickname[name]); IEnumerable<PhonebookEntry> matchedByNameAndTown = matchedByName.Where(entry => entry.Town == town); return matchedByNameAndTown; }
public CryptArithmeticProblem(CryptArithmeticInstanceDescription instanceDescriptor) { this.terms = instanceDescriptor.Terms; this.result = instanceDescriptor.Result; HashSet<char> charsInExpression = new HashSet<char>(); foreach (string term in terms) { charsInExpression.UnionWith(term.ToCharArray()); } charsInExpression.UnionWith(result.ToCharArray()); charArray = charsInExpression.ToArray(); }
public void SaveToFile(string suppressionsFilePath) { HashSet<string> lines = new HashSet<string>(); lines.Add("[cppcheck]"); lines.UnionWith(SuppressionLines); lines.Add("[cppcheck_files]"); lines.UnionWith(SkippedFilesMask); lines.Add("[cppcheck_includes]"); lines.UnionWith(SkippedIncludesMask); System.IO.FileInfo file = new System.IO.FileInfo(suppressionsFilePath); file.Directory.Create(); // If the directory already exists, this method does nothing. File.WriteAllLines(suppressionsFilePath, lines); }
public static List<List<String>> OrderByCount(List<List<String>> list) { list = list.OrderBy(item => item.Count()).ToList(); HashSet<string> sumAll = new HashSet<string>(); HashSet<string> listIntersect = new HashSet<string>(); HashSet<string> listExcept = new HashSet<string>(); HashSet<string> listEndExc = new HashSet<string>(); List<List<string>> tmpIntExc = new List<List<string>>(); // List of lists int i = 0; while (i < list.Count() - 1) { listIntersect = new HashSet<string>(list[i].Intersect(list[i + 1])); listIntersect.ExceptWith(sumAll); sumAll.UnionWith(listIntersect); listExcept = new HashSet<string>(list[i].Except(list[i + 1])); listExcept.ExceptWith(sumAll); sumAll.UnionWith(listExcept); i++; if (i == list.Count() - 1) { listEndExc = new HashSet<string>(list[list.Count() - 1]); listEndExc.ExceptWith(sumAll); } List<string> kkk = new List<string>(listIntersect);// List of Intersect List<string> mmm = new List<string>(listExcept);// List of Except List<string> nnn = new List<string>(listEndExc); if (kkk.Any()) { tmpIntExc.Add(kkk); } if (mmm.Any()) { tmpIntExc.Add(mmm); } if (nnn.Any()) { tmpIntExc.Add(nnn); } } return tmpIntExc.OrderBy(l=>l.Count).ThenBy((l=>l.First())).ToList(); //DisplaySet(tmpIntExc); }
public static HashSet<CyPhyML.Component> getCyPhyMLComponentSet(CyPhyML.ComponentAssemblies cyPhyMLComponentAssemblies) { HashSet<CyPhyML.Component> cyPhyMLComponentSet = new HashSet<CyPhyML.Component>(); foreach (CyPhyML.ComponentAssemblies childComponentAssembliesFolder in cyPhyMLComponentAssemblies.Children.ComponentAssembliesCollection) { cyPhyMLComponentSet.UnionWith(getCyPhyMLComponentSet(childComponentAssembliesFolder)); } foreach (CyPhyML.ComponentAssembly childComponentAssemblyFolder in cyPhyMLComponentAssemblies.Children.ComponentAssemblyCollection) { cyPhyMLComponentSet.UnionWith(getCyPhyMLComponentSet(childComponentAssemblyFolder)); } return cyPhyMLComponentSet; }
/// <summary> /// 返回文档所有节点,包括已分配和游离的 /// </summary> /// <param name="document">查找节点的文档</param> /// <returns>文档的所有节点</returns> public static IEnumerable<IHtmlNode> AllNodes( this IHtmlDocument document ) { if ( document == null ) throw new ArgumentNullException( "document" ); var nodes = new HashSet<IHtmlNode>(); nodes.UnionWith( document.DescendantNodes() ); var manager = document.FragmentManager; if ( manager != null ) nodes.UnionWith( manager.AllFragments.SelectMany( fragment => fragment.DescendantNodes() ) ); return nodes; }