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

C# SortedDictionary类代码示例

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

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



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

示例1: GetArtists

        private static SortedDictionary<string, int> GetArtists(XmlNode rootNode)
        {
            var artists = new SortedDictionary<string, int>();

            if (rootNode == null)
            {
                throw new ArgumentNullException("rootNode" + "is empty");
            }

            foreach (var artistName in from XmlNode node in rootNode.ChildNodes
                                       select node["artist"] into xmlElement
                                       where xmlElement != null
                                       select xmlElement.InnerText)
            {
                if (artists.ContainsKey(artistName))
                {
                    artists[artistName]++;
                }
                else
                {
                    artists.Add(artistName, 1);
                }
            }

            return artists;
        }
开发者ID:deyantodorov,项目名称:TelerikAcademy,代码行数:26,代码来源:ExtractArtistAndAlbums.cs


示例2: SqlCallProcedureInfo

 public SqlCallProcedureInfo(MethodInfo method, ISerializationTypeInfoProvider typeInfoProvider)
 {
     if (method == null) {
         throw new ArgumentNullException("method");
     }
     if (typeInfoProvider == null) {
         throw new ArgumentNullException("typeInfoProvider");
     }
     SqlProcAttribute procedure = GetSqlProcAttribute(method);
     schemaName = procedure.SchemaName;
     name = procedure.Name;
     timeout = procedure.Timeout;
     deserializeReturnNullOnEmptyReader = procedure.DeserializeReturnNullOnEmptyReader;
     deserializeRowLimit = procedure.DeserializeRowLimit;
     deserializeCallConstructor = procedure.DeserializeCallConstructor;
     SortedDictionary<int, SqlCallParameterInfo> sortedParams = new SortedDictionary<int, SqlCallParameterInfo>();
     outArgCount = 0;
     foreach (ParameterInfo parameterInfo in method.GetParameters()) {
         if ((parameterInfo.GetCustomAttributes(typeof(SqlNameTableAttribute), true).Length > 0) || (typeof(XmlNameTable).IsAssignableFrom(parameterInfo.ParameterType))) {
             if (xmlNameTableParameter == null) {
                 xmlNameTableParameter = parameterInfo;
             }
         } else {
             SqlCallParameterInfo sqlParameterInfo = new SqlCallParameterInfo(parameterInfo, typeInfoProvider, ref outArgCount);
             sortedParams.Add(parameterInfo.Position, sqlParameterInfo);
         }
     }
     parameters = sortedParams.Select(p => p.Value).ToArray();
     returnTypeInfo = typeInfoProvider.GetSerializationTypeInfo(method.ReturnType);
     if ((procedure.UseReturnValue != SqlReturnValue.Auto) || (method.ReturnType != typeof(void))) {
         useReturnValue = (procedure.UseReturnValue == SqlReturnValue.ReturnValue) || ((procedure.UseReturnValue == SqlReturnValue.Auto) && (typeInfoProvider.TypeMappingProvider.GetMapping(method.ReturnType).DbType == SqlDbType.Int));
     }
 }
开发者ID:avonwyss,项目名称:bsn-modulestore,代码行数:33,代码来源:SqlCallProcedureInfo.cs


示例3: Search

        public static string[] Search(String[] token, String txt, out Byte distance)
        {
            if (txt.Length > 0)
            {
                Byte bestKey = 255;
                SortedDictionary<Byte, List<string>> matches = new SortedDictionary<byte, List<string>>();
                Docking.Tools.ITextMetric tm = new Docking.Tools.Levenshtein(50);
                foreach(string s in token)
                {
                    Byte d = tm.distance(txt, s);
                    if (d <= bestKey) // ignore worse matches as previously found
                    {
                        bestKey = d;
                        List<string> values;
                        if (!matches.TryGetValue(d, out values))
                        {
                            values = new List<string>();
                            matches.Add(d, values);
                        }
                        if (!values.Contains(s))
                            values.Add(s);
                    }
                }

                if (matches.Count > 0)
                {
                    List<string> result = matches[bestKey];
                    distance = bestKey;
                    return result.ToArray();
                }
            }
            distance = 0;
            return null;
        }
开发者ID:Michael--,项目名称:DockingFramework,代码行数:34,代码来源:Levenshtein.cs


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


示例5: FindReplaceForm

        public FindReplaceForm()
        {
            InitializeComponent();

            m_Selection = new ObjectId[0];

            m_PosList = new SortedDictionary<string, List<ObjectId>>();
            m_CountList = new SortedDictionary<string, List<ObjectId>>();
            m_DiameterList = new SortedDictionary<string, List<ObjectId>>();
            m_SpacingList = new SortedDictionary<string, List<ObjectId>>();
            m_NoteList = new SortedDictionary<string, List<ObjectId>>();
            m_MultiplierList = new SortedDictionary<int, List<ObjectId>>();
            m_ShapeList = new SortedDictionary<string, List<ObjectId>>();

            m_PosProperties = new Dictionary<string, SelectedPos>();

            m_FindShape = string.Empty;
            m_ReplaceShape = string.Empty;
            m_FindFields = 0;
            m_ReplaceFields = 0;

            psvFind.BackColor = DWGUtility.ModelBackgroundColor();
            psvReplace.BackColor = DWGUtility.ModelBackgroundColor();

            init = false;
        }
开发者ID:oozcitak,项目名称:RebarPos,代码行数:26,代码来源:FindReplaceForm.cs


示例6: Process

        public void Process(RayCollection rayBuffer)
        {

            var topLevelHits = new SortedDictionary<uint, List<Tuple<Ray, PrimitiveHit>>>();
            rtDevice.TraceBuffer(rayBuffer);
            for (int index = 0; index < rayBuffer.rayHits.Length; index++)
            {
                if (!topLevelHits.ContainsKey(rayBuffer.rayHits[index].PrimitiveId))
                {
                    topLevelHits.Add(rayBuffer.rayHits[index].PrimitiveId, new List<Tuple<Ray, PrimitiveHit>>());
                }
                topLevelHits[rayBuffer.rayHits[index].PrimitiveId].Add(new Tuple<Ray, PrimitiveHit>(rayBuffer.RaysInfo[index], rayBuffer.rayHits[index]));
            }
            //Process Top Level Hits

            foreach (var topLevelHit in topLevelHits)
            {
                var prim = GetMesh(topLevelHit.Key);
                var rays = topLevelHit.Value.Select(item => item.Item1).ToArray();

                var buffer = new RayCollection(rays.Length);

                rtDevice.SetData(prim.BottomLevelBVH);
                rtDevice.TraceBuffer(buffer);
                for (int index = 0; index < buffer.rayHits.Length; index++)
                {
                    rayBuffer.UpdateHit(buffer.RaysInfo[index].Id, ref buffer.rayHits[index]);
                }
            }

        }
开发者ID:HungryBear,项目名称:rayden,代码行数:31,代码来源:RayProcessor.cs


示例7: cycle_check

        public string cycle_check(SortedDictionary<char, char> cycle)
        {
            cycle_str = "A";
            cycle_key = 'A';
            cycle_value = cycle['A'];
            cycle_length = "";

            while (cycle.Count != 1)
            {
                if (cycle_str.IndexOf(cycle_value) != -1)
                {
                    cycle.Remove(cycle_key);
                    cycle_key = cycle.ElementAt(0).Key;
                    cycle_value = cycle[cycle_key];
                    cycle_str += " " + cycle_key.ToString();
                }
                else
                {
                    cycle_str += cycle_value.ToString();
                    cycle.Remove(cycle_key);
                    cycle_key = cycle_value;
                    cycle_value = cycle[cycle_key];
                }
            }

            foreach (var el in cycle_str.Split(' '))
                cycle_length += el.Length + " ";

            return cycle_length;
        }
开发者ID:26Ghost,项目名称:Enigma,代码行数:30,代码来源:Data.cs


示例8: PrintArtists

 private static void PrintArtists(SortedDictionary<string, int> artists)
 {
     foreach (var artist in artists)
     {
         Console.WriteLine("Artist name: {0}, Number of albums: {1}", artist.Key, artist.Value);
     }
 }
开发者ID:deyantodorov,项目名称:TelerikAcademy,代码行数:7,代码来源:ExtractArtistAndAlbums.cs


示例9: GetSolution

        protected override object GetSolution()
        {
            SortedDictionary<long, long> decomposition = new SortedDictionary<long, long>();
            for (var i = 1; i <= MAX; i++)
            {
                var currentDecomposition = GetDecomposition(i);
                foreach (KeyValuePair<long, long> kvp in currentDecomposition)
                {
                    if (!decomposition.Keys.Contains(kvp.Key))
                    {
                        decomposition.Add(kvp.Key, kvp.Value);
                    }
                    else
                    {
                        var value = decomposition[kvp.Key];
                        if (value < kvp.Value)
                        {
                            decomposition[kvp.Key] = kvp.Value;
                        }
                    }
                }
            }

            double returnValue = 1;
            foreach (KeyValuePair<long, long> kvp in decomposition)
            {
                returnValue *= Math.Pow((double)kvp.Key, (double)kvp.Value);
            }

            return returnValue;
        }
开发者ID:pax162,项目名称:Problems,代码行数:31,代码来源:pe5.cs


示例10: GetData

        public List<SpreadPeriod> GetData()
        {
            var results = new SortedDictionary<long, SpreadPeriod>();
            this.AddValues(results, this.max, (x, y) => x.max = y);
            this.AddValues(results, this.min, (x, y) => x.min = y);
            this.AddValues(results, this.avg, (x, y) => x.avg = y);

            double lastMax = 0;
            double lastMin = 0;
            double lastAvg = 0;
            foreach (var period in results.Select(pair => pair.Value))
            {
                if (period.max == 0)
                {
                    period.max = lastMax;
                }
                if (period.min == 0)
                {
                    period.min = lastMin;
                }
                if (period.avg == 0)
                {
                    period.avg = lastAvg;
                }
                lastMax = period.max;
                lastMin = period.min;
                lastAvg = period.avg;
            }

            return results.Values.ToList();
        }
开发者ID:emardini,项目名称:TechnicalIndicators,代码行数:31,代码来源:SpreadsResponse.cs


示例11: GenerateAuthString

        public static string GenerateAuthString(string httpmethod, string url, SortedDictionary<string, string> parameters, string callback, string oauthToken = "")
        {
            byte[] nonceBuffer = new byte[32];
            random.NextBytes(nonceBuffer);

            string oauth_nonce = Convert.ToBase64String(nonceBuffer);
            string oauth_signature_method = "HMAC-SHA1";
            string oauth_timestamp = UnixTime().ToString();
            string oauth_callback = callback;
            string oauth_version = "1.0";

			if(callback != null)
			{
				parameters.Add("oauth_callback", oauth_callback);
			}
            parameters.Add("oauth_consumer_key", oauth_consumer_key);
            parameters.Add("oauth_nonce", oauth_nonce);
            parameters.Add("oauth_signature_method", oauth_signature_method);
            parameters.Add("oauth_timestamp", oauth_timestamp);
			if(oauthToken != "")
			{
				parameters.Add("oauth_token", oauthToken);
			}
            parameters.Add("oauth_version", oauth_version);

            string parameterString = ParameterString(parameters);

            parameters.Add("oauth_signature", Signature(httpmethod, url, parameterString, oauthToken));
            return "OAuth " + AuthenticationString(parameters);
        }
开发者ID:tblue1994,项目名称:SoftwareEngineeringProject2015,代码行数:30,代码来源:TwitterAuthenticator.cs


示例12: Main

    private static void Main()
    {
        SortedDictionary<string, List<Student>> courses = new SortedDictionary<string, List<Student>>();
        string studentsFilePath = "../../Resources/students.txt";

        using (StreamReader reader = new StreamReader(studentsFilePath))
        {
            string line;

            while ((line = reader.ReadLine()) != null)
            {
                string[] recordData = line.Split('|');
                string firstName = recordData[0].Trim();
                string lastName = recordData[1].Trim();
                string course = recordData[2].Trim();

                List<Student> students;

                if (!courses.TryGetValue(course, out students))
                {
                    students = new List<Student>();
                    courses.Add(course, students);
                }

                Student student = new Student(firstName, lastName);
                students.Add(student);
            }
        }

        foreach (var pair in courses)
        {
            Console.WriteLine("{0,15}:\n\t\t{1}", pair.Key, string.Join("\n\t\t", pair.Value));
        }
    }
开发者ID:Ivan-Dimitrov-bg,项目名称:.Net-framework,代码行数:34,代码来源:StudentSorter.cs


示例13: SendGetInfo

        /// <summary>
        /// 构造模拟远程HTTP的GET请求,获取支付宝的返回XML处理结果
        /// </summary>
        /// <param name="sParaTemp">请求参数数组</param>
        /// <param name="gateway">网关地址</param>
        /// <returns>支付宝返回XML处理结果</returns>
        public static XmlDocument SendGetInfo(SortedDictionary<string, string> sParaTemp, string gateway)
        {
            //待请求参数数组字符串
            Encoding code = Encoding.GetEncoding(_input_charset);
            string strRequestData = BuildRequestParaToString(sParaTemp, code);

            //构造请求地址
            string strUrl = gateway + strRequestData;

            //请求远程HTTP
            XmlDocument xmlDoc = new XmlDocument();
            try
            {
                //设置HttpWebRequest基本信息
                HttpWebRequest myReq = (HttpWebRequest)HttpWebRequest.Create(strUrl);
                myReq.Method = "get";

                //发送POST数据请求服务器
                HttpWebResponse HttpWResp = (HttpWebResponse)myReq.GetResponse();
                Stream myStream = HttpWResp.GetResponseStream();

                //获取服务器返回信息
                XmlTextReader Reader = new XmlTextReader(myStream);
                xmlDoc.Load(Reader);
            }
            catch (Exception exp)
            {
                string strXmlError = "<error>" + exp.Message + "</error>";
                xmlDoc.LoadXml(strXmlError);
            }

            return xmlDoc;
        }
开发者ID:codefighting,项目名称:shouxinzhihui,代码行数:39,代码来源:AlipaySubmit.cs


示例14: AlipayUrl

        public ActionResult AlipayUrl()
        {
            var shop = YunShop.Web.CommonMethod.GetSeoInfo();
            string partners = "";
            string return_url = "";
            try
            {
                partners = shop.FirstOrDefault(e => e.Key == "alipaykey").Value;
                if (string.IsNullOrWhiteSpace(shop.FirstOrDefault(e => e.Key == "alipayvalue").Value))
                {
                    return Json(false);
                }
                return_url = shop.FirstOrDefault(e => e.Key == "alipayurl").Value;
            }
            catch
            {
                return Json(false);
            }
            string target_service = "user.auth.quick.login";
            //必填
            //必填,页面跳转同步通知页面路径
            //需http://格式的完整路径,不允许加?id=123这类自定义参数

            //把请求参数打包成数组
            SortedDictionary<string, string> sParaTemp = new SortedDictionary<string, string>();
            sParaTemp.Add("partner", partners);
            sParaTemp.Add("_input_charset", Config.Input_charset.ToLower());
            sParaTemp.Add("service", "alipay.auth.authorize");
            sParaTemp.Add("target_service", target_service);
            sParaTemp.Add("return_url", return_url);
            //建立请求
            return Json(Submit.BuildRequestUrl(sParaTemp, shop.FirstOrDefault(e => e.Key == "alipayvalue").Value));
        }
开发者ID:icgyun,项目名称:Maigao,代码行数:33,代码来源:HomeController.cs


示例15: ParseAreaCodeMap

 public static AreaCodeMap ParseAreaCodeMap(Stream stream)
 {
     SortedDictionary<int, String> areaCodeMapTemp = new SortedDictionary<int, String>();
     using (var lines = new StreamReader(stream, Encoding.UTF8))
     {
         String line;
         while ((line = lines.ReadLine()) != null)
         {
             line = line.Trim();
             if (line.Length <= 0 || line[0] == '#')
                 continue;
             var indexOfPipe = line.IndexOf('|');
             if (indexOfPipe == -1)
             {
                 continue;
             }
             String areaCode = line.Substring(0, indexOfPipe);
             String location = line.Substring(indexOfPipe + 1);
             areaCodeMapTemp[int.Parse(areaCode)] = location;
         }
         // Build the corresponding area code map and serialize it to the binary format.
         AreaCodeMap areaCodeMap = new AreaCodeMap();
         areaCodeMap.readAreaCodeMap(areaCodeMapTemp);
         return areaCodeMap;
     }
 }
开发者ID:Effectlab-Solution-Web,项目名称:libphonenumber-csharp,代码行数:26,代码来源:AreaCodeParser.cs


示例16: Input

        static Input()
        {
            availableCommands = new SortedDictionary<string, MBCShellCommandHandler>();
            availableCommandDescriptions = new SortedDictionary<string, string>();

            AddCommand(Show.Config, "show", "config", "Displays the current configuration");
            AddCommand(Show.Controllers, "show", "controllers", "Displays the currently loaded controllers and their usage IDs");

            AddCommand(Create.Match, "create", "match", "[controllerIDs...] Discards the current match (if any) and creates a new match with the specified controllers by ID as shown by \"show controllers\".");
            AddCommand(Create.Config, "create", "config", "[configname] Creates a new configuration with the specified name.");

            AddCommand(Load.Match, "load", "match", "[filename] Loads a match from a file.");
            AddCommand(Load.Config, "load", "config", "[filename] Loads a configuration from a file.");

            AddCommand(Save.Match, "save", "match", "[filename] Saves the current match to a file.");
            AddCommand(Save.Config, "save", "config", "[filename] Saves the configuration to a file.");

            AddCommand(MatchRun.Step, "match", "step", "Steps through the current match.");
            AddCommand(MatchRun.Start, "match", "start", "Plays through a match until it ends.");
            AddCommand(MatchRun.Start, "match", "stop", "Ends the current match.");

            AddCommand(Set.Config, "set", "config", "[key] [value] Sets a configuration key value to the one specified.");

            AddCommand(EventOutput.Enable, "event", "enable", "[\"match\"/\"controller\"/\"round\"] Enables console display of the specified event.");
            AddCommand(EventOutput.Disable, "event", "disable", "[\"match\"/\"controller\"/\"round\"] Disables console display of the specified event.");

            AddCommand(Help.Commands, "help", "Shows this help display.");

            AddCommand(Stop, "exit", "Exits the console application.");
        }
开发者ID:J0RD1E,项目名称:Mohawk_Battleship,代码行数:30,代码来源:Input.cs


示例17: GetSignature

        /// <summary>
        /// 计算参数签名
        /// </summary>
        /// <param name="params">请求参数集,所有参数必须已转换为字符串类型</param>
        /// <param name="secret">签名密钥</param>
        /// <returns>签名</returns>
        public static string GetSignature(IDictionary<string, string> parameters, string secret, string url)
        {
            // 先将参数以其参数名的字典序升序进行排序
            IDictionary<string, string> sortedParams = new SortedDictionary<string, string>(parameters);
            IEnumerator<KeyValuePair<string, string>> iterator = sortedParams.GetEnumerator();

            // 遍历排序后的字典,将所有参数按"key=value"格式拼接在一起
            StringBuilder basestring = new StringBuilder();
            WebRequest request = WebRequest.Create(url);
            basestring.Append("POST").Append(request.RequestUri.Host).Append(request.RequestUri.AbsolutePath);
            while (iterator.MoveNext())
            {
                string key = iterator.Current.Key;
                string value = iterator.Current.Value;
                if (!string.IsNullOrEmpty(key) && !string.IsNullOrEmpty(value))
                {
                    basestring.Append(key).Append("=").Append(value);
                }
            }
            basestring.Append(secret);

            // 使用MD5对待签名串求签
            MD5 md5 = MD5.Create();
            byte[] bytes = md5.ComputeHash(Encoding.UTF8.GetBytes(basestring.ToString()));

            // 将MD5输出的二进制结果转换为小写的十六进制
            StringBuilder result = new StringBuilder();
            foreach (byte b in bytes)
            {
                result.Append(b.ToString("x2").ToLower());
            }
            return result.ToString();
        }
开发者ID:kinshines,项目名称:XinGePush,代码行数:39,代码来源:SignUtility.cs


示例18: ConvertHashTable

 private static SortedDictionary<string, object> ConvertHashTable(Hashtable ht) {
     var retval = new SortedDictionary<string, object>();
     foreach (DictionaryEntry de in ht) {
         retval.Add(de.Key.ToString(), de.Value);
     }
     return retval;
 }
开发者ID:elrute,项目名称:Triphulcas,代码行数:7,代码来源:MacroScript.cs


示例19: BindDataSource

        private void BindDataSource() {
            var queryTable = new SortedDictionary<string, string>(_repository.QueryProvider.GetQueries());

            lblProductName.Text = _dbName;
            rptMethods.DataSource = queryTable;
            rptMethods.DataBind();
        }
开发者ID:debop,项目名称:NFramework,代码行数:7,代码来源:Methods.aspx.cs


示例20: TestDistributionCalculation

        public void TestDistributionCalculation()
        {
            {
                var data = new[] { 0M, 0.1M, 0.6M, 0.8M, 1.1M, 2.2M, 2.4M, };
                var distribution = Stats.CalculateDistribution(data, 0.5M);
                var sample = new SortedDictionary<decimal, int>
                    {
                        { 0, 1 },
                        { 0.5M, 1 },
                        { 1, 2 },
                        { 1.5M, 1 },
                        { 2.5M, 2 }
                    };
                Assert.IsTrue(distribution.Vals.SequenceEqual(sample));
            }

            {
                var data = new[] { 0M, 0.1M, 0.2M, 0.21M, 0.25M };
                var distribution = Stats.CalculateDistribution(data, 0.2M);
                var sample = new SortedDictionary<decimal, int>
                    {
                        { 0, 1 },
                        { 0.2M, 2 },
                        { 0.4M, 2 },
                    };
                Assert.IsTrue(distribution.Vals.SequenceEqual(sample));
            }
        }
开发者ID:sopel,项目名称:AppMetrics,代码行数:28,代码来源:UnitTesting.cs



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


鲜花

握手

雷人

路过

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

请发表评论

全部评论

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

扫描微信二维码

查看手机版网站

随时了解更新最新资讯

139-2527-9053

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

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

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