• 设为首页
  • 点击收藏
  • 手机版
    手机扫一扫访问
    迪恩网络手机版
  • 关注官方公众号
    微信扫一扫关注
    迪恩网络公众号

C# Collections.SortedSet类代码示例

原作者: [db:作者] 来自: [db:来源] 收藏 邀请

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



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

示例1: Main

        public static void Main(string[] args)
        {
            var students
                = new SortedDictionary<string, SortedSet<Student>>();
            var projectDir = Directory.GetParent(Directory.GetCurrentDirectory()).Parent.FullName;
            var file = new StreamReader (projectDir + Path.DirectorySeparatorChar + "students.txt");
            string line;
            while(null != (line = file.ReadLine()))
            {
                var record = line.Split ('|').Select(p => p.Trim()).ToList();
                if( !students.ContainsKey(record[2] )) {
                    students[record[2]] = new SortedSet<Student>();
                }
                students [record [2]].Add(new Student (record[0], record[1], record[2]));
            }

            foreach (var course in students) {
                Console.Write ("{0}: ", course.Key);
                var i = 0;
                foreach (var student in course.Value) {
                    Console.Write (student);
                    if (i < course.Value.Count-1) {
                        Console.Write (", ");
                    }
                    i++;
                }
                Console.WriteLine ();
            }
        }
开发者ID:psha-,项目名称:softuni-datastruct,代码行数:29,代码来源:Program.cs


示例2: CreateNamesDictionary

    /// <summary>
    /// Creates dictionaries that maps from types full names to 
    /// a suitable collection name. The resulting name is usually
    /// simple the name of the type. When there is more than
    /// one type with the same name, FullName is progressively
    /// perpended to name until there is no ambiguity.
    /// Two dictionaries are generated, one with pluralized last name
    /// and one with singular one.
    /// </summary>
    /// <param name="pPersistables">Types to be translated.</param>
    /// <param name="pSchema">Schema to add names dictionaries.</param>
    private static void CreateNamesDictionary(Type[] pPersistables, ref SchemaInfo pSchema)
    {
      Dictionary<string, string> lPlural;
      SortedSet<string> lSingular = new SortedSet<string>();

      // Initially maps FullName to Name.
      lPlural = pPersistables.ToDictionary(lPersistable => lPersistable.ToGenericTypeString(), lPersistable => lPersistable.Name + "s");
      foreach (Type type in pPersistables)
        lSingular.Add(type.ToGenericTypeString());
      // Solve name clashes.
      pPersistables
          .ToLookup(lPersistable => lPersistable.Name)
          .Where(lGroup => lGroup.Count() > 1)
          .Select(lGroup => SolveNameClash(lGroup))
          .ToList()
          .ForEach(delegate(Dictionary<string, string[]> lSub)
          {
            foreach (KeyValuePair<string, string[]> lPair in lSub)
            {
              // Singular names just join names.
             // lSingular[lPair.Key] = String.Join("_", lPair.Value);
              // Last name gets pluralized for plural names.
              lPair.Value[lPair.Value.Count() - 1] = lPair.Value.Last() + "s";
              lPlural[lPair.Key] = String.Join("_", lPair.Value);

            }
          });
      pSchema.SingularNames = lSingular;
      pSchema.TypesNameToPluralName = lPlural;
    }
开发者ID:VelocityDB,项目名称:VelocityDB,代码行数:41,代码来源:SchemaExtractor.cs


示例3: Main

        static void Main(string[] args)
        {
            long[] primes = ESieve(7071);
            long[][] powers = new long[3][];
            int target = 50000000;

            List<long> templist = new List<long>(primes);
            for (int j = 0; j < 3; j++)
            {
                for (int i = 0; i < primes.Length; i++)
                {
                    templist[i] *= primes[i];
                }
                powers[j] = templist.ToArray();
            }

            SortedSet<long> numbers = new SortedSet<long>();
            for (int i = 0; i < primes.Length; i++)
            {
                for (int j = 0; j < primes.Length; j++)
                {
                    for (int k = 0; k < primes.Length; k++)
                    {
                        long number = powers[0][i] + powers[1][j] + powers[2][k];
                        if (number > target) break;
                        numbers.Add(number);
                    }
                }
            }
            Console.Write(numbers.Count);
            Console.WriteLine();
        }
开发者ID:HaochenLiu,项目名称:My-Project-Euler,代码行数:32,代码来源:087.cs


示例4: CountCirc

 public CountCirc(int el)
 {
     quantity = 2;
     primes = new SortedSet<int>(Sift(el));
     primes.Remove(2);
     primes.Remove(5);
 }
开发者ID:AlTTfT,项目名称:CircularPrime,代码行数:7,代码来源:CountCirc.cs


示例5: ReadSourceFiles

        public static ISet<string> ReadSourceFiles(string pdbPath)
        {
            var clsid = new Guid("3BFCEA48-620F-4B6B-81F7-B9AF75454C7D");
            var type = Type.GetTypeFromCLSID(clsid);
            var source = (DiaSource)Activator.CreateInstance(type);
            source.loadDataFromPdb(pdbPath);

            IDiaSession session;
            source.openSession(out session);

            IDiaEnumTables enumTables;
            session.getEnumTables(out enumTables);

            var result = new SortedSet<string>(StringComparer.OrdinalIgnoreCase);

            foreach (IDiaTable diaEnumTable in enumTables)
            {
                var sourceFiles = diaEnumTable as IDiaEnumSourceFiles;
                if (sourceFiles == null)
                    continue;

                foreach (IDiaSourceFile sourceFile in sourceFiles)
                    result.Add(sourceFile.fileName);
            }

            return result;
        }
开发者ID:NN---,项目名称:nuproj,代码行数:27,代码来源:ReadPdbSourceFiles.cs


示例6: Supermarket

 public Supermarket()
 {
     this.productsByType = new Dictionary<string, SortedSet<Product>>();
     this.productNames = new HashSet<string>();
     this.productsByPrice = new SortedDictionary<double, SortedSet<Product>>();
     this.allPrices = new SortedSet<double>();
 }
开发者ID:kaizer04,项目名称:Telerik-Academy-2015-2016,代码行数:7,代码来源:Supermarket.cs


示例7: SortedSetTests

        static SortedSetTests()
        {
            QUnit.module("SortedSet tests");

            QUnit.test("new SortedSet fails with null compare", delegate
            {
                QUnit.raises(delegate { new SortedSet(null, new Array(), true); }, "should throw an exception");
            });

            QUnit.test("new SortedSet succeeds with null array (sorted)", delegate
            {
                SortedSet s = new SortedSet(CompareNumber, new Array(), true);
                QUnit.equals(s.Count, 0, "count should be zero");
            });

            QUnit.test("new SortedSet succeeds with null array (unsorted)", delegate
            {
                SortedSet s = new SortedSet(CompareNumber, new Array(), true);
                QUnit.equals(s.Count, 0, "count should be zero");
            });

            QUnit.test("new SortedSet succeeds (empty, sorted)", delegate
            {
                SortedSet s = new SortedSet(CompareNumber, new Array(), true);
                QUnit.equals(s.Count, 0, "count should be zero");
            });

            QUnit.test("new SortedSet succeeds (empty, not sorted)", delegate
            {
                SortedSet s = new SortedSet(CompareNumber, new Array(), false);
                QUnit.equals(s.Count, 0, "count should be zero");
            });

            QUnit.test("new SortedSet succeeds (non empty, sorted)", delegate
            {
                SortedSet s = new SortedSet(CompareNumber, TestSortedArray, true);
                QUnit.equals(s.Count, TestSortedArray.Length, "count should be zero");
            });

            QUnit.test("new SortedSet succeeds (not empty, unsorted)", delegate
            {
                SortedSet s = new SortedSet(CompareNumber, TestUnsortedArray, false);
                QUnit.equals(s.Count, TestUnsortedArray.Length, "count should be zero");
            });

            QUnit.test("SortedSet.GetItems succeeds", delegate
            {
                SortedSet s = new SortedSet(CompareNumber, TestUnsortedArray, false);
                QUnit.equals(s.IndexOf(0), 0, "should find 0");
                QUnit.equals(s.IndexOf(1), 1, "should find 1");
                QUnit.equals(s.IndexOf(2), 2, "should find 2");
                QUnit.equals(s.IndexOf(3), 3, "should find 3");
                QUnit.equals(s.IndexOf(4), 4, "should find 4");
                QUnit.equals(s.IndexOf(5), 5, "should find 5");
                QUnit.equals(s.IndexOf(6), -1, "should not find 6");
            });
        }
开发者ID:Aethon,项目名称:odo,代码行数:57,代码来源:SortedSetTests.cs


示例8: FindDuplicateFiles

        public ScanResult FindDuplicateFiles(String dirPath)
        {
            worker.ReportProgress(0, "Preparing files ...");
            FileInfo[] files = new DirectoryInfo(dirPath).GetFiles("*", SearchOption.AllDirectories);
            Array.Sort(files, Comparer<FileInfo>.Create((a,b) => b.FullName.CompareTo(a.FullName)));
            
            int total = files.Length;
            double progress = 0;
            IDictionary<long, IDictionary<FileInfo, IList<FileInfo>>> byteTable = new Dictionary<long, IDictionary<FileInfo, IList<FileInfo>>>();
            foreach (FileInfo file in files) {
                worker.ReportProgress((int)(++progress/total*100), String.Format("Scanning files... ({0}/{1})", progress, total));

                // Compare size
                long fileSize = file.Length;
                if (!byteTable.ContainsKey(fileSize))
                    byteTable.Add(fileSize, new Dictionary<FileInfo, IList<FileInfo>>());
                
                // Compare contents of the files with the same size
                IDictionary<FileInfo, IList<FileInfo>> fileTable = byteTable[fileSize]; // All files in fileMap have the same size
                bool foundDuplicate = false;
                // Compare the current file to each file in fileTable
                foreach (KeyValuePair<FileInfo, IList<FileInfo>> pair in fileTable) {
                    // If find a duplicate, add the file to the duplicate-files-list and break the iteration
                    if (FilesAreEqual(pair.Key, file)) {
                        foundDuplicate = true;
                        pair.Value.Add(file);
                        break;
                    }
                }
                // No duplicate found, create a new entry in fileTable
                if (!foundDuplicate)
                    fileTable.Add(file, new List<FileInfo>());
            }

            // Build the result
            worker.ReportProgress(100, "Build the result ...");
            ScanResult result = new ScanResult();
            int sum = 0;
            foreach (IDictionary<FileInfo, IList<FileInfo>> fileTable in byteTable.Values) {
                foreach (KeyValuePair<FileInfo, IList<FileInfo>> pair in fileTable) {
                    if (pair.Value.Count > 0) {
                        ISet<FileInfo> list = new SortedSet<FileInfo>(Comparer<FileInfo>.Create((a, b) => b.FullName.CompareTo(a.FullName)));
                        list.Add(pair.Key);
                        result.RemoveList.Add(pair.Key, false);
                        foreach (FileInfo file in pair.Value) { 
                            list.Add(file);
                            result.RemoveList.Add(file, true);
                        }
                        result.FileList.Add(pair.Key, list);
                        sum += pair.Value.Count;
                    }
                }
            }
            result.NumDuplicates = sum;
            return result;
        }
开发者ID:smilecatx3,项目名称:DudDuRu,代码行数:56,代码来源:DuplicateFinder.cs


示例9: Main

 static void Main(string[] args)
 {
     var stackOfValues = new Stack<string>();
     GetInitialValuesFromArgs(args, ref stackOfValues);
     var demoSet1 = new Set<string>(stackOfValues.ToArray());
     Console.WriteLine(demoSet1.ToString());
     var demoSet3 = new SortedSet(stackOfValues.ToArray());
     Console.WriteLine(demoSet3.ToString());
     Console.ReadKey();
 }
开发者ID:RavingRabbit,项目名称:Labs,代码行数:10,代码来源:Program.cs


示例10: Add

		public void Add ()
		{
			var set = new SortedSet<int> ();
			Assert.AreEqual (0, set.Count);
			Assert.IsTrue (set.Add (2));
			Assert.IsTrue (set.Add (4));
			Assert.IsTrue (set.Add (3));
			Assert.AreEqual (3, set.Count);
			Assert.IsFalse (set.Add (2));
		}
开发者ID:mesheets,项目名称:Theraot-CF,代码行数:10,代码来源:SortedSetTest.cs


示例11: DataSet

 /***************************** Constructor *********************************/
 public DataSet()
 {
     egoLikedTweets = new HashSet<long>();
     egoLikedTweetsInTimeline = new HashSet<long>();
     egoUnLikedTweetsInTimeline = new HashSet<long>();
     timeline = new SortedSet<long>(new TweetIDComparer());
     egoLikedTweets.Clear();
     egoLikedTweetsInTimeline.Clear();
     egoUnLikedTweetsInTimeline.Clear();
     timeline.Clear();
 }
开发者ID:MPPECS,项目名称:Twitter_RWR_Recommender,代码行数:12,代码来源:DataSet.cs


示例12: Simulation

        private ConcurrentQueue<Cell[]> updated; // Cells updated since last checked by client

        #endregion Fields

        #region Constructors

        /// <summary>
        /// Initialize a new simulation with a blank grid (with all cells in the default state) of the default size.
        /// </summary>
        public Simulation()
        {
            toCheck = new SortedSet<CPoint>(new PointComparer());
            toUpdate = new ConcurrentQueue<Cell>();
            updated = new ConcurrentQueue<Cell[]>();
            grid = new uint[1][];
            ca = new CA();
            initGridBlank(defaultX, defaultY);
            refresh = defaultRefresh;
            throttled = false;
        }
开发者ID:JWCook,项目名称:Client-Server_CA_Sim,代码行数:20,代码来源:Simulation.cs


示例13: DataSctructure

        public DataSctructure()
        {
            this.dictionary = new Dictionary<int, string>();
            this.hashSet = new HashSet<int>();
            this.sortedList = new SortedList<int, string>();
            this.sortedSet = new SortedSet<int>();
            this.list = new List<int>();
            this.linkedList = new LinkedList<int>();
            this.pair = new KeyValuePair<int, string>();

            fillTheStructures();
        }
开发者ID:ElementsTraining,项目名称:CSharpTraining,代码行数:12,代码来源:DataSctructure.cs


示例14: Remove

		public void Remove ()
		{
			var set = new SortedSet<int> ();
			Assert.IsTrue (set.Add (2));
			Assert.IsTrue (set.Add (4));
			Assert.AreEqual (2, set.Count);
			Assert.IsTrue (set.Remove (4));
			Assert.IsTrue (set.Remove (2));
			Assert.AreEqual (0, set.Count);
			Assert.IsFalse (set.Remove (4));
			Assert.IsFalse (set.Remove (2));
		}
开发者ID:mesheets,项目名称:Theraot-CF,代码行数:12,代码来源:SortedSetTest.cs


示例15: InitData

        public void InitData()
        {
            int[] temp = new int[length];

            for (int i = 0; i < length; i++)
            {
                int n = i + 1;
                int triangleNumberForN =  n * (n + 1) / 2;
                temp[i] = triangleNumberForN;
            }
            triangleNumbers = new SortedSet<int>(temp);
        }
开发者ID:stannedelchev,项目名称:ProjectEulerSolutions,代码行数:12,代码来源:Problem42.cs


示例16: FindPrimesBySieveOfAtkins

        static SortedSet<int> FindPrimesBySieveOfAtkins(int max)
        {
            //  var isPrime = new BitArray((int)max+1, false);
            //  Can't use BitArray because of threading issues.
            var isPrime = new bool[max + 1];
            var sqrt = (int)Math.Sqrt(max);

            Parallel.For(1, sqrt, x =>
            {
                var xx = x * x;
                for (int y = 1; y <= sqrt; y++)
                {
                    var yy = y * y;
                    var n = 4 * xx + yy;
                    if (n <= max && (n % 12 == 1 || n % 12 == 5))
                        isPrime[n] ^= true;

                    n = 3 * xx + yy;
                    if (n <= max && n % 12 == 7)
                        isPrime[n] ^= true;

                    n = 3 * xx - yy;
                    if (x > y && n <= max && n % 12 == 11)
                        isPrime[n] ^= true;
                }
            });

            var primes = new SortedSet<int>() { 2, 3 };
            for (int n = 5; n <= sqrt; n++)
            {
                if (isPrime[n])
                {
                    primes.Add(n);
                    int nn = n * n;
                    for (int k = nn; k <= max; k += nn)
                        isPrime[k] = false;
                }
            }
            try
            {

                for (int n = sqrt + 1; n <= max; n++)
                    if (isPrime[n])
                        primes.Add(n);
            }
            catch (OutOfMemoryException e)
            {

            }

            return primes;
        }
开发者ID:patrickdean,项目名称:euler,代码行数:52,代码来源:Program.cs


示例17: Module

        public Module(string name)
        {
            Name     = Helpers.RequireName(name);
            Provides = new SortedSet<string>();
            Requires = new SortedSet<string>();
            Script   = new StringBuilder();
            WorkerId = Worker.Any;

            Provides.Add(name);

            if (name != InitModuleName)
                Requires.Add(InitModuleName);
        }
开发者ID:sharpjs,项目名称:PSql,代码行数:13,代码来源:PSql.ModuleRunner.cs


示例18: GenerarReporte

        private void GenerarReporte(List<Cita> list_citas, DateTime desde, DateTime hasta)
        {
            int i = 0; int j = 1; int iguales = 0;
            this.chtGrafico.Titles.Clear();
            this.chtGrafico.Legends.Clear();
            this.chtGrafico.Series.Clear();
            this.chtGrafico.Titles.Add(" Reportes Pacientes Atendidos - Generado el día: " + DateTime.Now + " " + System.Environment.NewLine + " " + System.Environment.NewLine + "Desde el día " + desde + " hasta el día " + hasta);
            ArrayList list_iguales = new ArrayList();
            foreach (Cita cita in list_citas)
            {
                this.list_fechas.Add(cita.Fecha);
            }
            SortedSet<DateTime> set = new SortedSet<DateTime>(list_fechas);

            foreach (DateTime val in set)
            {
                iguales = 0;
                foreach (Cita cita in list_citas)
                {
                    if (cita.Fecha == val)
                    {
                        ++iguales;
                    }
                }
                list_iguales.Add(iguales);
            }
            
            int x = list_fechas.Count;
            int y = set.Count;
            foreach (DateTime val in set)
            {
                Series serie = new Series();
                Legend legend = new Legend();
                serie.Legend = val.ToString();
                legend.Name = "Hora-" + val;
                legend.Title = "Horas de Atención";
                this.chtGrafico.Legends.Add(legend);
                this.chtGrafico.Series.Add(val.ToString());
                this.chtGrafico.Series[i].Points.AddXY(j,list_iguales[i]);
                this.chtGrafico.Series[i].ChartType = SeriesChartType.Bar;
                this.chtGrafico.Series[i]["PointWidth"] = "0.6";
                this.chtGrafico.Series[i].IsValueShownAsLabel = true;
                this.chtGrafico.Series[i]["BarLabelStyle"] = "Center";
                this.chtGrafico.Series[i]["DrawingStyle"] = "Emboss";
                ++i;++j;
            }
            chtGrafico.Update();
            chtGrafico.UpdateAnnotations();
            MessageBox.Show("Registro total de pacientes atendidos: " + list_citas.Count + "." + " " + System.Environment.NewLine + " " + System.Environment.NewLine + "Desde el día " + desde + " hasta el día " + hasta, "SFH Administración de Reportes y Estadísticas - Reportes de Pacientes", MessageBoxButtons.OK, MessageBoxIcon.Information);
        }
开发者ID:jacevedo,项目名称:proyectoTitulo,代码行数:50,代码来源:frmGenerarReportesPacientes.cs


示例19: GenerarReporte

        private void GenerarReporte(List<Cita> list_citas)
        {
           
            this.chtGrafico.Titles.Add(" Reportes Pacientes  " + DateTime.Now);
            //this.chtGrafico.ChartAreas[0].Area3DStyle.Enable3D = true;
            int i = 0;
            int j = 1;
            foreach (Cita cita in list_citas){

                this.list_fechas.Add(cita.Fecha.ToString());
            }

            int[] pointsArray = { Convert.ToInt32(1), Convert.ToInt32(3), Convert.ToInt32(1) };
            
            SortedSet<string> set = new SortedSet<string>(list_fechas);
            int x = list_fechas.Count;
            int y = set.Count;
           // this.chtGrafico.Series[0].Points.AddXY(x, y);

           
            foreach (string val in set)
            {
                Series serie = new Series();
                Legend legend = new Legend();
                serie.Legend = val;
                legend.Name = "Hora-" + val;
                legend.Title = "Horas de atencion";
                this.chtGrafico.Legends.Add(legend);
                serie = this.chtGrafico.Series.Add(val);
                //serie.Points.Add(pointsArray[i]);
                serie.Points.AddXY(j,pointsArray[i]);
                
                
                //this.chtGrafico.Series.Add(serie);
               
                
                
                //this.chtGrafico.Series[i].Points.AddXY(x, y);
                /*
                Series series = this.chtGrafico.Series.Add(val);
                series.Points.Add(pointsArray[i]);
                ++i;*/
              // this.chtGrafico.Series[i].ChartType = System.Windows.Forms.DataVisualization.Charting.SeriesChartType.Range;
                ++i; ++j;
                chtGrafico.Update();
            }
         
           
        }
开发者ID:jacevedo,项目名称:proyectoTitulo,代码行数:49,代码来源:frmGenerarReportesPacientes.cs


示例20: should_be_simplified_using_for_each

        public void should_be_simplified_using_for_each()
        {
            var collection = new SortedSet<int> { 10, 2, 3, 5 };
            var copyOfCollection = new List<int>();

            foreach (int valueInCollection in collection)
            {
                copyOfCollection.Add(valueInCollection);
            }

            // change the variable value to fix the test.
            var expectedCopyResult = new List<int> { 10, 2, 3, 5 };

            Assert.Equal(expectedCopyResult, copyOfCollection);
        }
开发者ID:chenbojian,项目名称:01_NewbieVillage,代码行数:15,代码来源:19_Enumeration.cs



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


鲜花

握手

雷人

路过

鸡蛋
该文章已有0人参与评论

请发表评论

全部评论

专题导读
上一篇:
C# Collections.Stack类代码示例发布时间:2022-05-26
下一篇:
C# Collections.SortedList类代码示例发布时间:2022-05-26
热门推荐
阅读排行榜

扫描微信二维码

查看手机版网站

随时了解更新最新资讯

139-2527-9053

在线客服(服务时间 9:00~18:00)

在线QQ客服
地址:深圳市南山区西丽大学城创智工业园
电邮:jeky_zhao#qq.com
移动电话:139-2527-9053

Powered by 互联科技 X3.4© 2001-2213 极客世界.|Sitemap