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


C# Collections.SortedList类代码示例

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


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

示例1: MatchSubstring

        private static Match[] MatchSubstring(string i_source, string i_matchPattern, bool i_uniqueMatch)
        {
            //<note> use RegexOptions.Multiline, otherwise it will treat the whole thing as 1 string
            Regex regex = new Regex(i_matchPattern, RegexOptions.Multiline);

            MatchCollection matchCollection = regex.Matches(i_source);

            Match[] result;
            if (!i_uniqueMatch)
            {
                result = new Match[matchCollection.Count];
                matchCollection.CopyTo(result, 0);
            }
            else
            {
                //<note> cannot use HashSet<Match> because each Match object is unique, even though they may have same value (string). Can use HashSet<string>
                //SortedList is more like sorted Dictionary<key, value>
                SortedList uniqueMatchCollection = new SortedList();
                foreach(Match match in matchCollection)
                {
                    if (!uniqueMatchCollection.ContainsKey(match.Value))
                    {
                        uniqueMatchCollection.Add(match.Value, match);
                    }
                }

                result = new Match[uniqueMatchCollection.Count];
                uniqueMatchCollection.Values.CopyTo(result, 0);     //<note> cannot use uniqueMatchCollection.CopyTo(...) since SortedList member is not type-match with destination array member
            }

            Console.WriteLine("Found {0} matches", result.Length);
            return result;
        }
开发者ID:hsn6,项目名称:csharp_cookbook,代码行数:33,代码来源:EnumerateMatches.cs

示例2: Scene

        //SpriteFont debugfont;
        public Scene(Game game)
            : base(game)
        {
            World = new World(new Vector2(0, 18));
            PhysicsDebug = new DebugViewXNA(World);
            InputManager = new InputManager(Game);
            Transitioner = new Transitioner(Game, this);
            #if !FINAL_RELEASE
            SelectionManager = new SelectionManager(Game, this);
            #endif
            SceneLoader = new SceneLoader(Game);
            Camera = new Camera(Game, this);
            GarbageElements = new SortedList<Element>();
            RespawnElements = new SortedList<Element>();
            Elements = new SortedList<Element>();

            PhysicsDebug.Enabled = false;
            SelectionManager.ShowEmblems = false;
            Kinect.ColorStream.Enable();
            Kinect.DepthStream.Enable();
            Kinect.SkeletonStream.Enable();
            Kinect.Start();

            //SelectionManager.ShowForm = false;
        }
开发者ID:MartinMcGuinness,项目名称:TheLastDawn,代码行数:26,代码来源:Scene.cs

示例3: ComputeTrendTest

        public void ComputeTrendTest(SortedList<int, double> years, int currentYear)
        {
            var map = new ExtractValuesForIndicatorsMapper();
            var data = new SortedList<int, double>();
            double[] inflationVal ={100.764370305146,104.476042578907,
            164.776810573524,343.810676313218,626.718592068498,672.180651051974,
            90.0966050749321,131.327020980362,342.955110191569,3079.8097030531,
            2313.96466339751,171.671696468307,24.8999485988254,10.6114940961306,
            4.17734724367,3.37611684980121,0.155695900742245,0.527258257063252
            ,0.920336467095566,-1.16689546970002,-0.935939411978723,-1.06663550777849,
            25.8684978656633,13.4428492915644,4.41571792341912,9.63939954620811,
            10.901124534884,
            8.83141298885049};
            int length = inflationVal.Count();

            int year = 2007;
            for (int i = length - 1; i >= 0; i--)
            {
                data.Add(year, inflationVal[i]);
                year--;
            }
            Assert.IsTrue( map.ComputeTrend(data, 1998)<1);
            Assert.IsTrue( map.ComputeTrend(data, 1999)<1);
            Assert.IsTrue( map.ComputeTrend(data, 2000)<1);
            Assert.IsTrue( map.ComputeTrend(data, 2001)<1);
             Assert.IsTrue(map.ComputeTrend(data, 2002)>1);
            Assert.IsTrue(map.ComputeTrend(data, 2003)>1);
            
        }
开发者ID:abhaymise,项目名称:Hadoop-Analysis,代码行数:29,代码来源:UnitTest1.cs

示例4: RowRecordsAggregate

 private RowRecordsAggregate(SharedValueManager svm)
 {
     _rowRecords = new SortedList();
     _valuesAgg = new ValueRecordsAggregate();
     _unknownRecords = new ArrayList();
     _sharedValueManager = svm;
 }
开发者ID:ChiangHanLung,项目名称:PIC_VDS,代码行数:7,代码来源:RowRecordsAggregate.cs

示例5: TestConstructor3

		public void TestConstructor3 ()
		{
			Hashtable d = new Hashtable ();
			d.Add ("one", "Mircosoft");
			d.Add ("two", "will");
			d.Add ("three", "rule");
			d.Add ("four", "the world");

			SortedList temp1 = new SortedList (d);
			Assert.IsNotNull (temp1, "#A1");
			Assert.AreEqual (4, temp1.Capacity, "#A2");
			Assert.AreEqual (4, temp1.Count, "#A3");

			try {
				new SortedList ((Hashtable) null);
				Assert.Fail ("#B");
			} catch (ArgumentNullException) {
			}

			try {
				d = new Hashtable ();
				d.Add ("one", "Mircosoft");
				d.Add ("two", "will");
				d.Add ("three", "rule");
				d.Add ("four", "the world");
				d.Add (7987, "lkj");
				new SortedList (d);
				Assert.Fail ("#C");
			} catch (InvalidOperationException) {
			}
		}
开发者ID:ItsVeryWindy,项目名称:mono,代码行数:31,代码来源:SortedListTest.cs

示例6: ThemeProvider

 public ThemeProvider(IDesignerHost host, string name, string themeDefinition, string[] cssFiles, string themePath)
 {
     this._themeName = name;
     this._themePath = themePath;
     this._cssFiles = cssFiles;
     this._host = host;
     ControlBuilder builder = DesignTimeTemplateParser.ParseTheme(host, themeDefinition, themePath);
     this._contentHashCode = themeDefinition.GetHashCode();
     ArrayList subBuilders = builder.SubBuilders;
     this._skinBuilders = new Hashtable();
     for (int i = 0; i < subBuilders.Count; i++)
     {
         ControlBuilder builder2 = subBuilders[i] as ControlBuilder;
         if (builder2 != null)
         {
             IDictionary dictionary = this._skinBuilders[builder2.ControlType] as IDictionary;
             if (dictionary == null)
             {
                 dictionary = new SortedList(StringComparer.OrdinalIgnoreCase);
                 this._skinBuilders[builder2.ControlType] = dictionary;
             }
             Control control = builder2.BuildObject() as Control;
             if (control != null)
             {
                 dictionary[control.SkinID] = builder2;
             }
         }
     }
 }
开发者ID:pritesh-mandowara-sp,项目名称:DecompliedDotNetLibraries,代码行数:29,代码来源:ThemeProvider.cs

示例7: EventStreamSlice

 private EventStreamSlice()
 {
     m_streamPosition = EventStreamPosition.Start;
     m_events = new SortedList<StreamVersion, JournaledEvent>(0);
     m_endOfStream = true;
     m_currentSlicePosition = EventStreamPosition.Start;
 }
开发者ID:savamura,项目名称:Journalist,代码行数:7,代码来源:EventStreamSlice.cs

示例8: Button

        public Button()
        {
            this.m_bNoScalingOnSetRect = true;
            Name = "Button";
            this.MouseActive = true;
            m_plStateSprites = new SortedList();

            Frame spFrame = new Frame();
            spFrame.Parent = this;
            spFrame.Member = new MemberSpriteBitmap("Button2Up");
            spFrame.Ink = RasterOps.ROPs.BgTransparent;
            spFrame.Member.ColorKey = Color.FromArgb(0,0,0);
            spFrame.Rect = new ERectangleF(0,0,50,50);
            m_plStateSprites.Add(Sprite.MouseEventType.Leave, (Sprite)spFrame);

            spFrame = new Frame();
            spFrame.Parent = this;
            spFrame.Member = new MemberSpriteBitmap("Button2Down");
            spFrame.Ink = RasterOps.ROPs.BgTransparent;
            spFrame.Member.ColorKey = Color.FromArgb(0,0,0);
            spFrame.Rect = new ERectangleF(0,0,50,50);
            m_plStateSprites.Add(Sprite.MouseEventType.Enter, (Sprite)spFrame);

            for (int i = 0; i < m_plStateSprites.Count; i++)
            {
                ((Sprite)m_plStateSprites.GetByIndex(i)).Visible = false;
            }
            ((Sprite)m_plStateSprites[MouseEventType.Leave]).Visible = true;
        }
开发者ID:timdetering,项目名称:Endogine,代码行数:29,代码来源:Button.cs

示例9: btnSave_Click

        void btnSave_Click(object sender, EventArgs e)
        {
            SortedList sl = new SortedList();

            Qry = "delete from Unit_master where UnitGroupName='" + cboUnitType.Text + "'";
            sl.Add(sl.Count + 1, Qry);

            for (int i = 0; i < dgvInfo.Rows.Count - 1; i++)
            {
                Qry = "INSERT INTO [dbo].[Unit_Master] " +
                      " ([UnitGroupName]" +
                      " ,[UnitID]" +
                      " ,[UnitName]" +
                      " ,[RelativeFactor]" +
                      " ,[IsBaseUOM]" +
                      " ,[AddedBy]" +
                      " ,[DateAdded])" +
                 " VALUES " +
                       " ('" + cboUnitType.Text + "'," +
                       "'" + dgvInfo.Rows[i].Cells[0].Value.ToString() + "'," +
                      "'" + dgvInfo.Rows[i].Cells[1].Value.ToString() + "'," +
                       "" + dgvInfo.Rows[i].Cells[2].Value.ToString() + "," +
                       "'" + Convert.ToBoolean(dgvInfo.Rows[i].Cells[3].Value) + "'," +
                      "'" + LoginSession.UserID + "',getdate())";
                sl.Add(sl.Count + 1, Qry);
            }

            DbUtility.ExecuteQuery(sl, "");
            MessageBox.Show("Saved");
        }
开发者ID:Rakibxl,项目名称:cureDBrakib,代码行数:30,代码来源:FrmUnitConversion.cs

示例10: Type2CIDFont

        /// <summary>
        ///     Class constructor.
        /// </summary>
        /// <param name="properties"></param>
        public Type2CIDFont(FontProperties properties) {
            this.properties = properties;
            this.baseFontName = properties.FaceName.Replace(" ", "-");
            this.usedGlyphs = new SortedList();

            ObtainFontMetrics();
        }
开发者ID:nholik,项目名称:Fo.Net,代码行数:11,代码来源:Type2CIDFont.cs

示例11: TemplateCollection

 public TemplateCollection()
 {
   eX4XcIhHpDXt70u2x3N.k8isAcYzkUOGF();
   // ISSUE: explicit constructor call
   base.\u002Ector();
   this.aJ8duHpkdC = new SortedList();
 }
开发者ID:heber,项目名称:FreeOQ,代码行数:7,代码来源:TemplateCollection.cs

示例12: ExecuteSclrBySP

        public string ExecuteSclrBySP(string sp, SortedList sl)
        {
            string err = string.Empty;
            string returnSclr = "-1";

            SqlConnection con = new SqlConnection(DbConnStr);
            SqlCommand cmd = new SqlCommand(sp, con);

            cmd.CommandType = CommandType.StoredProcedure;

            foreach (DictionaryEntry entry in sl)
            {
                cmd.Parameters.Add(new SqlParameter(entry.Key.ToString(), entry.Value));
            }

            try
            {
                con.Open();
                returnSclr = Convert.ToString(cmd.ExecuteScalar());

            }
            catch (Exception ex)
            {
                err = ex.Message;
            }
            finally
            {
                con.Close();
            }

            return returnSclr;
        }
开发者ID:nganbui,项目名称:SP,代码行数:32,代码来源:DataLayer.cs

示例13: ServerDBQuery

        public DataSet ServerDBQuery(string strProcName, DataSet dsIN)
        {
            try
            {
                SortedList SDList = new SortedList();
                if (dsIN.Tables.Count > 0 && dsIN.Tables[0].Rows.Count > 0)
                {
                    DataRow dR = dsIN.Tables[0].Rows[0];
                    for (int i = 0; i < dsIN.Tables[0].Columns.Count; i++)
                    {
                        SDList[dsIN.Tables[0].Columns[i].ColumnName] = dR[i];
                    }
                }
                return WSBDB.proGetDS(SDList, strProcName);
            }
            catch (Exception Ex)
            {
                #region 错误日志
                string strSDList = "";
                if (dsIN.Tables.Count > 0 && dsIN.Tables[0].Rows.Count > 0)
                {
                    DataRow dR = dsIN.Tables[0].Rows[0];
                    for (int i = 0; i < dsIN.Tables[0].Columns.Count; i++)
                    {
                        strSDList += dsIN.Tables[0].Columns[i].ColumnName + ":" + dR[i] + "$";
                    }
                }
                string strErrEx = "出现未知错误,请联系系统管理员查询日志,方法" + strProcName + "参数:" + strSDList + "错误ID:" + Guid.NewGuid().ToString();
                WSBDB.txtSaveErro(strErrEx + ":" + Ex.ToString());
                #endregion

                return null;
            }
        }
开发者ID:trloveu,项目名称:che9app,代码行数:34,代码来源:CHE9000.asmx.cs

示例14: FindSubstrings

        public static Match[] FindSubstrings(string source, string matchPattern, bool findAllUnique)
        {
            SortedList uniqueMatches = new SortedList();
            Match[] retArray = null;

            Regex RE = new Regex(matchPattern, RegexOptions.Multiline);
            MatchCollection theMatches = RE.Matches(source);

            if (findAllUnique)
            {
                for (int counter = 0; counter < theMatches.Count; counter++)
                {
                    if (!uniqueMatches.ContainsKey(theMatches[counter].Value))
                    {
                        uniqueMatches.Add(theMatches[counter].Value,
                                          theMatches[counter]);
                    }
                }

                retArray = new Match[uniqueMatches.Count];
                uniqueMatches.Values.CopyTo(retArray, 0);
            }
            else
            {
                retArray = new Match[theMatches.Count];
                theMatches.CopyTo(retArray, 0);
            }

            return (retArray);
        }
开发者ID:peeboo,项目名称:open-media-library,代码行数:30,代码来源:NetFlixDb.cs

示例15: TargetSelectorCallback

 protected void TargetSelectorCallback(Address start, SortedList score_table, Address current) {
   Assert.IsTrue(score_table.Count > 0);
   if (current == null) {
     Address min_target = (Address) score_table.GetByIndex(0);
     Assert.AreEqual(_addr_list[_idx++], min_target);
   }
 }
开发者ID:pstjuste,项目名称:brunet,代码行数:7,代码来源:TargetSelector.cs


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