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


C# SortedList.Add方法代码示例

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


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

示例1: Page_Load

    protected void Page_Load(object sender, EventArgs e)
    {
        AWSAuthConnection conn = new AWSAuthConnection(accessKey, secretKey);

          XmlTextReader r = new XmlTextReader(Request.InputStream);
          r.MoveToContent();
          string xml = r.ReadOuterXml();

          XmlDocument documentToSave = new XmlDocument();
          documentToSave.LoadXml(xml);

          SortedList metadata = new SortedList();
          metadata.Add("title", bucket);
          metadata.Add("Content-Type", "application/xml");
          S3Object titledObject =
           new S3Object(documentToSave.OuterXml, metadata);

          SortedList headers = new SortedList();
          headers.Add("Content-Type", "application/xml");
          headers.Add("x-amz-acl", "public-read");

          conn.put(bucket, documentKey, titledObject, headers);

          Response.Write("saved: " + documentToSave.OuterXml);
    }
开发者ID:isccarlosaguilar,项目名称:exosamples,代码行数:25,代码来源:save.aspx.cs

示例2: ListProc

 private void ListProc()
 {
     listView1.Items.Clear();
     Process[] proc = System.Diagnostics.Process.GetProcesses();
     List<Process> l = proc.ToList<Process>();
     SortedList<String, Process> sl = new SortedList<string, Process>();
     int it = 0;
     foreach (Process p in proc)
     {
         if (sl.ContainsKey(p.ProcessName))
             sl.Add(p.ProcessName + it.ToString(), p);
         else sl.Add(p.ProcessName, p);
         it++;
     }
     foreach (KeyValuePair<String, Process> pr in sl.ToList<KeyValuePair<String, Process>>())
     {
         ListViewItem lvi = new ListViewItem(pr.Value.ProcessName);
         lvi.SubItems.Add(pr.Value.BasePriority.ToString());
         lvi.SubItems.Add(pr.Value.Id.ToString());
         lvi.SubItems.Add(pr.Value.WorkingSet64.ToString());
         listView1.Items.Add(lvi);
     }
     toolStripStatusLabel1.Text = "Процессов: " + proc.Count<Process>().ToString();
     int count = 0;
     foreach (Process p in proc)
     {
         count += p.Threads.Count;
     }
     toolStripStatusLabel2.Text = "Потоков: " + count.ToString();
 }
开发者ID:evgenij1204,项目名称:TaskManager,代码行数:30,代码来源:Form1.cs

示例3: StressTestList

        public void StressTestList()
        {
            var sortedList = new SortedList<int>();

            for (var i = 1000; i > 0; i--)
            {
                sortedList.Add(i);
            }

            for (var i = 1000; i > 0; i--)
            {
                sortedList.Add(i);
            }

            var counter = 0;
            var val = 1;

            while (counter <= 1000)
            {
                Assert.AreEqual(sortedList[counter], val);
                counter++;

                Assert.AreEqual(sortedList[counter], val);
                counter++;
                val++;
            }
        }
开发者ID:GTuritto,项目名称:ngenerics,代码行数:27,代码来源:Add.cs

示例4: Main

        static void Main()
        {
            var books = new SortedList<string, string>();
              books.Add("Professional WPF Programming", "978–0–470–04180–2");
              books.Add("Professional ASP.NET MVC 3", "978–1–1180–7658–3");

              books["Beginning Visual C# 2010"] = "978–0–470-50226-6";
              books["Professional C# 4 and .NET 4"] = "978–0–470–50225–9";

              foreach (KeyValuePair<string, string> book in books)
              {
            Console.WriteLine("{0}, {1}", book.Key, book.Value);
              }

              foreach (string isbn in books.Values)
              {
            Console.WriteLine(isbn);
              }

              foreach (string title in books.Keys)
              {
            Console.WriteLine(title);
              }

              {
            string isbn;
            string title = "Professional C# 7.0";
            if (!books.TryGetValue(title, out isbn))
            {
              Console.WriteLine("{0} not found", title);
            }
              }
        }
开发者ID:Ricky-Hao,项目名称:ProCSharp,代码行数:33,代码来源:Program.cs

示例5: ComputeChildList

        public static SortedList<string, Either<TreeTreeReference, TreeBlobReference>> ComputeChildList(IEnumerable<TreeTreeReference> treeRefs, IEnumerable<TreeBlobReference> blobRefs)
        {
            // Sort refs by name:
            var namedRefs = new SortedList<string, Either<TreeTreeReference, TreeBlobReference>>(treeRefs.Count() + blobRefs.Count(), StringComparer.Ordinal);

            // Add tree refs:
            foreach (var tr in treeRefs)
            {
                if (namedRefs.ContainsKey(tr.Name))
                    throw new InvalidOperationException();

                namedRefs.Add(tr.Name, tr);
            }

            // Add blob refs:
            foreach (var bl in blobRefs)
            {
                if (namedRefs.ContainsKey(bl.Name))
                    throw new InvalidOperationException();

                namedRefs.Add(bl.Name, bl);
            }

            return namedRefs;
        }
开发者ID:JamesDunne,项目名称:Immutable-Versioned-Objects,代码行数:25,代码来源:TreeNode.cs

示例6: Main

        static void Main(string[] args)
        {
            var books = new SortedList<string, string>();
            books.Add("C# 2008 Wrox Box", "978–0–470–047205–7");
            books.Add("Professional ASP.NET MVC 1.0", "978–0–470–38461–9");

            books["Beginning Visual C# 2008"] = "978–0–470-19135-4";
            books["Professional C# 2008"] = "978–0–470–19137–6";

            foreach (KeyValuePair<string, string> book in books)
            {
                Console.WriteLine("{0}, {1}", book.Key, book.Value);
            }

            foreach (string isbn in books.Values)
            {
                Console.WriteLine(isbn);
            }

            foreach (string title in books.Keys)
            {
                Console.WriteLine(title);
            }

            {
                string isbn;
                string title = "Professional C# 7.0";
                if (!books.TryGetValue(title, out isbn))
                {
                    Console.WriteLine("{0} not found", title);
                }
            }
            Console.ReadKey();
        }
开发者ID:CSharpDev,项目名称:Csharp,代码行数:34,代码来源:Program.cs

示例7: Frm_Main_Load

 private void Frm_Main_Load(object sender, EventArgs e)
 {
     //构造泛型排序列表
     SortedList<int, UserInfo> uses = new SortedList<int, UserInfo>();
     //为泛型排序列表添加元素
     uses.Add(2, new UserInfo(2, "User02", "02"));
     uses.Add(1, new UserInfo(3, "User03", "03"));
     uses.Add(3, new UserInfo(1, "User01", "01"));
    label1.Text="未按用户名排序前的查询结果:\n";
     foreach (var item in uses)//泛型排序列表按键自动进行排序
     {
         label1.Text+=string.Format("({0},{1})", item.Key, item.Value.UserName);
         label1.Text += "\n";
     }
     //按用户名对泛型排序列表进行排序
     var query = from item in uses
                 orderby item.Value.UserName
                 select item;
     label1.Text += "按用户名排序后的查询结果:\n";
     foreach (var item in query)//遍历查询结果
     {
         label1.Text+=string.Format("({0},{1})", item.Key, item.Value.UserName);
         label1.Text += "\n";
     }
 }
开发者ID:mahuidong,项目名称:c-1200-II,代码行数:25,代码来源:Frm_Main.cs

示例8: SortBehavior

        public void SortBehavior(string sortBy, bool sortAsc)
        {
            SortedList<string, User> list = new SortedList<string, User>();
            IList<User> userList = new List<User>();
            foreach (User user in User.FindAll())
            {
                if (sortBy == "Email")
                    list.Add(user.Email, user);
                else
                    list.Add(user.Name, user);
            }

            if (!sortAsc)
            {
                for (int x = list.Count - 1; x >= 0; x--)
                {
                    userList.Add(list[list.Keys[x]]);
                }
            }
            else
            {
                foreach (KeyValuePair<string, User> pair in list)
                {
                    userList.Add(pair.Value);
                }
            }

            PropertyBag["users"] = userList;
            PropertyBag["sortBy"] = sortBy;
            PropertyBag["sortAsc"] = sortAsc;
        }
开发者ID:jamescurran,项目名称:Castle.MonoRail.ViewComponents,代码行数:31,代码来源:SmartGridController.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: Run

 public static void Run()
 {
     string[] line = Console.ReadLine().Split(' ');
     long r = Convert.ToInt32(line[0]),
         g = Convert.ToInt32(line[1]),
         b = Convert.ToInt32(line[2]);
     SortedList<long, long> list = new SortedList<long, long>();
     list.Add(r, r);
     list.Add(g, g);
     list.Add(b, b);
     long t = list[2] / 2;
     long result = 0;
     if (list[0] + list[1] <= t)
     {
         result = (list[0] + list[1]) * 2;
     }
     else
     {
         result = t * 2;
         long last = list[2] - t * 2;
         if (list[0] - t >= 0) {
             list[0] -= t; // 0 - n
             list[2] = last; // 0 - 1
             
         }
         else {
             t -= list[0];
             list[0] = 0;
             list[1] -= t;
             list[2] = last;
             if (last == 1) result++;
         }
     }
 }
开发者ID:dzholmukhanov,项目名称:AlgorithmTraining,代码行数:34,代码来源:TableDecorations273.cs

示例11: ClassHierarchyTreeView

        public ClassHierarchyTreeView(Type typeRoot)
        {
            // Make sure PresentationCore is loaded.
            UIElement dummy = new UIElement();

            // Put all the referenced assemblies in a List.
            List<Assembly> assemblies = new List<Assembly>();

            // Get all referenced assemblies.
            AssemblyName[] anames =
                    Assembly.GetExecutingAssembly().GetReferencedAssemblies();

            // Add to assemblies list.
            foreach (AssemblyName aname in anames)
                assemblies.Add(Assembly.Load(aname));

            // Store descendants of typeRoot in a sorted list.
            SortedList<string, Type> classes = new SortedList<string, Type>();
            classes.Add(typeRoot.Name, typeRoot);

            // Get all the types in the assembly.
            foreach (Assembly assembly in assemblies)
                foreach (Type typ in assembly.GetTypes())
                    if (typ.IsPublic && typ.IsSubclassOf(typeRoot))
                        classes.Add(typ.Name, typ);

            // Create root item.
            TypeTreeViewItem item = new TypeTreeViewItem(typeRoot);
            Items.Add(item);

            // Call recursive method.
            CreateLinkedItems(item, classes);
        }
开发者ID:gawallsibya,项目名称:BIT_MFC-CShap-DotNet,代码行数:33,代码来源:ClassHierarchyTreeView.cs

示例12: lb_mvtypes_SelectedIndexChanged

 private void lb_mvtypes_SelectedIndexChanged(object sender, EventArgs e)
 {
     String t = lb_mvtypes.SelectedItem.ToString();
     PythonReader pr = null;
     if (t == "common") { pr = StaticDataHolder.Header_Common; }
     else if (t == "operations") { pr = StaticDataHolder.Header_Operations; }
     else if (t == "triggers") { pr = StaticDataHolder.Header_Triggers; }
     lb_mvnames.Items.Clear();
     SortedList<String, byte> tempsort = new SortedList<string, byte>();
     for (int j = 0; j < pr.Items.Length; ++j)
     {
         if (tempsort.ContainsKey(pr.Items[j].Name))
         {
             for (int k = 0; k < 100; ++k)
             {
                 if (!tempsort.ContainsKey(pr.Items[j].Name + "(" + k.ToString() + ")"))
                 {
                     tempsort.Add(pr.Items[j].Name + "(" + k.ToString() + ")", 0);
                     k = 100;
                 }
             }
         }
         else { tempsort.Add(pr.Items[j].Name, 0); }
     }
     foreach (KeyValuePair<String, byte> kvp in tempsort) { lb_mvnames.Items.Add(kvp.Key); }
 }
开发者ID:jpearce,项目名称:mbmodview,代码行数:26,代码来源:ConstantForm.cs

示例13: Form1

        public Form1()
        {
            InitializeComponent();

            for (int i = 0; i < table.Columns.Count; ++i)
            {
                contextMenuStrip2.Items.Add(table.Columns[i].HeaderText);

                contextMenuStrip2.Items[i].Name = table.Columns[i].Name;

                ((ToolStripMenuItem)contextMenuStrip2.Items[i]).Checked = table.Columns[i].Visible;
            }

            prevCat = new SortedList<string, int>();

            prevCat.Add(mensCategories.DropDownItems[0].Text, 0);
            for (int i = 1; i < mensCategories.DropDownItems.Count; ++i)
                prevCat.Add(mensCategories.DropDownItems[i].Text, Convert.ToInt32(mensCategories.DropDownItems[i - 1].Text));

            prevCat.Add(womensCategories.DropDownItems[0].Text, 0);
            for (int i = 1; i < womensCategories.DropDownItems.Count; ++i)
                prevCat.Add(womensCategories.DropDownItems[i].Text, Convert.ToInt32(womensCategories.DropDownItems[i - 1].Text));

            changed = false;
        }
开发者ID:ZzzoOk,项目名称:WilksTable,代码行数:25,代码来源:Form1.cs

示例14: LoadData

    private void LoadData()
    {
        // Create sorted list for drop down values
        var items = new SortedList<string, string>()
        {
            { GetString("smartsearch.indextype." + TreeNode.OBJECT_TYPE), TreeNode.OBJECT_TYPE },
            { GetString("smartsearch.indextype." + UserInfo.OBJECT_TYPE), UserInfo.OBJECT_TYPE },
            { GetString("smartsearch.indextype." + CustomTableInfo.OBJECT_TYPE_CUSTOMTABLE), CustomTableInfo.OBJECT_TYPE_CUSTOMTABLE },
            { GetString("smartsearch.indextype." + SearchHelper.CUSTOM_SEARCH_INDEX), SearchHelper.CUSTOM_SEARCH_INDEX },
            { GetString("smartsearch.indextype." + SearchHelper.DOCUMENTS_CRAWLER_INDEX), SearchHelper.DOCUMENTS_CRAWLER_INDEX },
            { GetString("smartsearch.indextype." + SearchHelper.GENERALINDEX), SearchHelper.GENERALINDEX },
        };

        // Allow forum only if forums module is available
        if ((ModuleManager.IsModuleLoaded(ModuleName.FORUMS)))
        {
            items.Add(GetString("smartsearch.indextype." + PredefinedObjectType.FORUM), PredefinedObjectType.FORUM);
        }

        // Allow on-line forms only if the module is available
        if ((ModuleManager.IsModuleLoaded(ModuleName.BIZFORM)))
        {
            items.Add(GetString("smartsearch.indextype." + SearchHelper.ONLINEFORMINDEX), SearchHelper.ONLINEFORMINDEX);
        }

        // Data bind DDL
        drpIndexType.DataSource = items;
        drpIndexType.DataValueField = "value";
        drpIndexType.DataTextField = "key";
        drpIndexType.DataBind();

        // Pre-select documents
        drpIndexType.SelectedValue = TreeNode.OBJECT_TYPE;
    }
开发者ID:kbuck21991,项目名称:kentico-blank-project,代码行数:34,代码来源:IndexTypeSelector.ascx.cs

示例15: Simple

        public void Simple()
        {
            var sortedList = new SortedList<int> { 5 };

            Assert.AreEqual(sortedList.Count, 1);

            sortedList.RemoveAt(0);

            Assert.AreEqual(sortedList.Count, 0);

            sortedList.Add(5);
            sortedList.Add(2);

            Assert.AreEqual(sortedList.Count, 2);
            sortedList.RemoveAt(1);

            Assert.AreEqual(sortedList.Count, 1);

            sortedList.Add(2);

            Assert.AreEqual(sortedList.Count, 2);
            sortedList.RemoveAt(0);

            Assert.AreEqual(sortedList.Count, 1);
        }
开发者ID:havok,项目名称:ngenerics,代码行数:25,代码来源:RemoveAt.cs


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