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


C# HashSet.Overlaps方法代码示例

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


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

示例1: TestOverlaps

		public void TestOverlaps ()
		{
			var aSet = new HashSet<int> { 1, 2 };  
			var bSet = new HashSet<int> { 1 };  

			Assert.IsTrue (aSet.Overlaps (bSet));
		}
开发者ID:caloggins,项目名称:DOT-NET-on-Linux,代码行数:7,代码来源:HashSetExampleTests.cs

示例2: getEffectListByKey

    public virtual List<AbstracteEffect> getEffectListByKey(HashSet<EffectActionTypes> keys)
    {
        List<AbstracteEffect> returnedList = new List<AbstracteEffect> ();

        foreach (AbstracteEffect effect in effects.Values) {
            if (keys.Overlaps(effect.getEffectActionList())) {
                returnedList.Add(effect);
            }
        }
        return returnedList;
    }
开发者ID:Grimm-Mushroom,项目名称:Mages,代码行数:11,代码来源:AbstractInteractive.cs

示例3: Main

        static void Main(string[] args)
        {
            var myHash = new HashSet<String>();

            myHash.Add("hello");
            myHash.Add("hello");

            String[] s = new String[] { "hello" };

            Console.WriteLine(myHash.Count);
            Console.WriteLine(myHash.Overlaps(s));
        }
开发者ID:RickyGenz,项目名称:Learning-C-Sharp,代码行数:12,代码来源:Program.cs

示例4: getEffectListByKey

    public override List<AbstracteEffect> getEffectListByKey(HashSet<EffectActionTypes> keys)
    {
        List<AbstracteEffect> returnedList = base.getEffectListByKey (keys);

        for (int i = currentLifeIndex; i < healthPoints.Length; i++) {
            if ((healthPoints [i].effect != null) &&
                (keys.Overlaps(healthPoints [i].effect.getEffectActionList()))
            ) {
                returnedList.Add(healthPoints [i].effect);
            }
        }

        return returnedList;
    }
开发者ID:Grimm-Mushroom,项目名称:Mages,代码行数:14,代码来源:AbstractDamageable.cs

示例5: Main

        static void Main()
        {
            var companyTeams = new HashSet<string>() { "Ferrari", "McLaren", "Mercedes" };
            var traditionalTeams = new HashSet<string>() { "Ferrari", "McLaren" };
            var privateTeams = new HashSet<string>() { "Red Bull", "Lotus", "Toro Rosso", "Force India", "Sauber" };

            if (privateTeams.Add("Williams"))
                WriteLine("Williams added");
            if (!companyTeams.Add("McLaren"))
                WriteLine("McLaren was already in this set");

            if (traditionalTeams.IsSubsetOf(companyTeams))
            {
                WriteLine("traditionalTeams is subset of companyTeams");
            }

            if (companyTeams.IsSupersetOf(traditionalTeams))
            {
                WriteLine("companyTeams is a superset of traditionalTeams");
            }


            traditionalTeams.Add("Williams");
            if (privateTeams.Overlaps(traditionalTeams))
            {
                WriteLine("At least one team is the same with traditional and private teams");
            }

            var allTeams = new SortedSet<string>(companyTeams);
            allTeams.UnionWith(privateTeams);
            allTeams.UnionWith(traditionalTeams);

            WriteLine();
            WriteLine("all teams");
            foreach (var team in allTeams)
            {
                WriteLine(team);
            }

            allTeams.ExceptWith(privateTeams);
            WriteLine();
            WriteLine("no private team left");
            foreach (var team in allTeams)
            {
                WriteLine(team);
            }

        }
开发者ID:ProfessionalCSharp,项目名称:ProfessionalCSharp6,代码行数:48,代码来源:Program.cs

示例6: GetDisplayedBountyValue

		int GetDisplayedBountyValue(Actor self, HashSet<string> deathTypes, string bountyType)
		{
			var bounty = GetBountyValue(self);
			if (cargo == null)
				return bounty;

			foreach (var a in cargo.Passengers)
			{
				var givesProximityBounty = a.TraitsImplementing<GivesProximityBounty>().Where(gpb => deathTypes.Overlaps(gpb.info.DeathTypes)
					&& (gpb.info.BountyTypes.Count == 0 || gpb.info.BountyTypes.Contains(bountyType)));
				foreach (var gpb in givesProximityBounty)
					bounty += gpb.GetDisplayedBountyValue(a, deathTypes, bountyType);
			}

			return bounty;
		}
开发者ID:GraionDilach,项目名称:OpenRA.Mods.AS,代码行数:16,代码来源:GivesProximityBounty.cs

示例7: GetRequiredStrippableModules

		private static HashSet<string> GetRequiredStrippableModules(HashSet<string> nativeClasses)
		{
			HashSet<string> hashSet = new HashSet<string>();
			string[] moduleNames = ModuleMetadata.GetModuleNames();
			for (int i = 0; i < moduleNames.Length; i++)
			{
				string text = moduleNames[i];
				if (ModuleMetadata.GetModuleStrippable(text))
				{
					HashSet<string> classNames = CodeStrippingUtils.GetClassNames(ModuleMetadata.GetModuleClasses(text));
					if (nativeClasses.Overlaps(classNames))
					{
						hashSet.Add(text);
					}
				}
			}
			return hashSet;
		}
开发者ID:guozanhua,项目名称:UnityDecompiled,代码行数:18,代码来源:CodeStrippingUtils.cs

示例8: CalculateSort

        /// <summary>
        /// Append the result of this dependency graph to the end of the given sorting solution
        /// </summary>
        /// <param name="instance">The instance.</param>
        /// <returns></returns>
        public TopologicalSort CalculateSort(TopologicalSort instance)
        {
            HashSet<OrderedProcess> unused = new HashSet<OrderedProcess>(_processes);

            do
            {
                HashSet<OrderedProcess> set = new HashSet<OrderedProcess>(
                    unused.Where(p => !unused.Overlaps(p.Predecessors)) //select processes which have no predecessors in the unused set, which means that all their predecessors must either be used, or not exist, either way is fine
                );

                if (set.Count == 0)
                    throw new InvalidOperationException("Cannot order this set of processes");

                unused.ExceptWith(set);

                foreach (var subset in SolveResourceDependencies(set))
                    instance.Append(subset);
            }
            while (unused.Count > 0);

            return instance;
        }
开发者ID:martindevans,项目名称:TopologicalSorting,代码行数:27,代码来源:DependencyGraph.cs

示例9: GetRequiredStrippableModules

 private static HashSet<string> GetRequiredStrippableModules(HashSet<string> nativeClasses)
 {
   HashSet<string> stringSet = new HashSet<string>();
   foreach (string moduleName in ModuleMetadata.GetModuleNames())
   {
     if (ModuleMetadata.GetModuleStrippable(moduleName))
     {
       HashSet<string> classNames = CodeStrippingUtils.GetClassNames((IEnumerable<int>) ModuleMetadata.GetModuleClasses(moduleName));
       if (nativeClasses.Overlaps((IEnumerable<string>) classNames))
         stringSet.Add(moduleName);
     }
   }
   return stringSet;
 }
开发者ID:BlakeTriana,项目名称:unity-decompiled,代码行数:14,代码来源:CodeStrippingUtils.cs

示例10: LocationsAreUniqueOnRoute

 public static bool LocationsAreUniqueOnRoute(INetworkCoverage source, Route route)
 {
     //find all locations and checks for doubles.
     var locationsSet = new HashSet<INetworkLocation>();
     foreach (var segment in route.Segments.Values)
     {
         IEnumerable<INetworkLocation> locations = GetLocationsForSegment(segment, source, false);
         
         if (locationsSet.Overlaps(locations))
             return false;
         foreach (var location in locations)
         {
             locationsSet.Add(location);
         }
     }
     return true;
 }
开发者ID:lishxi,项目名称:_SharpMap,代码行数:17,代码来源:RouteHelper.cs

示例11: Change

        /// <summary>
        /// Verifies that no circular exception will be created and then sends CHANGE request to server.
        /// </summary>
        /// <param name="name">The cell to be changed</param>
        /// <param name="content">The candidate contents of the cell</param>
        public void Change(string name, string content)
        {
            // If we're waiting for a change to be confirmed by the server, don't take a new change.
            if (_currentChangeCell != null)
            {
                return;
            }
            var normalizedName = Normalize(name);

            // Check if content is null.
            if (content == null)
            {
                throw new ArgumentNullException();
            }
            // Check if name is null or invalid.
            if (normalizedName == null || !_validCellNameRegex.IsMatch(normalizedName) || !IsValid(normalizedName))
            {
                throw new InvalidNameException();
            }
            if (content.StartsWith("="))
            {
                Formula formula = new Formula(content.Substring(1), IsValid, Normalize);

                // The HashSet dependents contains name and all of name's direct and indirect dependents.
                var dependents = new HashSet<string>(GetCellsToRecalculate(normalizedName));

                // Variables contains name's new dependees.
                var variables = formula.GetVariables();

                // Checking if any of name's new dependees are already its dependents
                // or if name is its own new dependee.
                if (dependents.Overlaps(variables))
                {
                    throw new CircularException();
                }
            }
            _currentChangeCell = normalizedName;
            _currentChangeContent = content;
            _socket.BeginSend("CHANGE\n" + _name + "\n" + _version + "\nCell:" + normalizedName + "\nLength:" + content.Length.ToString() + "\n" + content + "\n", (e, o) => { }, null);
        }
开发者ID:OscarMarshall,项目名称:cs3505-SocialSpreadsheet-Client,代码行数:45,代码来源:Spreadsheet.cs

示例12: ExcludeModuleManagers

 private static void ExcludeModuleManagers(ref HashSet<string> nativeClasses)
 {
     string[] moduleNames = ModuleMetadata.GetModuleNames();
     int derivedFromClassID = BaseObjectTools.StringToClassID("GlobalGameManager");
     foreach (string str in moduleNames)
     {
         if (ModuleMetadata.GetModuleStrippable(str))
         {
             int[] moduleClasses = ModuleMetadata.GetModuleClasses(str);
             HashSet<int> set = new HashSet<int>();
             HashSet<string> other = new HashSet<string>();
             foreach (int num3 in moduleClasses)
             {
                 if (BaseObjectTools.IsDerivedFromClassID(num3, derivedFromClassID))
                 {
                     set.Add(num3);
                 }
                 else
                 {
                     other.Add(BaseObjectTools.ClassIDToString(num3));
                 }
             }
             if ((other.Count != 0) && !nativeClasses.Overlaps(other))
             {
                 foreach (int num5 in set)
                 {
                     nativeClasses.Remove(BaseObjectTools.ClassIDToString(num5));
                 }
             }
         }
     }
 }
开发者ID:randomize,项目名称:VimConfig,代码行数:32,代码来源:CodeStrippingUtils.cs

示例13: AddOutputAdapter

        // Adds an output adapter to the dependency chain.
        private void AddOutputAdapter(IOutputAdapter adapter, ISet<IAdapter> dependencyChain, IInputAdapter[] inputAdapterCollection, IActionAdapter[] actionAdapterCollection, IOutputAdapter[] outputAdapterCollection)
        {
            HashSet<MeasurementKey> inputMeasurementKeys = new HashSet<MeasurementKey>(adapter.InputMeasurementKeys());

            // Adds the adapter to the chain
            dependencyChain.Add(adapter);

            if ((object)inputAdapterCollection != null)
            {
                // Checks all input adapters to determine whether they also need to be
                // added to the chain as a result of this adapter being added to the chain
                foreach (IInputAdapter inputAdapter in inputAdapterCollection)
                {
                    if (!dependencyChain.Contains(inputAdapter) && inputMeasurementKeys.Overlaps(inputAdapter.OutputMeasurementKeys()))
                        AddInputAdapter(inputAdapter, dependencyChain, inputAdapterCollection, actionAdapterCollection, outputAdapterCollection);
                }
            }

            if ((object)actionAdapterCollection != null)
            {
                // Checks all action adapters to determine whether they also need to be
                // added to the chain as a result of this adapter being added to the chain
                foreach (IActionAdapter actionAdapter in actionAdapterCollection)
                {
                    if (actionAdapter.RespectOutputDemands && !dependencyChain.Contains(actionAdapter) && inputMeasurementKeys.Overlaps(actionAdapter.OutputMeasurementKeys()))
                        AddActionAdapter(actionAdapter, dependencyChain, inputAdapterCollection, actionAdapterCollection, outputAdapterCollection);
                }
            }
        }
开发者ID:rmc00,项目名称:gsf,代码行数:30,代码来源:RoutingTables.cs

示例14: RemoveGraphCycles

        /// <summary>
        /// temporarily flips joints to remove cycles
        /// </summary>
        private void RemoveGraphCycles()
        {
            HashSet<GraphNode> tempGraph = new HashSet<GraphNode>(RobotNodes.Values.ToArray());
            while (tempGraph.Count > 0)
            {
                bool hasFinished = false;
                while (!hasFinished)//remove all sources from tempGraph. A source is a node with no parents
                {
                    hasFinished = true;
                    GraphNode tempNode;

                    for (int i = 0; i < tempGraph.Count;i++ )
                    {
                        tempNode = tempGraph.ElementAt(i);
                        if(!tempGraph.Overlaps(tempNode.ParentNodes))
                        {
                            tempGraph.Remove(tempNode);
                            hasFinished = false;
                            i--;
                        }
                    }
                }
                hasFinished = false;
                while (!hasFinished)//remove all sinks from the graph. A sink is a node with no children
                {
                    hasFinished = true;
                    GraphNode tempNode;
                    for (int i = 0; i < tempGraph.Count; i++)
                    {
                        tempNode = tempGraph.ElementAt(i);
                        if(!tempGraph.Overlaps(tempNode.ChildNodes))
                        {
                            tempGraph.Remove(tempNode);
                            hasFinished = false;
                            i--;
                        }
                    }
                }

                if (tempGraph.Count > 0) //If nodes are left, they must be in a cycle, so flip joints to fix
                {
                    foreach (GraphNode tempNode in tempGraph)
                    {
                        if (tempNode.Equals(RobotNodes[0]) || tempNode.ParentNodes.Count > 1)
                        {
                            List<GraphNode> tempList = tempNode.ParentNodes.ToList();
                            foreach (GraphNode g in tempList)
                            {
                                if (tempGraph.Contains(g))
                                {
                                    tempNode.FlipJoint(g);
                                }

                            }
                            break;
                        }

                    }
                }

            }
        }
开发者ID:FRCTeam159,项目名称:MentorRepository,代码行数:65,代码来源:RobotGraphPanel.cs

示例15: CollectPminZeroStates

        //GL
        public HashSet<MDPStateStat> CollectPminZeroStates()
        {
            bool done = false;
            HashSet<MDPStateStat> target = new HashSet<MDPStateStat>(TargetStates);
            HashSet<MDPStateStat> reached = new HashSet<MDPStateStat>();
            reached.UnionWith(target);
            HashSet<MDPStateStat> copyTarget = new HashSet<MDPStateStat>(); //updated

            while (done == false)
            {

                HashSet<MDPStateStat> postreached = MDPStateStat.cloneHashSet(reached);
                List<MDPStateStat> preTarget = new List<MDPStateStat>();
                HashSet<MDPStateStat> intsPre = null;

                foreach (MDPStateStat state in reached)  //updated
                {
                    if (copyTarget.Contains(state)) { continue; }  //updated
                    preTarget = state.Pre;
                    if (intsPre == null)
                    {
                        intsPre = new HashSet<MDPStateStat>(preTarget);
                    }
                    else
                    {
                        //intsPre.IntersectWith(preTarget);
                        intsPre.UnionWith(preTarget);
                    }
                }

                // intsPre2 = this.ListStateFromHashset(intsPre);
                if (intsPre == null) { done = true; break; }  //updated
                HashSet<MDPStateStat> enLargeTarget = MDPStateStat.cloneHashSet(intsPre);

                foreach (MDPStateStat st in intsPre)
                {
                    foreach (DistributionStat ds in st.Distributions)
                    {
                        // HashSet<MDPStateStat> nextStates = new HashSet<KeyValuePair> (ds.States);
                        HashSet<MDPStateStat> endStates = new HashSet<MDPStateStat>();
                        endStates = ds.getEndStates();
                        if (!reached.Overlaps(endStates))  //updated
                        {
                            enLargeTarget.Remove(st);
                            goto firstforloop;
                        }
                    }
                firstforloop: ;
                }
                copyTarget = MDPStateStat.cloneHashSet(reached);  //updated
                postreached.UnionWith(enLargeTarget);
                if (reached.SetEquals(postreached)) done = true;
                reached = postreached;
            }
            return reached;
        }
开发者ID:nhannhan159,项目名称:PAT,代码行数:57,代码来源:MDPStat.cs


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