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


C# SortedSet类代码示例

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


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

示例1: Parse

        public static void Parse(SortedSet<string> list, Expression expr)
        {
            if (expr == null)
                return;

            BinaryExpression eb = expr as BinaryExpression;
            MemberExpression em = expr as MemberExpression;
            UnaryExpression eu = expr as UnaryExpression;
            MethodCallExpression ec = expr as MethodCallExpression;


            if (em != null) // member expression
            {
                list.Add(em.Member.Name);
            }
            else if (eb != null) // binary expression
            {
                Parse(list, eb.Left);
                Parse(list, eb.Right);
            }
            else if (eu != null) // unary expression
            {
                Parse(list, eu.Operand);
            }
            else if (ec != null) // call expression
            {
                foreach (var a in ec.Arguments)
                    Parse(list, a);
            }


            return;
        }
开发者ID:accord-net,项目名称:framework,代码行数:33,代码来源:ExpressionParser.cs

示例2: ReadStudentsInfoFromFile

        private static void ReadStudentsInfoFromFile(string filePath, SortedDictionary<string, SortedSet<Student>> courses)
        {
            using (StreamReader reader = new StreamReader(filePath))
            {
                string line = reader.ReadLine();
                while (line != string.Empty && line != null)
                {
                    string[] data = line.Split('|');
                    string firstName = data[0].Trim();
                    string lastName = data[1].Trim();
                    string courseName = data[2].Trim();

                    if (courses.ContainsKey(courseName))
                    {
                        courses[courseName].Add(new Student(firstName, lastName));
                    }
                    else
                    {
                        courses[courseName] = new SortedSet<Student>();
                        courses[courseName].Add(new Student(firstName, lastName));
                    }

                    line = reader.ReadLine();
                }
            }
        }
开发者ID:dchakov,项目名称:Data-Structures-and-Algorithms_HW,代码行数:26,代码来源:StartUp.cs

示例3: TestCollectionContains

        public void TestCollectionContains()
        {
            var sortedSet = new SortedSet<int>();
            sortedSet.Add(10);
            sortedSet.Add(5);
            sortedSet.Add(6);
            sortedSet.Add(20);
            sortedSet.Add(13);
            sortedSet.Add(14);

            Assert.IsTrue(sortedSet.Contains(10));
            Assert.IsTrue(sortedSet.Contains(5));
            Assert.IsTrue(sortedSet.Contains(6));
            Assert.IsTrue(sortedSet.Contains(20));
            Assert.IsTrue(sortedSet.Contains(13));
            Assert.IsTrue(sortedSet.Contains(14));

            for (int i = 0; i < 4; i++)
            {
                Assert.IsFalse(sortedSet.Contains(i));
            }
            for (int i = 21; i < 50; i++)
            {
                Assert.IsFalse(sortedSet.Contains(i));
            }
        }
开发者ID:bdr27,项目名称:c-,代码行数:26,代码来源:UnitTest1.cs

示例4: buttonGerar_Click

        private void buttonGerar_Click(object sender, EventArgs e)
        {
            Task.Run(() => {
                ClearText();
                Random random = new Random((int) DateTime.Now.Ticks);
                SortedSet<string> numerosCertidao = new SortedSet<string>();

                int quantidade;
                if (!Int32.TryParse(textBoxQtd.Text, out quantidade)) {
                    InsertText(String.Format("Erro: \"{0}\" não é uma quantidade válida.", textBoxQtd.Text));
                    return;
                }

                while (numerosCertidao.Count() < quantidade) {
                    string numeroCertidao = CertidaoNascimentoHelper.GerarNumeroCertidao(random);
                    numeroCertidao =
                        numeroCertidao.Substring(0, 6) + " " +
                        numeroCertidao.Substring(6, 2) + " " +
                        numeroCertidao.Substring(8, 2) + " " +
                        numeroCertidao.Substring(10, 4) + " " +
                        numeroCertidao.Substring(14, 1) + " " +
                        numeroCertidao.Substring(15, 5) + " " +
                        numeroCertidao.Substring(20, 3) + " " +
                        numeroCertidao.Substring(23, 7) + " " +
                        numeroCertidao.Substring(30, 2);
                    numerosCertidao.Add(numeroCertidao);
                }

                foreach (var numero in numerosCertidao) {
                    InsertText(numero);
                }
            });
        }
开发者ID:arfurlaneto,项目名称:CertidaoNascimento,代码行数:33,代码来源:FormPrincipal.cs

示例5: Main

 static void Main()
 {
     Dictionary<string, SortedDictionary<string,SortedSet<string>>> NightLife = new Dictionary<string, SortedDictionary<string, SortedSet<string>>>();
     string city = "";
     string venue = "";
     string performars = "";
     string[] input = Console.ReadLine().Split(';');
     while (input[0] != "END")
     {
         city = input[0];
         venue = input[1];
         performars = input[2];
         if (!NightLife.ContainsKey(city))
         {
             NightLife[city] = new SortedDictionary<string, SortedSet<string>>();
         }
         if (!NightLife[city].ContainsKey(venue))
         {
             NightLife[city][venue] = new SortedSet<string>();
         }
         NightLife[city][venue].Add(performars);
         input = Console.ReadLine().Split(';');
     }
     foreach (var cityPair in NightLife)
     {
         Console.WriteLine(cityPair.Key);
         foreach (var venuePair in cityPair.Value)
         {
             Console.WriteLine("->{0}: {1}",venuePair.Key,String.Join(",",venuePair.Value));
         }
     }
 }
开发者ID:kiret0,项目名称:CSharp-Fundamental,代码行数:32,代码来源:NightLife.cs

示例6: LoadChildren

 protected override void LoadChildren()
 {
   base.Children.Add(new ObjectViewModel(m_databaseLocation, this, m_databaseLocation.Session));
   SortedSet<Database> dbSet = new SortedSet<Database>(m_databaseLocation.Session.OpenLocationDatabases(m_databaseLocation, false));
   foreach (Database database in dbSet)
     base.Children.Add(new DatabaseViewModel(this, database));
 }
开发者ID:MerlinBrasil,项目名称:VelocityDB,代码行数:7,代码来源:DatabaseLocationViewModel+.cs

示例7: SetUp

        public override void SetUp()
        {
            base.SetUp();
            // we generate aweful regexps: good for testing.
            // but for preflex codec, the test can be very slow, so use less iterations.
            NumIterations = Codec.Default.Name.Equals("Lucene3x") ? 10 * RANDOM_MULTIPLIER : AtLeast(50);
            Dir = NewDirectory();
            RandomIndexWriter writer = new RandomIndexWriter(Random(), Dir, (IndexWriterConfig)NewIndexWriterConfig(TEST_VERSION_CURRENT, new MockAnalyzer(Random(), MockTokenizer.KEYWORD, false)).SetMaxBufferedDocs(TestUtil.NextInt(Random(), 50, 1000)));
            Document doc = new Document();
            Field field = NewStringField("field", "", Field.Store.YES);
            doc.Add(field);
            Terms = new SortedSet<BytesRef>();

            int num = AtLeast(200);
            for (int i = 0; i < num; i++)
            {
                string s = TestUtil.RandomUnicodeString(Random());
                field.StringValue = s;
                Terms.Add(new BytesRef(s));
                writer.AddDocument(doc);
            }

            TermsAutomaton = BasicAutomata.MakeStringUnion(Terms);

            Reader = writer.Reader;
            Searcher = NewSearcher(Reader);
            writer.Dispose();
        }
开发者ID:joyanta,项目名称:lucene.net,代码行数:28,代码来源:TestTermsEnum2.cs

示例8: ListTests_Exception

 public void ListTests_Exception()
 {
     SortedSet<string> phoneNumbers = new SortedSet<string> { "+35929811111" };
     PhonebookRepository phonebook = new PhonebookRepository();
     phonebook.AddPhone("Kalina", phoneNumbers);
     phonebook.ListEntries(10, 10);
 }
开发者ID:NikolayGenov,项目名称:TelerikAcademy,代码行数:7,代码来源:ListTests.cs

示例9: AprioriGen

 //产生候选集:使用《数据挖掘导论》上P210页的方法
 static List<SortedSet<string>> AprioriGen(List<SortedSet<string>> kFequentSet)
 {
     List<SortedSet<string>> result = new List<SortedSet<string>>();
     for (int i = 0; i < kFequentSet.Count; i++)
     {
         SortedSet<string> aTmpSet = new SortedSet<string>(kFequentSet[i]);
         string aLastElement = kFequentSet[i].Last<string>();
         aTmpSet.Remove(aLastElement);//去掉最后一个元素
         for (int j = i + 1; j < kFequentSet.Count; j++)
         {
             SortedSet<string> bTmpSet = new SortedSet<string>(kFequentSet[j]);
             string bLastElement = kFequentSet[j].Last<string>();
             bTmpSet.Remove(bLastElement);//去掉最后一个元素
             if (bTmpSet.Count == aTmpSet.Count)
             {
                 bTmpSet.ExceptWith(aTmpSet);
                 if (bTmpSet.Count == 0 && !aLastElement.Equals(bLastElement))//前k-2个元素相同而最后一个元素不同
                 {
                     result.Add(new SortedSet<string>(kFequentSet[i]));
                     result[result.Count - 1].Add(bLastElement);
                 }
             }
         }
     }
     return result;
 }
开发者ID:CaseyYang,项目名称:WebProjects,代码行数:27,代码来源:Program.cs

示例10: GetContactList

        public ActionResult GetContactList()
        {
            if (!PingNotif())
            {
                return new HttpStatusCodeResult(HttpStatusCode.Unauthorized);
            }

            logger.LogActionEnter(Session.SessionID, "/Service/GetContactList");

            SortedSet<GetContactListResponse_User> list = new SortedSet<GetContactListResponse_User>();
            User user = UserManager.GetUser(System.Web.HttpContext.Current.User.Identity.Name);

            Dictionary<string, User> contact_list = UserManager.GetContactList(user);
            foreach(KeyValuePair<string, User> u in contact_list)
            {
                list.Add(new GetContactListResponse_User
                {
                    user_id = u.Value.user_id,
                    login = u.Value.login,
                    nickname = u.Key,
                    status = (int)u.Value.status,
                    description = u.Value.descripton
                });
            }

            logger.LogActionLeave(Session.SessionID, "/Service/GetContactList", list.Count + " contacts sent");
            return Json(list.OrderBy(u => u.user_id));
        }
开发者ID:neri14,项目名称:projekt_zespolowy,代码行数:28,代码来源:ServiceController.cs

示例11: Main

        public static void Main()
        {
            Console.WriteLine("A TV company needs to lay cables to a new neighborhood (for every house).");
            Console.WriteLine("Some of the paths are longer. Find a way to minimize the cost for cables.\n");
            SortedSet<Edge> priority = new SortedSet<Edge>();
            int numberOfNodes = 8;
            bool[] used = new bool[numberOfNodes + 1];
            List<Edge> mpdNodes = new List<Edge>();
            List<Edge> edges = new List<Edge>();
            InitializeGraph(edges);

            Console.WriteLine("The paths from house to house are:");

            //adding edges that connect the node 1 with all the others - 2, 3, 4
            for (int i = 0; i < edges.Count; i++)
            {
                Console.WriteLine("{0}", edges[i]);
                if (edges[i].StartNode == edges[0].StartNode)
                {
                    priority.Add(edges[i]);
                }
            }
            used[edges[0].StartNode] = true;

            FindMinimumSpanningTree(used, priority, mpdNodes, edges);

            PrintMinimumSpanningTree(mpdNodes);
        }
开发者ID:RamiAmaire,项目名称:TelerikAcademy,代码行数:28,代码来源:Program.cs

示例12: Main

        public static void Main(string[] args)
        {
            SortedDictionary<string, SortedSet<Fullname>> courseDictionary = new SortedDictionary<string, SortedSet<Fullname>>();

            using (FileStream fs = new FileStream("students.txt", FileMode.Open))
            {
                StreamReader reader = new StreamReader(fs);

                while (!reader.EndOfStream)
                {
                  var lineItems =  reader.ReadLine().Split('|').Select(x => x.Trim()).ToArray();

                    SortedSet<Fullname> students;

                    if (!courseDictionary.TryGetValue(lineItems[2], out students))
                    {
                        students = new SortedSet<Fullname>();

                        courseDictionary.Add(lineItems[2], students);
                    }

                    students.Add(new Fullname()
                    {
                        FirstName = lineItems[0],
                        LastName = lineItems[1]
                    });
                }
            }

            foreach (var course in courseDictionary)
            {
                Console.WriteLine("{0}:{1}", course.Key, string.Join(",", course.Value));
            }
        }
开发者ID:iovigi,项目名称:Telerik-Academy,代码行数:34,代码来源:StartUp.cs

示例13: ConvertForwardReferencesToNamespaces

        public Namespace ConvertForwardReferencesToNamespaces(
            IEnumerable<CLITypeReference> typeReferences)
        {
            // Create a new tree of namespaces out of the type references found.
            var rootNamespace = new TranslationUnit();
            rootNamespace.Module = TranslationUnit.Module;

            var sortedRefs = typeReferences.ToList();
            sortedRefs.Sort((ref1, ref2) =>
                string.CompareOrdinal(ref1.FowardReference, ref2.FowardReference));

            var forwardRefs = new SortedSet<string>();

            foreach (var typeRef in sortedRefs)
            {
                if (string.IsNullOrWhiteSpace(typeRef.FowardReference))
                    continue;

                var declaration = typeRef.Declaration;
                if (!(declaration.Namespace is Namespace))
                    continue;

                if (!forwardRefs.Add(typeRef.FowardReference))
                    continue;

                if (typeRef.Include.InHeader)
                    continue;

                var @namespace = FindCreateNamespace(rootNamespace, declaration);
                @namespace.TypeReferences.Add(typeRef);
            }

            return rootNamespace;
        }
开发者ID:acklinr,项目名称:CppSharp,代码行数:34,代码来源:CLIHeadersTemplate.cs

示例14: Main

    static void Main()
    {
        var findedAreas = new SortedSet<Area>();
        for (int row = 0; row < matrix.GetLength(0); row++)
        {
            for (int col = 0; col < matrix.GetLength(1); col++)
            {
                if (matrix[row, col] == ' ')
                {
                    GetConnectedAreaSize(row, col);
                    var area = new Area(row, col, areaSize);
                    findedAreas.Add(area);
                    areaSize = 0;
                }
            }
        }

        if (findedAreas.Any())
        {
            Console.WriteLine("Total areas found: {0}", findedAreas.Count);
            int number = 0;
            foreach (var area in findedAreas)
            {
                ++number;
                Console.WriteLine("Area #{0} at {1}", number, area.ToString());
            }
        }
    }
开发者ID:milen-vm,项目名称:Algorithms,代码行数:28,代码来源:ConnectedAreasInAMatrix.cs

示例15: ExecuteResult

        /// <inheritdoc />
        public override void ExecuteResult(ControllerContext context)
        {
            var response = context.HttpContext.Response;

            response.StatusCode = 200;
            response.ContentType = "application/x-" + this.service + "-advertisement";
            response.BinaryWrite(ProtocolUtils.PacketLine("# service=" + this.service + "\n"));
            response.BinaryWrite(ProtocolUtils.EndMarker);

            var ids = new SortedSet<string>(this.repo.Refs.Select(r => r.TargetIdentifier));

            var first = true;
            foreach (var id in ids)
            {
                var line = first
                    ? string.Format("{0} refs/anonymous/{0}\0{1}\n", id, this.GetCapabilities())
                    : string.Format("{0} refs/anonymous/{0}\n", id);

                response.BinaryWrite(ProtocolUtils.PacketLine(line));

                first = false;
            }

            if (first)
            {
                var line = string.Format("{0} capabilities^{{}}\0{1}\n", ProtocolUtils.ZeroId, this.GetCapabilities());

                response.BinaryWrite(ProtocolUtils.PacketLine(line));
            }

            response.BinaryWrite(ProtocolUtils.EndMarker);
            response.End();
        }
开发者ID:otac0n,项目名称:GitReview,代码行数:34,代码来源:AdvertiseRefsResult.cs


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