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


C# SortedList.Contains方法代码示例

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


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

示例1: calculateMatchRate

 //return how closely an input string resembles a single memory entry
 protected int calculateMatchRate(ArrayList input, ArrayList memory)
 {
     int matchRate = 0;
     IEnumerator i = input.GetEnumerator();
     IEnumerator m = memory.GetEnumerator();
     while(i.MoveNext())
     {
         while(m.MoveNext())
         {
             SortedList isNewWord = new SortedList();
             string cc = (string)i.Current;
             string bb = (string)m.Current;
             cc.ToLower();
             bb.ToLower();
             //mehrfachwertung für ein wort vermeiden z.b. eine 3 für 3x "ich"
             if(!isNewWord.Contains(bb))
             {
                 isNewWord.Add(bb, bb);
                 if(cc == bb)
                 {
                     matchRate++;
                 }
             }
             isNewWord.Clear();
         }
     }
     return matchRate;
 }
开发者ID:sanyaade-g2g-repos,项目名称:prelude-csharp,代码行数:29,代码来源:StringBase.cs

示例2: GetMxRecordsFromAnswers

        /// <summary>
        /// Gets MX records from answer collection and ORDERS them by preference.
        /// NOTE: Duplicate preference records are appended to end. 
        /// </summary>
        /// <returns></returns>
        internal MX_Record[] GetMxRecordsFromAnswers()
        {
            MX_Record[] retVal = null;

            try
            {
                SortedList mx            = new SortedList();
                ArrayList  duplicateList = new ArrayList();
                foreach(Dns_Answer answer in m_Answers){
                    if(answer.QTYPE == QTYPE.MX){
                        MX_Record mxRec = (MX_Record)answer.RecordObj;

                        if(!mx.Contains(mxRec.Preference)){
                            mx.Add(mxRec.Preference,mxRec);
                        }
                        else{
                            duplicateList.Add(mxRec);
                        }
                    }
                }

                MX_Record[] mxBuff = new MX_Record[mx.Count + duplicateList.Count];
                mx.Values.CopyTo(mxBuff,0);
                duplicateList.CopyTo(mxBuff,mx.Count);
                retVal = mxBuff;
            }
            catch{
            }

            return retVal;
        }
开发者ID:janemiceli,项目名称:authenticated_mail_server,代码行数:36,代码来源:Dns_Answers.cs

示例3: TestGetIsSynchronizedBasic

        public void TestGetIsSynchronizedBasic()
        {
            SortedList slst1;
            string strValue;

            Task[] workers;
            Action ts1;
            int iNumberOfWorkers = 3;

            // Vanila test case - Synchronized returns an IList that is thread safe
            // We will try to test this by getting a number of threads to write some items
            // to a synchronized IList
            slst1 = new SortedList();
            _slst2 = SortedList.Synchronized(slst1);

            workers = new Task[iNumberOfWorkers];
            for (int i = 0; i < workers.Length; i++)
            {
                var name = "Thread worker " + i;
                ts1 = new Action(() => AddElements(name));
                workers[i] = Task.Run(ts1);
            }

            Task.WaitAll(workers);

            //checking time
            Assert.Equal(_slst2.Count, _iNumberOfElements * iNumberOfWorkers);

            for (int i = 0; i < iNumberOfWorkers; i++)
            {
                for (int j = 0; j < _iNumberOfElements; j++)
                {
                    strValue = "Thread worker " + i + "_" + j;
                    Assert.True(_slst2.Contains(strValue), "Error, Expected value not returned, " + strValue);
                }
            }

            // We can't make an assumption on the order of these items though
            //now we are going to remove all of these
            workers = new Task[iNumberOfWorkers];
            for (int i = 0; i < workers.Length; i++)
            {
                var name = "Thread worker " + i;
                ts1 = new Action(() => RemoveElements(name));
                workers[i] = Task.Run(ts1);
            }

            Task.WaitAll(workers);

            Assert.Equal(0, _slst2.Count);

            // we will check IsSynchronized now
            Assert.False(slst1.IsSynchronized);
            Assert.True(_slst2.IsSynchronized);
        }
开发者ID:johnhhm,项目名称:corefx,代码行数:55,代码来源:PropertyIsSynchronizedTests.cs

示例4: CreateIE

 // name - имя инф. элемента
 // listIE - список сущ. инф. элементов
 private Element CreateIE(string name, SortedList allIE)
 {
     Element ie = null;
     if (!allIE.Contains(name))
     {
         ie = new Element(name);
         allIE.Add(name, ie);
     }
     else ie = (Element)allIE[name];
     return ie;
 }
开发者ID:antonchaika,项目名称:SearchingPeople.com,代码行数:13,代码来源:Converter.cs

示例5: TestSynchronizedBasic

        public void TestSynchronizedBasic()
        {
            SortedList slst1;
            String strValue;

            Task[] workers;
            Action ts1;
            Int32 iNumberOfWorkers = 3;

            slst1 = new SortedList();
            _slst2 = SortedList.Synchronized(slst1);

            workers = new Task[iNumberOfWorkers];
            for (int i = 0; i < workers.Length; i++)
            {
                var name = "Thread worker " + i;
                ts1 = new Action(() => AddElements(name));
                workers[i] = Task.Run(ts1);
            }

            Task.WaitAll(workers);

            //checking time

            Assert.Equal(_slst2.Count, _iNumberOfElements * iNumberOfWorkers);


            for (int i = 0; i < iNumberOfWorkers; i++)
            {
                for (int j = 0; j < _iNumberOfElements; j++)
                {
                    strValue = "Thread worker " + i + "_" + j;

                    Assert.True(_slst2.Contains(strValue), "Error, Expected value not returned, " + strValue);
                }
            }

            //I dont think that we can make an assumption on the order of these items though
            //now we are going to remove all of these
            workers = new Task[iNumberOfWorkers];
            for (int i = 0; i < workers.Length; i++)
            {
                var name = "Thread worker " + i;
                ts1 = new Action(() => RemoveElements(name));
                workers[i] = Task.Run(ts1);
            }

            Task.WaitAll(workers);

            Assert.Equal(0, _slst2.Count);
            Assert.False(slst1.IsSynchronized);
            Assert.True(_slst2.IsSynchronized);
        }
开发者ID:johnhhm,项目名称:corefx,代码行数:53,代码来源:SynchronizedTests.cs

示例6: TestGetIsReadOnlyBasic

        public void TestGetIsReadOnlyBasic()
        {
            String strValue;
            SortedList dic1;

            dic1 = new SortedList();
            for (int i = 0; i < 10; i++)
            {
                strValue = "String_" + i;
                dic1.Add(i, strValue);
            }

            for (int i = 0; i < 10; i++)
            {
                Assert.True(dic1.Contains(i));
            }

            //we'll do the ReadOnly test
            Assert.False(dic1.IsReadOnly);

            //we'll make sure by doing a modifiable things!!
            dic1.Remove(0);
            Assert.False(dic1.Contains(0));
        }
开发者ID:johnhhm,项目名称:corefx,代码行数:24,代码来源:PropertyIsReadOnlyTests.cs

示例7: BuildTextCache

        public static IDictionary BuildTextCache( TreeNode[] array )
        {
            IDictionary dict = new SortedList();

              foreach( TreeNode node in array )
              {
            if( dict.Contains( node.Text ) == false )
            {
              dict[ node.Text ] = new ArrayList();
            }

            ((IList)dict[ node.Text ]).Add( node );
              }

              return dict;
        }
开发者ID:tiankongldp,项目名称:MyTestApplication,代码行数:16,代码来源:TreeViewUtils.cs

示例8: BuildTagsCache

        /// <summary>
        /// Build TreeNodes caches for fast find and update
        /// </summary>
        public static IDictionary BuildTagsCache( TreeNode[] array )
        {
            IDictionary dict = new SortedList();

              foreach( TreeNode node in array )
              {
            int indexTag = ( node.Tag == null ) ? -1 : node.Tag.GetHashCode();

            if( dict.Contains( indexTag ) == false )
            {
              dict[ indexTag ] = new ArrayList();
            }

            ((IList)dict[ indexTag ]).Add( node );
              }

              return dict;
        }
开发者ID:tiankongldp,项目名称:MyTestApplication,代码行数:21,代码来源:TreeViewUtils.cs

示例9: IsSimple

		/// <summary>
		/// Tests if MultiPoint is simple.
		/// </summary>
		/// <param name="mp">Geometry to test.  Must be of type MultiPoint.</param>
		/// <returns>Returns True if geometry is simple.</returns>
		/// <remarks>A MultiPoint is simple if and only if it has no repeated points.</remarks>
		public bool IsSimple( MultiPoint mp )
		{
			if ( mp.IsEmpty() )
			{
				return true;
			}
			SortedList points = new SortedList();
			for ( int i = 0; i < mp.GetNumGeometries(); i++ ) 
			{
				Point pt = (Point) mp.GetGeometryN( i );
				Coordinate p = pt.GetCoordinate();
				if ( points.Contains( p ) )
				{
					return false;
				}
				points.Add( p, p );
			} //for ( int i = 0; i < mp.NumGeometries; i++ )
			return true;
		} // public bool IsSimple( MultiPoint mp )
开发者ID:xuchuansheng,项目名称:GenXSource,代码行数:25,代码来源:IsSimpleOp.cs

示例10: Main

        static void Main(string[] args)
        {
            SortedList mySL = new SortedList();
            mySL.Add("One", "1");
            mySL.Add("Two", "2");
            mySL.Add("Three", "3");

            // Result will be displayed in sorted order as all keys are auto stored in sorted order
            System.Console.WriteLine("KEY\tVALUE");
            System.Console.WriteLine("---\t-----");
            for (int i = 0; i < mySL.Count; i++)
            {
                System.Console.WriteLine("{0}\t{1}", mySL.GetKey(i), mySL.GetByIndex(i));
            }
            System.Console.WriteLine("\nCapacity of this SortedList: {0}", mySL.Capacity);
            System.Console.WriteLine("Does this SortedList contain \"One\" as key: {0}", mySL.Contains("One"));
            System.Console.WriteLine("Number of objects presently in this SortedList: {0}", mySL.Count);
            System.Console.ReadLine();
        }
开发者ID:anuragbhd,项目名称:code,代码行数:19,代码来源:Program.cs

示例11: CandidateTest

 private void CandidateTest(Element ie, int index, SortedList subject, SortedList candidate)
 {
     if (subject.Contains(ie.Name)) return;
     if (!candidate.Contains(ie.Name))
     {
         // Если ie еще нет в списке кандидатов
         IE_Index ie_index = new IE_Index(ie);
         ie_index.Index.Add(index, 0);
         candidate.Add(ie.Name, ie_index);
     }
     else
     {
         // Если ie уже существует в списке кандидатов
         IE_Index ie_index = ((IE_Index)candidate[ie.Name]);
         // Проверяем не было ли ie с таким же инексом 
         // (т.е. не встречали ли мы его в данном индексе потока)
         if (!ie_index.Index.Contains(index))
             ie_index.Index.Add(index, 0);
     }
 }
开发者ID:antonchaika,项目名称:SearchingPeople.com,代码行数:20,代码来源:Searcher.cs

示例12: JoinUnique

 public static string JoinUnique(string delimiter, params string[][] fragmentArrays)
 {
     SortedList list = new SortedList();
     foreach (string[] fragmentArray in fragmentArrays)
     {
         foreach (string fragment in fragmentArray)
         {
             if (! list.Contains(fragment))
                 list.Add(fragment, fragment);
         }
     }
     StringBuilder buffer = new StringBuilder();
     foreach (string value in list.Values)
     {
         if (buffer.Length > 0)
         {
             buffer.Append(delimiter);
         }
         buffer.Append(value);
     }
     return buffer.ToString();
 }
开发者ID:vardars,项目名称:ci-factory,代码行数:22,代码来源:StringUtil.cs

示例13: VerifyResourceNames

 private static SortedList VerifyResourceNames(Dictionary<string, ResourceData> resourceList, CodeDomProvider codeProvider, ArrayList errors, out Hashtable reverseFixupTable)
 {
     reverseFixupTable = new Hashtable(0, StringComparer.InvariantCultureIgnoreCase);
     SortedList list = new SortedList(StringComparer.InvariantCultureIgnoreCase, resourceList.Count);
     foreach (KeyValuePair<string, ResourceData> pair in resourceList)
     {
         string key = pair.Key;
         if ((string.Equals(key, "ResourceManager") || string.Equals(key, "Culture")) || (typeof(void) == pair.Value.Type))
         {
             errors.Add(key);
         }
         else
         {
             if (((key.Length <= 0) || (key[0] != '$')) && (((key.Length <= 1) || (key[0] != '>')) || (key[1] != '>')))
             {
                 if (!codeProvider.IsValidIdentifier(key))
                 {
                     string str2 = VerifyResourceName(key, codeProvider, false);
                     if (str2 == null)
                     {
                         errors.Add(key);
                         goto Label_0185;
                     }
                     string item = (string) reverseFixupTable[str2];
                     if (item != null)
                     {
                         if (!errors.Contains(item))
                         {
                             errors.Add(item);
                         }
                         if (list.Contains(str2))
                         {
                             list.Remove(str2);
                         }
                         errors.Add(key);
                         goto Label_0185;
                     }
                     reverseFixupTable[str2] = key;
                     key = str2;
                 }
                 ResourceData data = pair.Value;
                 if (!list.Contains(key))
                 {
                     list.Add(key, data);
                 }
                 else
                 {
                     string str4 = (string) reverseFixupTable[key];
                     if (str4 != null)
                     {
                         if (!errors.Contains(str4))
                         {
                             errors.Add(str4);
                         }
                         reverseFixupTable.Remove(key);
                     }
                     errors.Add(pair.Key);
                     list.Remove(key);
                 }
             }
         Label_0185:;
         }
     }
     return list;
 }
开发者ID:pritesh-mandowara-sp,项目名称:DecompliedDotNetLibraries,代码行数:65,代码来源:StronglyTypedResourceBuilder.cs

示例14: SetupPrint


//.........这里部分代码省略.........

            // rows to print (handles "selection" and "current page" options
            if (PrintRange.Selection == printRange)
            {
                // if DGV has rows selected, it's easy, selected rows and all visible columns
                if (0 != dgv.SelectedRows.Count)
                {
                    rowstoprint = dgv.SelectedRows;
                    colstoprint = new List<object>(dgv.Columns.Count);
                    foreach (DataGridViewColumn col in dgv.Columns) if (col.Visible) colstoprint.Add(col);
                }
                // if selected columns, then all rows, and selected columns
                else if (0 != dgv.SelectedColumns.Count)
                {
                    rowstoprint = dgv.Rows;
                    colstoprint = dgv.SelectedColumns;
                }
                // we just have a bunch of selected cells so we have to do some work
                else
                {
                    // set up sorted lists. the selectedcells method does not guarantee
                    // that the cells will always be in left-right top-bottom order. 
                    SortedList temprowstoprint = new SortedList(dgv.SelectedCells.Count);
                    SortedList tempcolstoprint = new SortedList(dgv.SelectedCells.Count);

                    // for each selected cell, add unique rows and columns
                    int colindex, rowindex;
                    foreach (DataGridViewCell cell in dgv.SelectedCells)
                    {
                        colindex = cell.ColumnIndex;
                        rowindex = cell.RowIndex;

                        // add unique rows
                        if (!temprowstoprint.Contains(rowindex))
                            temprowstoprint.Add(rowindex, dgv.Rows[rowindex]);

                        // add unique columns
                        if (!tempcolstoprint.Contains(colindex))
                            tempcolstoprint.Add(colindex, dgv.Columns[colindex]);
                    }

                    // Move the now-duplicate free columns and rows to our list of what to print
                    rowstoprint = new List<object>(temprowstoprint.Count);
                    foreach (object item in temprowstoprint.Values) rowstoprint.Add(item);
                    colstoprint = new List<object>(tempcolstoprint.Count);
                    foreach (object item in tempcolstoprint.Values) colstoprint.Add(item);
                }
            }
            // if current page was selected, print visible columns for the
            // displayed rows                
            else if (PrintRange.CurrentPage == printRange)
            {
                // create lists
                rowstoprint = new List<object>(dgv.DisplayedRowCount(true));
                colstoprint = new List<object>(dgv.Columns.Count);

                // select all visible rows on displayed page
                for (int i = dgv.FirstDisplayedScrollingRowIndex;
                    i < dgv.FirstDisplayedScrollingRowIndex + dgv.DisplayedRowCount(true);
                    i++)
                {
                    DataGridViewRow row = dgv.Rows[i];
                    if (row.Visible) rowstoprint.Add(row);
                }

                // select all visible columns
开发者ID:softballsolutions,项目名称:softballsolutions.Forms,代码行数:67,代码来源:sbDataGridPrinter.cs

示例15: Read


//.........这里部分代码省略.........
							// Read element
							reader.Read();
							if(reader.Depth == d)
								break;

							name = reader.Name;
							// Read the value
							reader.Read();

							switch(name)
							{
								case "ForeColor":
									fore = XmlConvert.ToColor(reader.Value);
									break;
								case "BackColor":
									back = XmlConvert.ToColor(reader.Value);
									break;
								case "Style":
									style = (HatchStyle)XmlConvert.ToEnum(
										typeof(HatchStyle), reader.Value);
									break;
							}

							// Read the closing element
							reader.Read();

							brush = new FlowChartX.HatchBrush(
								style, fore, back);
						}
					}
						break;
				}

				if(!brushes.Contains(id) && brush != null)
					brushes.Add(id, brush);
			}

			// Read the brushes closing element
			if(count > 0)
				reader.Read();

			ReadMandatory(reader, "Environment",
				"Environment element missing or invalid");

			// Read all appearance properties
			ReadMandatory(reader, "Appearance",
				"Appearance element missing or invalid");
			if(!ReadProperties(reader, _diagram, reader.Depth + 1))
				throw new InvalidFormatException("Unexpected " +
					"EOF in the Appearance section");

			// Read all bahaviour properties
			ReadMandatory(reader, "Behaviour",
				"Behaviour element missing or invalid");
			if(!ReadProperties(reader, _diagram, reader.Depth + 1))
				throw new InvalidFormatException("Unexpected " +
					"EOF in the Behaviour section");

			// Read all default properties
			ReadMandatory(reader, "Defaults",
				"Defaults element missing or invalid");
			if(!ReadProperties(reader, _diagram, reader.Depth + 1))
				throw new InvalidFormatException("Unexpected " +
					"EOF in the Defaults section");

			// Read default brushes and pens
开发者ID:ChrisMoreton,项目名称:Test3,代码行数:67,代码来源:XmlReader.cs


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