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


C# SortedDictionary.Add方法代码示例

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


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

示例1: GetDefaultConfigs

        /// <summary>
        /// Generate default configurations for the filter.
        /// </summary>
        /// <returns>Dictionary used to pass configuration though the 
        /// configs parameter of the method ApplyFilter. 
        /// null if there is the filter doesn't use configurations.</returns>
        public override SortedDictionary<string, object> GetDefaultConfigs()
        {
            SortedDictionary<string, object> ret = new SortedDictionary<string, object>();

            // Add configs from Gaussian
            SortedDictionary<string, object> tmp_conf = g.GetDefaultConfigs();
            if (null != tmp_conf)
            {
                foreach (KeyValuePair<string, object> item in tmp_conf)
                {
                    ret.Add(item.Key, item.Value);
                }
            }

            // Add configs from Laplacian of Gauss
            tmp_conf = logauss.GetDefaultConfigs();
            if (null != tmp_conf)
            {
                foreach (KeyValuePair<string, object> item in tmp_conf)
                {
                    if (!ret.ContainsKey(item.Key))
                    {
                        ret.Add(item.Key, item.Value);
                    }
                }
            }

            return ret;
        }
开发者ID:fabriceleal,项目名称:ImageProcessing,代码行数:35,代码来源:MarrHildreth.cs

示例2: Solve

        public long Solve()
        {
            var primes = new Prime((int)DivisoNumbers);

            var sortedPrimes = new SortedDictionary<long, PrimeDivisors>();
            foreach (var prime in primes.PrimeList)
            {
                sortedPrimes.Add(prime, new PrimeDivisors(prime));
            }

            while (true)
            {
                var minkey = sortedPrimes.Keys.First();
                var maxKey = sortedPrimes.Keys.Last();

                var minValue = sortedPrimes[minkey];

                var newKey = minkey * minkey;
                if (newKey > maxKey)
                {
                    break;
                }
                sortedPrimes.Add(newKey, minValue.UpdatePower());

                sortedPrimes.Remove(minkey);
                sortedPrimes.Remove(maxKey);
            }

            return sortedPrimes.Select(
                primeDivisorse => (long)Math.Pow(primeDivisorse.Value.Prime, primeDivisorse.Value.Power) % Modulo
            ).Aggregate(
                1L, (current, coefficient) => (current * coefficient) % Modulo
            );
        }
开发者ID:joeazbest,项目名称:Euler,代码行数:34,代码来源:Problem500.cs

示例3: FindTypes

        /// <summary>
        /// Finds the all the types that implement or inherit from the baseType.  
        /// </summary>
        /// <param name="baseType">base type.</param>
        /// <param name="includeBaseType">if set to <c>true</c> the base type will be included in the result</param>
        /// <returns></returns>
        public static SortedDictionary<string, Type> FindTypes( Type baseType, bool includeBaseType )
        {
            SortedDictionary<string, Type> types = new SortedDictionary<string, Type>();

            if ( includeBaseType )
                types.Add( ClassName( baseType ), baseType );

            Assembly executingAssembly = Assembly.GetExecutingAssembly();
            FileInfo executingFile = new FileInfo( executingAssembly.Location );

            Dictionary<string, Assembly> assemblies = new Dictionary<string, Assembly>();
            assemblies.Add( executingAssembly.Location.ToLower(), executingAssembly );

            foreach ( Assembly assembly in AppDomain.CurrentDomain.GetAssemblies() )
                if ( assembly.FullName.StartsWith( "Rock" ) && !assemblies.Keys.Contains( assembly.Location  ) )
                    assemblies.Add( assembly.FullName.ToLower(), assembly );

            foreach ( FileInfo fileInfo in executingFile.Directory.GetFiles( "rock.*.dll" ) )
                if ( !assemblies.Keys.Contains( fileInfo.FullName.ToLower() ) )
                {
                    Assembly fileAssembly = Assembly.LoadFrom( fileInfo.FullName );
                    assemblies.Add( fileInfo.FullName.ToLower(), fileAssembly );
                }

            foreach ( KeyValuePair<string, Assembly> assemblyEntry in assemblies )
                foreach ( KeyValuePair<string, Type> typeEntry in SearchAssembly( assemblyEntry.Value, baseType ) )
                    if (!types.Keys.Contains(typeEntry.Key))
                        types.Add( typeEntry.Key, typeEntry.Value );

            return types;
        }
开发者ID:rowlek,项目名称:Rock-ChMS,代码行数:37,代码来源:Reflection.cs

示例4: TestNumbersOrWords

 public void TestNumbersOrWords()
 {
     IDictionary<Int64, String> euroCities = new SortedDictionary<Int64, String>();
     euroCities.Add(2, "Oslo");
     euroCities.Add(4, "Helsinki");
     euroCities.Add(8, "Lisbon");
     euroCities.Add(16, "Dubrovnik");
     FizzBuzz fizzbuzz = new FizzBuzz(300, euroCities);
     IEnumerable<String> results = from fb in fizzbuzz select fb;
     long index = 1;
     foreach (String r in results)
     {
         try
         {
             // odds should be a number
             Int64 i64 = Convert.ToInt64(r);
             Assert.AreNotEqual(0, index % 2);
         }
         catch (FormatException)
         {
             // evens will be a city and throw an exception based on number conversion
             Assert.AreEqual(0, index % 2);
         }
         finally
         {
             index++;
         }
     }
 }
开发者ID:jamescaldwell,项目名称:fizzandbuzz,代码行数:29,代码来源:FizzBuzzUnitTest.cs

示例5: MainGame

        public MainGame(Game1 theGame)
            : base("background", 1.0f)
        {
            LABELWIDTH = SEC1WIDTH / 2 - MARGIN;
            CARDWIDTH = (Game1.WIDTH - 8 * (MARGIN * 2) - 30) / MAXHANDSIZE;
            CARDHEIGHT = (int) (CARDWIDTH * 1.612);
            LABELLENGTH = (SEC1WIDTH - MARGIN) / 5;
            RESOURCELENGTH = (SEC1WIDTH - 3 * MARGIN) * 4 / 5;
            player = null;
            wonder = null;
            lastPlayed = new Dictionary<string, Visual>();
            hand = new SortedDictionary<string, Visual>();
            leftButton = new Button(new Vector2(Game1.WIDTH - 27, 200 + CARDHEIGHT / 2 - 7), 15, 15, "", "Font1", "left");
            leftButton.z = 1;
            hand.Add("paperleft", new Visual(new Vector2(Game1.WIDTH - 27, 190), 30, CARDHEIGHT + 30, "paperleft"));
            hand.Add("leftButton", leftButton.setBorder(false));

            close = new Button(new Vector2(Game1.WIDTH - Game1.WIDTH / 9, Game1.HEIGHT * 5/ 8), 75, 40, "Close", "Font1");

            lastPlayed.Add("bg", new Visual(new Vector2(Game1.WIDTH / 3, Game1.HEIGHT / 6), Game1.WIDTH * 2 / 3, Game1.HEIGHT * 2 / 3, "bg"));
            lastPlayed.Add("close", close);

            seatVisuals = new Dictionary<int, Dictionary<string, Visual>>();
            baseVisuals = new Dictionary<String, Visual>();
            baseVisuals.Add("Label1", new Visual(new Vector2(MARGIN, MARGIN), LABELWIDTH, LABELHEIGHT, "Players", "Font1", null, Color.Gray, "grayback"));
            baseVisuals.Add("Label2", new Visual(new Vector2(MARGIN + LABELWIDTH, MARGIN), LABELWIDTH, LABELHEIGHT, "icons"));
            baseVisuals.Add("Divider1", new Visual(new Vector2(SEC1WIDTH - 1, 0), DIVIDERWIDTH, Game1.HEIGHT, "line", Color.Silver));
            baseVisuals.Add("Divider2", new Visual(new Vector2(0, SEC1HEIGHT - 1), Game1.WIDTH, DIVIDERWIDTH, "line", Color.Silver));
            baseVisuals.Add("Age", new Visual(new Vector2(Game1.WIDTH - MARGIN - 75, MARGIN), 75, 75, "age1"));
            baseVisuals.Add("discard", new Visual(new Vector2(Game1.WIDTH - MARGIN - 60, MARGIN * 3 + 120), 60, 60, "0", "Font1", null, Color.White, "deck"));
            baseVisuals["discard"].setLeftMargin(15);
            baseVisuals["discard"].setTopMargin(9);
        }
开发者ID:Will2817,项目名称:COMP3004,代码行数:33,代码来源:MainGame.cs

示例6: availableCharsets

		/// <summary>
		/// Returns an immutable case-insensitive map from canonical names to
		/// <code>Charset</code>
		/// instances.
		/// If multiple charsets have the same canonical name, it is unspecified which is returned in
		/// the map. This method may be slow. If you know which charset you're looking for, use
		/// <see cref="forName(string)">forName(string)</see>
		/// .
		/// </summary>
		/// <returns>
		/// an immutable case-insensitive map from canonical names to
		/// <code>Charset</code>
		/// instances
		/// </returns>
		public static SortedDictionary<string, Charset> availableCharsets ()
		{
			SortedDictionary<string, Charset> charsets = new SortedDictionary<string, Charset> ();
			charsets.Add (utf8.Name, utf8);
			charsets.Add (ascii.Name, ascii);
			return charsets;
		}
开发者ID:hakeemsm,项目名称:XobotOS,代码行数:21,代码来源:Charset.cs

示例7: Main

        private static void Main()
        {
            string readLine = Console.ReadLine();
            SortedDictionary<char, int> countsOfChars = new SortedDictionary<char, int>();
            int count = 1;

            for (int i = 0; i < readLine.Length; i++)
            {
                if (countsOfChars.ContainsKey(readLine[i]))
                {
                    int value = countsOfChars[readLine[i]];
                    countsOfChars.Remove(readLine[i]);
                    countsOfChars.Add(readLine[i], count + value);
                }
                else
                {
                    countsOfChars.Add(readLine[i], count);
                }
            }

            foreach (KeyValuePair<char, int> p in countsOfChars)
            {
                Console.WriteLine("{0}: {1} time/s", p.Key, p.Value);
            }
        }
开发者ID:Ilo-ILD,项目名称:AdvancedCSharp,代码行数:25,代码来源:Problem6CountSymbols.cs

示例8: TitleFillUp

        private static void TitleFillUp()
        {
            System.IO.StreamReader files = new System.IO.StreamReader(@"../../CodeResources/Files.txt");
            System.IO.StreamReader dependences = new System.IO.StreamReader(@"../../CodeResources/Dependences.txt");

            SortedDictionary<string, Node> independedFolders = new SortedDictionary<string, Node>();
            independedFolders.Add("TASKS_EXPLORER\n", new Node("TASKS_EXPLORER\n"));

            while (!files.EndOfStream) {
                string file = files.ReadLine();
                independedFolders.Add(file, new Node(file));
            }

            while (!dependences.EndOfStream) {
                string inp = dependences.ReadLine();
                inp = Regex.Replace(inp, @"\s+", " ");
                inp = Regex.Replace(inp, @"\\n+", "\n");
                string[] edge = inp.Split(' ');
                independedFolders[edge[0]].children.Add(independedFolders[edge[1]]);
                independedFolders[edge[0]].children[independedFolders[edge[0]].children.Count - 1].number = independedFolders[edge[0]].children.Count - 1;
                independedFolders[edge[0]].children[independedFolders[edge[0]].children.Count - 1].parent = independedFolders[edge[0]];
            }

            folders = independedFolders["TASKS_EXPLORER\n"];

            files.Close();
            dependences.Close();
        }
开发者ID:Praytic,项目名称:csharp-basics,代码行数:28,代码来源:ConsoleInterface.cs

示例9: GetLast10Licenses

		public List<License> GetLast10Licenses()
		{
			var newLics = (from l in _licensesRepository.GetAllLicenses()
										 where l.UpdatedOn == null
										 orderby l.CreatedOn descending
										 select l).ToList();


			var updatedLics = (from l in _licensesRepository.GetAllLicenses()
												 where l.UpdatedOn != null
												 orderby l.UpdatedOn descending
												 select l).ToList();

			SortedDictionary<DateTime, License> sortedLics = new SortedDictionary<DateTime, License>();

			foreach (var lic in newLics)
			{
				sortedLics.Add(lic.CreatedOn, lic);
			}

			foreach (var lic in updatedLics)
			{
				sortedLics.Add(lic.UpdatedOn.Value, lic);
			}

			return sortedLics.Take(8).Select(x => x.Value).ToList();
		}
开发者ID:chantsunman,项目名称:Scutex,代码行数:27,代码来源:LicenseService.cs

示例10: chooseBttn_Click

 private void chooseBttn_Click(object sender, EventArgs e)
 {
     fileDialog.ShowDialog();
     fileBox.Text = fileDialog.FileName;
     string content = "";
     content = Program.ExtractTextFromPdf(fileDialog.FileName);
     var numtype = new Regex(@"\(\d{4,6}\/2015\)\s+([\d]). mell", RegexOptions.Multiline);
     var eur = new Regex(@"\(\d{4,6}\/2015\)\s+EUR", RegexOptions.Multiline);
     var dict = new SortedDictionary<string, int>();
     dict.Add("total", 0);
     foreach (Match item in numtype.Matches(content))
     {
         string key = item.Groups[1].Value;
         if (!dict.ContainsKey(key)) dict.Add(key, 0);
         dict[key]++;
         dict["total"]++;
     }
     dict.Add("eur", 0);
     foreach (Match item in eur.Matches(content))
     {
         dict["eur"]++;
         dict["total"]++;
     }
     int total = 0;
     foreach (KeyValuePair<string, int> item in dict)
     {
         dataView.Rows.Add(new string[] { item.Key, item.Value.ToString() });
     }
 }
开发者ID:SevenofNine24,项目名称:counter,代码行数:29,代码来源:Form1.cs

示例11: AbstractClassifier

        protected AbstractClassifier(/*IDictionary<string,object> prms=null*/)
        {
            Prms = new SortedDictionary<string, object>();
            //foreach (var p in prms.Keys)
            //    Prms.Add(p, prms[p]);

            string trp = ConfigReader.Read("TrainPath");
            if (trp != null) TrainPath = trp;
            Prms.Add("TrainPath", TrainPath);

            string tsp = ConfigReader.Read("TestPath");
            if (tsp != null) TestPath = tsp;
            Prms.Add("TestPath", TestPath);

            string tn = ConfigReader.Read("TargetName");
            if (tn != null) TargetName = tn;
            Prms.Add("TargetName", TargetName);

            string inm = ConfigReader.Read("IdName");
            if (inm != null) IdName = inm;
            Prms.Add("IdName", IdName);

            string isp = ConfigReader.Read("IsParallel");
            if (isp != null) IsParallel = bool.Parse(isp);
            Prms.Add("IsParallel", IsParallel);
        }
开发者ID:orlovk,项目名称:PtProject,代码行数:26,代码来源:AbstractClassifier.cs

示例12: KwayMerge

        private static void KwayMerge(IEnumerable<string> chunkFilePaths, string resultFilePath)
        {
            var chunkReaders = chunkFilePaths
                .Select(path => new StreamReader(path))
                .Where(chunkReader => !chunkReader.EndOfStream)
                .ToList();

            var sortedDict = new SortedDictionary<string, TextReader>();
            chunkReaders.ForEach(chunkReader => sortedDict.Add(chunkReader.ReadLine(), chunkReader));

            using (var resultWriter = new StreamWriter(resultFilePath, false))
                while (sortedDict.Any())
                {
                    var line = sortedDict.Keys.First();
                    var chunkReader = sortedDict[line];
                    sortedDict.Remove(line);

                    resultWriter.WriteLine(line);

                    var nextLine = chunkReader.ReadLine();
                    if (nextLine != null)
                    {
                        sortedDict.Add(nextLine, chunkReader);
                    }
                    else
                    {
                        chunkReader.Dispose();
                    }
                }
        }
开发者ID:anton-chernov,项目名称:SPPFirsLab,代码行数:30,代码来源:FileSort.cs

示例13: Build

        //Build double array trie-tree from text file
        //strTextFileName: raw text file name used to build DA trie-tree
        //  text file format: key \t value
        //  key as string type
        //  value as non-netgive integer
        //strDAFileName: double array trie-tree binary file name built from strTextFileName
        private static void Build(string strTextFileName, string strDAFileName)
        {
            StreamReader sr = new StreamReader(strTextFileName);
            //Load raw data from text file and sort them as ordinal
            SortedDictionary<string, int> sdict = new SortedDictionary<string, int>(StringComparer.Ordinal);
            Console.WriteLine("Loading key value pairs from raw text file and sort them...");
            while (sr.EndOfStream == false)
            {
                string strLine = sr.ReadLine();
                if (strLine.Length == 0)
                {
                    continue;
                }

                string[] items = strLine.Split('\t');
                sdict.Add(items[0], int.Parse(items[1]));
            }

            //test case for SearchAsKeyPrefix and SearchByPrefix
            sdict.Add("TestSearchPrefix_case0", 1234567);
            sdict.Add("TestSearchPrefix_case01", 2345678);
            sdict.Add("TestSearchPrefix_case012", 3456789);

            DoubleArrayTrieBuilder dab = new DoubleArrayTrieBuilder(4);
            Console.WriteLine("Begin to build double array trie-tree...");
            dab.build(sdict);
            dab.save(strDAFileName);
            Console.WriteLine("Done!");
        }
开发者ID:zhongkaifu,项目名称:AdvUtils,代码行数:35,代码来源:Program.cs

示例14: GetRequestParameters

        public SortedDictionary<string, string> GetRequestParameters()
        {
            int i = 0;
            SortedDictionary<string, string> sArray = new SortedDictionary<string, string>();
            try
            {
                NameValueCollection coll;
                //Load Form variables into NameValueCollection variable.
                coll = request.QueryString;

                // Get names of all forms into a string array.
                String[] requestItem = coll.AllKeys;

                for (i = 0; i < requestItem.Length; i++)
                {
                    sArray.Add(requestItem[i], request[requestItem[i]]);
                }

                string[] formKeys = request.Form.AllKeys;
                if (formKeys != null)
                {
                    for (int j = 0; j < formKeys.Length; j++)
                    {
                        sArray.Add(formKeys[j], request[formKeys[j]]);
                    }
                }
            }
            catch(Exception ex)
            {
                logger.Error(ex);
            }

            return sArray;
        }
开发者ID:Bobom,项目名称:kuanmai,代码行数:34,代码来源:BaseApiController.cs

示例15: FollowAccount

        public static bool FollowAccount(string AccessToken,string AccessTokenSecret ,string Screen_name, string user_id) 
        {
            bool IsFollowed = false;
            oAuthTwitter oauth = new oAuthTwitter();

            oauth.AccessToken = AccessToken;
            oauth.AccessTokenSecret = AccessTokenSecret;
            oauth.ConsumerKey = ConfigurationManager.AppSettings["consumerKey"];
            oauth.ConsumerKeySecret = ConfigurationManager.AppSettings["consumerSecret"];
            string RequestUrl = "https://api.twitter.com/1.1/friendships/create.json";
            SortedDictionary<string, string> strdic = new SortedDictionary<string, string>();
            if (!string.IsNullOrEmpty(Screen_name)) 
            {
                strdic.Add("screen_name", Screen_name);
            }
            else if (!string.IsNullOrEmpty(user_id))
            {
                strdic.Add("user_id", user_id);
            }
            else 
            {
                return false;
            }
            strdic.Add("follow", "true");
            string response = oauth.oAuthWebRequest(oAuthTwitter.Method.POST, RequestUrl, strdic);
            if (!string.IsNullOrEmpty(response)) 
            {
                IsFollowed = true;
            }
            return IsFollowed;
        }
开发者ID:prog-moh,项目名称:socioboard-core,代码行数:31,代码来源:TwitterHelper.cs


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