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


C# SortedSet.UnionWith方法代码示例

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


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

示例1: 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

示例2: Preprocess

 public ISet<string> Preprocess(ISet<string> tags)
 {
     var resultTags = new SortedSet<string>();
     foreach (var tag in tags.Select(t => SkipPattern.Replace(t, "")))
         resultTags.UnionWith(tag.Split(SplitChars, StringSplitOptions.RemoveEmptyEntries));
     return resultTags;
 }
开发者ID:CrowdKnowledge,项目名称:codetag,代码行数:7,代码来源:SpecialCharsTagPreprocessor.cs

示例3: RangedListFilter

 public RangedListFilter(IEnumerable<IEnumerable<byte[]>> buckets)
 {
     if (items == null)
         throw new ArgumentNullException ("items");
     this.items = new SortedSet<byte[]> (items);
     byte[] min = null;
     byte[] max = null;
     foreach (IEnumerable<byte[]> bucket in buckets) {
         items.UnionWith (bucket);
     }
     int maxItemLength = int.MaxValue;
     //TODO: this procedure needs a hell lot of optimization and security fixes
     foreach (byte[] item in items) {
         if (min == null) {
             min = item;
             max = item;
         }
         if (min.CompareTo (item) < 0)
             min = item;
         if (max.CompareTo (item) > 0)
             max = item;
         if (item.Length > maxItemLength)
             maxItemLength = item.Length;
     }
     first = min;
     last = max;
     skipBytes = Math.Min (min.IdenticalBytesWith (max), maxItemLength);
 }
开发者ID:vebin,项目名称:BD2,代码行数:28,代码来源:RangedListFilter.cs

示例4: SpecRunCoordinator_should_route_messages_correctly_to_child_NodeDataActors

        public void SpecRunCoordinator_should_route_messages_correctly_to_child_NodeDataActors()
        {
            var nodeIndexes = Enumerable.Range(1, 3).ToArray();
            var nodeTests = NodeMessageHelpers.BuildNodeTests(nodeIndexes);

            var specRunCoordinator = Sys.ActorOf(Props.Create(() => new SpecRunCoordinator(nodeTests.First()
                .TypeName, nodeTests.First().MethodName, nodeTests)));

            var messages = NodeMessageHelpers.GenerateMessageSequence(nodeIndexes, 100);
            foreach (var multiNodeMessage in messages)
            {
                specRunCoordinator.Tell(multiNodeMessage);
            }

            //End the test
            specRunCoordinator.Tell(new EndSpec(), TestActor);
            var factData = ExpectMsg<FactData>();

            // Combine the messages from each individual NodeData back into a unioned set. 
            // Should match what we sent (messages.)
            var combinedTimeline = new SortedSet<MultiNodeMessage>();
            foreach(var nodeData in factData.NodeFacts)
                combinedTimeline.UnionWith(nodeData.Value.EventStream);

            Assert.Equal(nodeIndexes.Length, factData.NodeFacts.Count);
            Assert.True(messages.SetEquals(combinedTimeline));
        }
开发者ID:MaciekLesiczka,项目名称:akka.net,代码行数:27,代码来源:SpecRunCoordinatorSpec.cs

示例5: GenerateMessageDistributionForNodes

        /// <summary>
        /// Meta-function for generating a distribution of messages across multiple nodes
        /// </summary>
        private static SortedSet<MultiNodeMessage> GenerateMessageDistributionForNodes(IEnumerable<int> nodeIndices,
            int count, Func<int, int, SortedSet<MultiNodeMessage>> messageGenerator)
        {
            var nodes = nodeIndices.ToList();
            var messages = new SortedSet<MultiNodeMessage>();

            //special case for 1:1 distribution
            if (nodes.Count == count)
            {
                foreach (var node in nodes)
                {
                    messages.UnionWith(messageGenerator(node, node));
                }
                return messages;
            }

            // Key = nodeIndex, Value = # of allocated messages
            var messageDistribution = new Dictionary<int, int>();
            foreach (var node in nodes)
            {
                messageDistribution[node] = 0;
            }

            var remainingMessages = count;
            var nodeIterator = nodes.GetContinuousEnumerator();

            while (remainingMessages > 0)
            {
                nodeIterator.MoveNext();
                var node = nodeIterator.Current;
                var added = Faker.Generators.Numbers.Int(1, Math.Max(1, remainingMessages / 2));

                //Don't go over the message count
                if (added > remainingMessages)
                    added = remainingMessages;

                messageDistribution[node] += added;
                remainingMessages -= added;
            }

            //generate the assigned sequence for each node
            foreach (var node in messageDistribution)
                messages.UnionWith(messageGenerator(node.Key, node.Value));

            return messages;
        }
开发者ID:,项目名称:,代码行数:49,代码来源:

示例6: GetFunctionsUsingAddresses

		internal ICollection<string> GetFunctionsUsingAddresses(ICollection<FullCellAddr> fcas) {
			ISet<string> affectedFunctions = new SortedSet<string>();
			foreach (FullCellAddr fca in fcas) {
				HashSet<string> names;
				if (fca.sheet.IsFunctionSheet && addressToFunctionList.TryGetValue(fca, out names)) {
					affectedFunctions.UnionWith(names);
				}
			}
			return affectedFunctions;
		}
开发者ID:josiahdj,项目名称:SDFCalc,代码行数:10,代码来源:CellsUsedInFunctions.cs

示例7: ExcludeLeft

        static SortedSet<char> ExcludeLeft(SortedSet<char> intersectionResult,
            string[] tokens)
        {
            char[] rightArray = tokens[1].ToCharArray();
            SortedSet<char> result =
                new SortedSet<char>();

            result.UnionWith(rightArray);
            result.ExceptWith(intersectionResult);
            return result;
        }
开发者ID:YouJinTou,项目名称:SoftUniHomework,代码行数:11,代码来源:ArrayMatcher.cs

示例8: CalculateDominatesSet

    public static SortedSet<IRBlock> CalculateDominatesSet(IRGraph cfg, SortedSet<IRBlock> V, SortedSet<IRBlock> VSansR, IRBlock v)
    {
        SortedSet<IRBlock> VSansv = new SortedSet<IRBlock>();
        VSansv.UnionWith(V);
        VSansv.Remove(v); // V - {v}
        SortedSet<IRBlock> S = FindReachableBlocks(cfg, v.GetIndex());

        VSansv.ExceptWith(S);

        return VSansv; // V - {v} - S
    }
开发者ID:TribeMedia,项目名称:tcd-swift,代码行数:11,代码来源:DominatorTree.cs

示例9: GetAllParentCategories

 public SortedSet<int> GetAllParentCategories(TimeSpan? CacheDuration = null)
 {
     SortedSet<int> parentCategoryList = null;
     var cache = DataCache.Cache;
     string cacheKey = "GAPRNTCAT:Cat:" + CategoryId;
     parentCategoryList = (SortedSet<int>)cache[cacheKey];
     if (parentCategoryList == null)
     {
         parentCategoryList = new SortedSet<int>();
         var parentCategories = CategoryClassParentCategories;
         var categoryParentIds = parentCategories.Select(c => c.ParentId);
         parentCategoryList.UnionWith(categoryParentIds);
         foreach (var item in parentCategories)
         {
             var categoryIds = GetAllParentCategories(item.ParentCategory, CacheDuration);
             if (categoryIds != null)
                 parentCategoryList.UnionWith(categoryIds);
         }
         cache.Put(cacheKey, parentCategoryList, CacheDuration != null ? (TimeSpan)CacheDuration : DataCache.CacheDuration);
     }
     return (parentCategoryList);
 }
开发者ID:agentvnod,项目名称:tfctvoldcode,代码行数:22,代码来源:Category.cs

示例10: Main

    public static void Main()
    {
        HashSet<Student> topStuds = new HashSet<Student>();
        topStuds.Add(new Student("Rami", 16, 21));
        topStuds.Add(new Student("Rida", 12, 18));
        topStuds.Add(new Student("Penko", 11, 17));
        topStuds.Add(new Student("Valyo", 10, 16));

        HashSet<Student> averageStuds = new HashSet<Student>();
        averageStuds.Add(new Student("Rami", 16, 21));
        averageStuds.Add(new Student("Velko", 10, 13));
        averageStuds.Add(new Student("Kircho", 5, 10));

        SortedSet<Student> allStuds = new SortedSet<Student>();
        allStuds.UnionWith(topStuds);
        allStuds.UnionWith(averageStuds);

        foreach (var stud in allStuds)
        {
            Console.WriteLine("Name {0}, Grade {1}, Age {2}", stud.Name, stud.Grade, stud.Age);
        }
    }
开发者ID:RamiAmaire,项目名称:TelerikAcademy,代码行数:22,代码来源:Testing.cs

示例11: TestRunCoordinator_should_start_and_route_messages_to_SpecRunCoordinator

        public void TestRunCoordinator_should_start_and_route_messages_to_SpecRunCoordinator()
        {
            var testRunCoordinator = Sys.ActorOf(Props.Create<TestRunCoordinator>());
            var nodeIndexes = Enumerable.Range(1, 4).ToArray();
            var nodeTests = NodeMessageHelpers.BuildNodeTests(nodeIndexes);

            var beginSpec = new BeginNewSpec(nodeTests.First().TypeName, nodeTests.First().MethodName, nodeTests);

            //begin a new spec
            testRunCoordinator.Tell(beginSpec);

            // create some messages for each node, the test runner, and some result messages
            // just like a real MultiNodeSpec
            var allMessages = NodeMessageHelpers.GenerateMessageSequence(nodeIndexes, 300);
            var runnerMessages = NodeMessageHelpers.GenerateTestRunnerMessageSequence(20);
            allMessages.UnionWith(runnerMessages);

            foreach(var message in allMessages)
                testRunCoordinator.Tell(message);

            //end the spec
            testRunCoordinator.Tell(new EndTestRun(), TestActor);
            var testRunData = ExpectMsg<TestRunTree>();

            Assert.Equal(1, testRunData.Specs.Count());

            var specMessages = new SortedSet<MultiNodeMessage>();
            foreach (var spec in testRunData.Specs)
            {
                specMessages.UnionWith(spec.RunnerMessages);
                foreach(var fact in spec.NodeFacts)
                    specMessages.UnionWith(fact.Value.EventStream);
            }

            Assert.True(allMessages.SetEquals(specMessages));
               
        }
开发者ID:,项目名称:,代码行数:37,代码来源:

示例12: FillCache

 public void FillCache(IPTV2Entities context, TimeSpan cacheDuration, int offeringId, int serviceId)
 {
     DateTime registDt = DateTime.Now;
     try
     {
         var countries = context.Countries;
         var listOfProductPackages = context.ProductPackages.Where(p => p.Product.IsForSale && p.Product.StatusId == Visible).Select(p => p.Package).Distinct();
         var offering = context.Offerings.Find(offeringId);
         var service = offering.Services.FirstOrDefault(o => o.PackageId == serviceId);
         foreach (var package in listOfProductPackages)
         {
             foreach (var c in countries)
             {
                 string cacheKey = "GPKGFEAT:P:" + package.PackageId + ";C:" + c.Code;
                 List<string> list = new List<string>();
                 SortedSet<int> listOfShowIds = new SortedSet<int>();
                 try
                 {
                     foreach (var category in package.Categories)
                     {
                         listOfShowIds.UnionWith(service.GetAllOnlineShowIds(c.Code, category.Category));
                         if (category.Category is Category)
                         {
                             var item = (Category)category.Category;
                             var CategoryShowIds = service.GetAllOnlineShowIds(c.Code, item);
                             if (CategoryShowIds.Count() > 1000)
                                 list.Add(String.Format("{0}+ in {1}", Floor(CategoryShowIds.Count(), 100), item.Description));
                             else if (CategoryShowIds.Count() > 100)
                                 list.Add(String.Format("{0}+ in {1}", Floor(CategoryShowIds.Count(), 10), item.Description));
                             else if (CategoryShowIds.Count() > 10)
                                 list.Add(String.Format("{0}+ in {1}", Floor(CategoryShowIds.Count(), 10), item.Description));
                             else
                                 list.Add(String.Format("{0} in {1}", CategoryShowIds.Count(), item.Description));
                         }
                     }
                     int showCount = listOfShowIds.Count();
                     if (showCount < 10)
                         list.Add(String.Format("{0} {1}", showCount, showCount == 1 ? "Title" : "Titles"));
                     else
                         list.Add(String.Format("{0}+ Titles", Floor(showCount, 10)));
                     string jsonString = Newtonsoft.Json.JsonConvert.SerializeObject(list);
                     IPTV2_Model.DataCache.Cache.Put(cacheKey, jsonString, cacheDuration);
                 }
                 catch (Exception) { }
             }
         }
     }
     catch (Exception e) { Trace.TraceError("PackageFeatureCacheRefresher Cache - Error! " + e.Message); }
 }
开发者ID:agentvnod,项目名称:tfctvoldcode,代码行数:49,代码来源:PackageFeatureCacheRefresher.cs

示例13: GetActivePosProducts

        public IEnumerable<string> GetActivePosProducts(int merchantId)
        {
            var allMainProducts = _dbContext.pos_mainproducts;

            var merchantProducts = new SortedSet<string>(allMainProducts.Where(p => p.merchant_pk == merchantId && p.prdActive == 1)
                .Select(p=> p.prdDescription));

            var extraPosMainProducts = new SortedSet<string>
            {
                "longdistance"
            };

            merchantProducts.UnionWith(extraPosMainProducts);

            return merchantProducts;
        }
开发者ID:hansel0691,项目名称:BSpos,代码行数:16,代码来源:BsPromotionsRepository.cs

示例14: JoinArrays

        static SortedSet<char> JoinArrays(string[] tokens)
        {
            char[] leftArray = tokens[0].ToCharArray();
            char[] rightArray = tokens[1].ToCharArray();
            SortedSet<char> leftSet =
                new SortedSet<char>(leftArray);
            SortedSet<char> rightSet =
                new SortedSet<char>(rightArray);
            SortedSet<char> result =
                new SortedSet<char>();

            result.UnionWith(leftSet);
            result.IntersectWith(leftSet);
            result.IntersectWith(rightSet);
            return result;
        }
开发者ID:YouJinTou,项目名称:SoftUniHomework,代码行数:16,代码来源:ArrayMatcher.cs

示例15: Main

        static void Main(string[] args)
        {
            Console.Write("First list: ");
            string firstNumberList = Console.ReadLine();
            Console.Write("Second list: ");
            string secondNumberList = Console.ReadLine();

            string[] firstTokens = firstNumberList.Split(' ');
            string[] secondTokens = secondNumberList.Split(' ');

            SortedSet<int> firstNumbers = new SortedSet<int>();
            foreach (string number in firstTokens)
                firstNumbers.Add(int.Parse(number));

            SortedSet<int> secondNumbers = new SortedSet<int>();
            foreach (string number in secondTokens)
                secondNumbers.Add(int.Parse(number));

            firstNumbers.UnionWith(secondNumbers);
            foreach (int number in firstNumbers)
                Console.Write(number + " ");
            Console.WriteLine();
        }
开发者ID:YouJinTou,项目名称:SoftUniHomework,代码行数:23,代码来源:JoinLists.cs


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