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

C# SortedList类代码示例

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

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



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

示例1: getBeforeAndAfterKeys

 public List<double> getBeforeAndAfterKeys(SortedList<double, double> aSortedList, double pseudoKey)
 {
     double before = 0;
     double after = 0;
     this.getBeforeAndAfterKeys(aSortedList, pseudoKey, ref before, ref after);
     return new List<double>{before, after};
 }
开发者ID:JoepBC,项目名称:scientrace,代码行数:7,代码来源:OpticalEfficiencyCharacteristics.cs


示例2: rptTeams_ItemDataBound

 protected void rptTeams_ItemDataBound(object sender, RepeaterItemEventArgs e)
 {
     DropDownList drpStanding = (DropDownList)e.Item.FindControl("drpStanding");
     int year = cf.getMaxYear();
     SortedList teams = new SortedList();
     int cnt = 0;
     if (Session["user"] != null)
     {
         user u = (user)Session["user"];
         teams = u.get_teams();
         rptTeams.DataSource = null;
     }
     if (teams == null)
     {
         teams = cf.getTeams(year);
     }
     cnt = teams.Count;
     for (int i = 0; i < cnt; i++)
     {
         int s = i + 1;
         drpStanding.Items.Add(new ListItem(s.ToString(), s.ToString()));
     }
     try
     {
         drpStanding.SelectedIndex = e.Item.ItemIndex;
     }
     catch (Exception ex)
     {
         cf.logError(ex);
     }
 }
开发者ID:denpone,项目名称:ffl,代码行数:31,代码来源:final_standings.aspx.cs


示例3: Updater

 public Updater(FileTransfer fileTransfer)
 {
     this.fileTransfer = fileTransfer;
     filesToDelete = new SortedList<string, string>();
     filesToDownload = new SortedList<string,TransferFile>();
     updaterConfig = new UpdaterConfig();
 }
开发者ID:BitAlchemists,项目名称:EU-Updater,代码行数:7,代码来源:Updater.cs


示例4: MainForm

        public MainForm(string configPath, bool minimize)
        {
            Config config;
            string message;

            this.InitializeComponent();

            this.toolStripMenuItemName.Text += Assembly.GetExecutingAssembly().GetName().Version.ToString(2);
            this.Icon = Resources.AppIcon;

            this.rules = new Dictionary<string, Rule>();
            this.configPath = configPath;
            this.minimize = minimize;
            this.points = new SortedList<int, Point>();

            if (!File.Exists(configPath))
                config = new Config();
            else if (!Config.TryParse(File.ReadAllText(configPath), out config, out message))
            {
                this.toolStripStatusLabel.Text = string.Format(CultureInfo.InvariantCulture, "Configuration error: {0}", message);

                config = new Config();
            }

            this.ConfigSet(config);
            this.ModeConfigRadioCheckedChanged(this, new EventArgs());
        }
开发者ID:r3c,项目名称:menora,代码行数:27,代码来源:MainForm.cs


示例5: GetPatents

        //read XML file for patent info
        public static SortedList<int, Patent> GetPatents()
        {
            XmlDocument doc = new XmlDocument();

            //if file doesn't exist, create it
            if (!File.Exists("Patents.xml"))
                doc.Save("Patents.xml");

            SortedList<int, Patent> patents = new SortedList<int, Patent>();

            XmlReaderSettings readerSettings = new XmlReaderSettings();
            readerSettings.IgnoreWhitespace = true;
            readerSettings.IgnoreComments = true;

            XmlReader readXml = null;

            try
            {
                readXml = XmlReader.Create(path, readerSettings);

                if (readXml.ReadToDescendant("Patent")) //read to first Patent node
                {
                    do
                    {
                        Patent patent = new Patent();
                        patent.Number = Convert.ToInt32(readXml["Number"]);
                        readXml.ReadStartElement("Patent");
                        patent.AppNumber = readXml.ReadElementContentAsString();
                        patent.Description = readXml.ReadElementContentAsString();
                        patent.FilingDate = DateTime.Parse(readXml.ReadElementContentAsString());
                        patent.Inventor = readXml.ReadElementContentAsString();
                        patent.Inventor2 = readXml.ReadElementContentAsString();

                        int key = patent.Number; //assign key to value

                        patents.Add(key, patent); //add key-value pair to list
                    }
                    while (readXml.ReadToNextSibling("Patent"));
                }
            }
            catch (XmlException ex)
            {
                MessageBox.Show(ex.Message, "Xml Error");
            }
            catch (IOException ex)
            {
                MessageBox.Show(ex.Message, "IO Exception");
            }
            catch (Exception ex)
            {
                MessageBox.Show(ex.Message, "Exception Occurred");
            }
            finally
            {
                if (readXml != null)
                    readXml.Close();
            }

            return patents;
        }
开发者ID:whitneyhaddow,项目名称:cat-patents-v2,代码行数:61,代码来源:PatentDB.cs


示例6: CalculateAverage

        public List<Measure> CalculateAverage()
        {
            //return empty MeasureList if no measures where added
            if ((_inputList == null) || (_inputList.Count == 0))
            {
                return new List<Measure>();
            }

            //Get the average measures for all logminutes
            SortedList<DateTime, MeasureMinute> calcList = new SortedList<DateTime, MeasureMinute>();
            foreach (var measure in _inputList)
            {
                var currentMeasureTime = Utils.GetWith0Second(measure.DateTime);
                if (!calcList.ContainsKey(currentMeasureTime))
                {
                    calcList.Add(currentMeasureTime, new MeasureMinute(currentMeasureTime));
                }

                calcList[currentMeasureTime].AddMeasure(measure);
            }
            List<Measure> result = new List<Measure>();
            foreach (var logMinute in calcList.Values)
            {
                result.AddRange(logMinute.CalculateAverage());
            }

            return result;
        }
开发者ID:Epstone,项目名称:mypvlog,代码行数:28,代码来源:MinuteWiseAverageCalculator.cs


示例7: ContainsNearbyAlmostDuplicate

    public bool ContainsNearbyAlmostDuplicate(int[] nums, int k, int t)
    {

        if (k <= 0 || t < 0) return false;
        var index = new SortedList<int, object>();
        for (int i = 0; i < nums.Length; ++i)
        {
            if (index.ContainsKey(nums[i]))
            {
                return true;
            }
            index.Add(nums[i], null);
            var j = index.IndexOfKey(nums[i]);
            if (j > 0 && (long)nums[i] - index.Keys[j - 1] <= t)
            {
                return true;
            }
            if (j < index.Count - 1 && (long)index.Keys[j + 1] - nums[i] <= t)
            {
                return true;
            }
            if (index.Count > k)
            {
                index.Remove(nums[i - k]);
            }
        }
        return false;
    }
开发者ID:alexguo88,项目名称:LeetCode,代码行数:28,代码来源:220.ContainsDuplicateIII.cs


示例8: flushToDatabase

 //This is the function that is used to put buffered data on the database
 public bool flushToDatabase()
 {
     //Set to correct database
     mysql.switchDatabase("crex_forwardmetric");
     Console.WriteLine("Flushing To Forward Metric...");
     Console.WriteLine("0%");
     string returnval = "";
     //Go through all the data and add it efficiently
     for(int i = 0; i < data.Count;i++)
     {
         returnval+=mysql.issueCommand("create table if not exists `"+data.Keys[i]+"` (wordStrings char(50), wordCounts integer unsigned, primary key (wordStrings));");
         if(data.Values[i].Count==0) continue;
         string command = "insert into `"+data.Keys[i]+"` (wordStrings,wordCounts) values ";
         for(int j = 0; j < data.Values[i].Count;j++)
             command+="('"+data.Values[i][j]+"',1),";
         command = command.Remove(command.Length-1);
         command+=" on duplicate key update wordCounts=wordCounts+1;";
         returnval+=mysql.issueCommand(command);
         Console.SetCursorPosition(0, Console.CursorTop - 1);
         Console.WriteLine((int)((double)((double)i/(double)data.Count)*100.00)+"%");
     }
     Console.SetCursorPosition(0, Console.CursorTop - 1);
     Console.WriteLine("100%");
     Console.WriteLine("Done Flushing to Forward Metric...");
     //Reset data
     data = new SortedList<string, List<string>>();
     if(returnval!="") return false;
     return true;
 }
开发者ID:Xydane,项目名称:Contextosaurus-Rex,代码行数:30,代码来源:ForwardMetric.cs


示例9: CovertChatLogsToDialogue

 public static void CovertChatLogsToDialogue(ref SortedList<DateTime, List<ChatWord>> chatLogs, ref SortedList<DateTime, List<ChatDialogue>> chatDialogues, int timeSpan = 60)
 {
     DateTime currentDate = DateTime.Today;
     DateTime currentDateTime = DateTime.Today;
     foreach (var dialogue in chatLogs)
     {
         if (currentDateTime.Equals(DateTime.Today) || (dialogue.Value.First().timeStamp - currentDateTime).TotalMinutes > timeSpan)
         {
             chatDialogues.Add(dialogue.Key, new List<ChatDialogue>());
             currentDate = dialogue.Key;
         }
         foreach (var log in dialogue.Value)
         {
             if (currentDateTime.Equals(DateTime.Today) || (log.timeStamp - currentDateTime).TotalMinutes > timeSpan)
             {
                 if (!currentDate.Date.Equals(log.timeStamp.Date))
                 {
                     chatDialogues.Add(dialogue.Key, new List<ChatDialogue>());
                     currentDate = dialogue.Key;
                 }
                 chatDialogues[currentDate].Add(new ChatDialogue(log.timeStamp));
             }
             chatDialogues[currentDate].Last().chatWords.Add(log);
             currentDateTime = log.timeStamp;
         }
     }
 }
开发者ID:CaseyYang,项目名称:Utilities,代码行数:27,代码来源:ChatDialogue.cs


示例10: GetExternalActions

        private SortedList<int, IAction> GetExternalActions(IPolicyChannel channel)
        {
            SortedList<int, IAction> externalActions = new SortedList<int, IAction>();

            IRoutingTable routing = channel.Routing;

            if (routing == null)
                return externalActions;

            Guid unprivDestinationId = routing.DefaultDestination.Identifier;
            Guid unprivSourceId = routing.DefaultSource.Identifier;

            IRoutingMatrixCell routingMatrixCell = routing[unprivSourceId, unprivDestinationId];
            if (routingMatrixCell == null)
                return externalActions;

            IActionMatrixCell actionMatrixCell = channel.Actions[unprivSourceId, unprivDestinationId];

            if (actionMatrixCell == null)
                return externalActions;

            foreach (IActionConditionGroup actionCondtionGroup in actionMatrixCell.ActionConditionGroups)
            {
                foreach (IAction action in actionCondtionGroup.ActionGroup.Actions)
                {
                    externalActions.Add(action.Precedence, action);
                }
            }
            return externalActions;
        }
开发者ID:killbug2004,项目名称:WSProf,代码行数:30,代码来源:PolicyLoader.cs


示例11: ForwardMetric

 public ForwardMetric()
 {
     //Star SQL Connection and set data to null
     data = new SortedList<string, List<string>>();
     mysql = new SQLInterface();
     mysql.connect(Program.mysqlusername, Program.mysqlpass, Program.mysqldatabase, Program.mysqlservername);
 }
开发者ID:Xydane,项目名称:Contextosaurus-Rex,代码行数:7,代码来源:ForwardMetric.cs


示例12: TabStandards

        public TabStandards(string standardsFile)
        {
            FilePath = standardsFile;
            StandardsList = new SortedList<long, NZQAStandard>();
            LatestVersions = new SortedList<int, int>();

            bool firstLine = true;
            int lineNumber = 1;
            foreach (var line in File.ReadAllLines(standardsFile))
            {
                if (firstLine)
                {
                    firstLine = false;
                    if (!line.Contains(DELIMETER)) continue;
                }

                var std = ParseLine(line, lineNumber++);
                var stdNo = std.StandardNumber;
                var verNo = std.Version;

                StandardsList[ToKey(stdNo, verNo)] = std;
                if (( !LatestVersions.ContainsKey(stdNo)) || LatestVersions[stdNo] < verNo)
                {
                    LatestVersions[stdNo] = verNo;
                    if (std.IsInternal) StandardsList[ToKey(stdNo, MAX_VERSION)] = std;
                }
            }
        }
开发者ID:smanoharan,项目名称:hbhs-automation,代码行数:28,代码来源:TabStandards.cs


示例13: StopSpider

        public StopSpider(IPAddress providerDNS, IPAddress censorRedirect, string provider, string country, string reporter)
        {
            // initiate spiderlist

            this.providerDNS = providerDNS;
            this.censorRedirect = censorRedirect;
            this.provider = provider;
            this.country = country;
            this.reporter = reporter;
            this.openDnsResolver = new Resolver(Resolver.DefaultDnsServers[0]);

            // add an initial list in randomized order, this will also prevent adding already known urls!
            SortedList<int, string> rlist = new SortedList<int, string>();
            TextReader inputurls = new StreamReader(Assembly.GetExecutingAssembly().GetManifestResourceStream("shortlist.txt"));
            string url; Random r = new Random();
            while ((url = inputurls.ReadLine()) != null)
            {
                rlist.Add(r.Next(), url);
            }

            foreach (string uri in rlist.Values)
            {
                spiderlist.Add(new SpiderInfo(uri, 0));
                spidercheck.Add(uri, true);
            }
        }
开发者ID:FreeApophis,项目名称:zensorchecker,代码行数:26,代码来源:StopSpider.cs


示例14: ResetControls

    /// <summary>
    /// Resets all boxes.
    /// </summary>
    public void ResetControls()
    {
        txtCodeName.Text = null;
        txtDisplayName.Text = null;

        //Fill drop down list
        DataHelper.FillWithEnum<AnalyzerTypeEnum>(drpAnalyzer, "srch.index.", SearchIndexInfoProvider.AnalyzerEnumToString, true);

        drpAnalyzer.SelectedValue = SearchIndexInfoProvider.AnalyzerEnumToString(AnalyzerTypeEnum.StandardAnalyzer);
        chkAddIndexToCurrentSite.Checked = true;

        // Create sorted list for drop down values
        SortedList sortedList = new SortedList();

        sortedList.Add(GetString("srch.index.doctype"), PredefinedObjectType.DOCUMENT);
        // Allow forum only if module is available
        if ((ModuleEntry.IsModuleRegistered(ModuleEntry.FORUMS) && ModuleEntry.IsModuleLoaded(ModuleEntry.FORUMS)))
        {
            sortedList.Add(GetString("srch.index.forumtype"), PredefinedObjectType.FORUM);
        }
        sortedList.Add(GetString("srch.index.usertype"), PredefinedObjectType.USER);
        sortedList.Add(GetString("srch.index.customtabletype"), SettingsObjectType.CUSTOMTABLE);
        sortedList.Add(GetString("srch.index.customsearch"), SearchHelper.CUSTOM_SEARCH_INDEX);
        sortedList.Add(GetString("srch.index.doctypecrawler"), SearchHelper.DOCUMENTS_CRAWLER_INDEX);
        sortedList.Add(GetString("srch.index.general"), SearchHelper.GENERALINDEX);

        drpType.DataValueField = "value";
        drpType.DataTextField = "key";
        drpType.DataSource = sortedList;
        drpType.DataBind();

        // Pre-select documents index
        drpType.SelectedValue = PredefinedObjectType.DOCUMENT;
    }
开发者ID:hollycooper,项目名称:Sportscar-Standings,代码行数:37,代码来源:SearchIndex_New.ascx.cs


示例15: GetPeersTask

 public GetPeersTask(DhtEngine engine, NodeId infohash)
 {
     this.engine = engine;
     this.infoHash = infohash;
     this.closestNodes = new SortedList<NodeId, NodeId>(Bucket.MaxCapacity);
     this.queriedNodes = new SortedList<NodeId, Node>(Bucket.MaxCapacity * 2);
 }
开发者ID:senditu,项目名称:simpletorrent,代码行数:7,代码来源:GetPeersTask.cs


示例16: DcmDataset

 public DcmDataset(long streamPosition, uint lengthInStream, DicomTransferSyntax transferSyntax)
 {
     _streamPosition = streamPosition;
     _streamLength = lengthInStream;
     _transferSyntax = transferSyntax;
     _items = new SortedList<DicomTag, DcmItem>(new DicomTagComparer());
 }
开发者ID:karanbajaj,项目名称:mdcm,代码行数:7,代码来源:DcmDataset.cs


示例17: Run

        public override void Run(string[] _params)
        {
            try {
                EnumGamePrefs enumGamePrefs = EnumGamePrefs.Last;

                if (_params.Length > 0) {
                    try {
                        enumGamePrefs = (EnumGamePrefs)((int)Enum.Parse (typeof(EnumGamePrefs), _params [0]));
                    } catch (Exception e) {
                        Log.Out ("Error in GetGamePrefs.Run: " + e);
                    }
                }

                if (enumGamePrefs == EnumGamePrefs.Last) {
                    SortedList<string, string> sortedList = new SortedList<string, string> ();
                    foreach (EnumGamePrefs gp in Enum.GetValues(typeof(EnumGamePrefs))) {
                        if ((_params.Length == 0) || (gp.ToString ().ToLower ().Contains (_params [0].ToLower ()))) {
                            if (prefAccessAllowed (gp)) {
                                sortedList.Add (gp.ToString (), string.Format ("{0} = {1}", gp.ToString (), GamePrefs.GetObject (gp)));
                            }
                        }
                    }
                    foreach (string s in sortedList.Keys) {
                        m_Console.SendResult (sortedList [s]);
                    }
                } else {
                    if (prefAccessAllowed (enumGamePrefs))
                        m_Console.SendResult (string.Format ("{0} = {1}", enumGamePrefs, GamePrefs.GetObject (enumGamePrefs)));
                    else
                        m_Console.SendResult ("Je ne peux communiquer cette information.");
                }
            } catch (Exception e) {
                Log.Out ("Error in GetGamePrefs.Run: " + e);
            }
        }
开发者ID:Ketchu13,项目名称:7dtd_Commands_Extended,代码行数:35,代码来源:GetGamePrefs.cs


示例18: AddIdentifier

        // assumes identifier is valid
        protected virtual void AddIdentifier(string identifier)
        {
            if (names == null)
                names = new SortedList<string, string>(StringComparer.OrdinalIgnoreCase);

            names.Add(identifier, identifier);
        }
开发者ID:iskiselev,项目名称:JSIL.NetFramework,代码行数:8,代码来源:UniqueCodeIdentifierScope.cs


示例19: GetReadableTimespan

        public static string GetReadableTimespan(TimeSpan ts)
        {
            // formats and its cutoffs based on totalseconds
            var cutoff = new SortedList<long, string>
            {
                {60, "{3:S}" },
                {60*60, "{2:M}, {3:S}"},
                {24*60*60, "{1:H}, {2:M}"},
                {Int64.MaxValue , "{0:D}, {1:H}"}
            };

            // find nearest best match
            var find = cutoff.Keys.ToList()
                          .BinarySearch((long)ts.TotalSeconds);
            // negative values indicate a nearest match
            var near = find < 0 ? Math.Abs(find) - 1 : find;
            // use custom formatter to get the string
            return String.Format(
                new HMSFormatter(),
                cutoff[cutoff.Keys[near]],
                ts.Days,
                ts.Hours,
                ts.Minutes,
                ts.Seconds);
        }
开发者ID:hexafluoride,项目名称:byteflood,代码行数:25,代码来源:HMSFormatter.cs


示例20: LRUCacheManager

 public LRUCacheManager(String savedLocation, String memoryRunLocation)
 {
     StreamReader reader = new StreamReader(savedLocation);
     StorageFileLocation = reader.ReadLine();
     File.Copy(StorageFileLocation, memoryRunLocation, true);
     StorageFileLocation = memoryRunLocation;
     NextPageAddress = Int64.Parse(reader.ReadLine());
     CacheSize = Int32.Parse(reader.ReadLine());
     NumberOfNodes = Int32.Parse(reader.ReadLine());
     StorageReader = new FileStream(
         memoryRunLocation,
         FileMode.OpenOrCreate,
         FileAccess.ReadWrite,
         FileShare.None,
         8,
         FileOptions.WriteThrough | FileOptions.RandomAccess);
     AddressTranslationTable = new SortedDictionary<Address, Int64>();
     PageTranslationTable = new Dictionary<Int64, Page>();
     LeastRecentlyUsed = new SortedList<Int64, Page>();
     DirtyPages = new List<Page>();
     FreePages = new Queue<Int64>();
     Ticks = 0;
     if (!reader.ReadLine().Equals("AddressTranslationTable"))
         throw new Exception();
     String buffer;
     while (!(buffer = reader.ReadLine()).Equals("FreePages"))
         AddressTranslationTable.Add(
             new Address(buffer),
             Int64.Parse(reader.ReadLine()));
     while (!reader.EndOfStream)
         FreePages.Enqueue(Int64.Parse(reader.ReadLine()));
     reader.Close();
 }
开发者ID:joaofig,项目名称:r-tree-csharp-framework,代码行数:33,代码来源:LRUCache.cs



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


鲜花

握手

雷人

路过

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

请发表评论

全部评论

专题导读
上一篇:
C# SortedMap类代码示例发布时间:2022-05-24
下一篇:
C# SortedDictionary类代码示例发布时间: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