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


C# System.Collections.ArrayList.GetEnumerator方法代码示例

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


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

示例1: sort

 /// <summary> Sorts the rings in the set by size. The largest ring comes
 /// first.
 /// </summary>
 public static void sort(IRingSet ringSet)
 {
     System.Collections.IList ringList = new System.Collections.ArrayList();
     IAtomContainer[] rings = ringSet.AtomContainers;
     for (int i = 0; i < rings.Length; i++)
     {
         ringList.Add(rings[i]);
     }
     SupportClass.CollectionsSupport.Sort(ringList, new RingSizeComparator(RingSizeComparator.LARGE_FIRST));
     ringSet.removeAllAtomContainers();
     System.Collections.IEnumerator iter = ringList.GetEnumerator();
     //UPGRADE_TODO: Method 'java.util.Iterator.hasNext' was converted to 'System.Collections.IEnumerator.MoveNext' which has a different behavior. "ms-help://MS.VSCC.v80/dv_commoner/local/redirect.htm?index='!DefaultContextWindowIndex'&keyword='jlca1073_javautilIteratorhasNext'"
     while (iter.MoveNext())
     {
         //UPGRADE_TODO: Method 'java.util.Iterator.next' was converted to 'System.Collections.IEnumerator.Current' which has a different behavior. "ms-help://MS.VSCC.v80/dv_commoner/local/redirect.htm?index='!DefaultContextWindowIndex'&keyword='jlca1073_javautilIteratornext'"
         ringSet.addAtomContainer((IRing)iter.Current);
     }
 }
开发者ID:xuchuansheng,项目名称:GenXSource,代码行数:21,代码来源:RingSetManipulator.cs

示例2: EnumerateCache

        static private AssemblyInformation EnumerateCache(String partialName)
        {
            ArrayList                       a = new ArrayList();
            AssemblyInformation             ainfo;
            AssemblyInformation             ainfoHighest = new AssemblyInformation();

            partialName = StripVersionFromAssemblyString(partialName);
            Fusion.ReadCache(a, partialName, ASM_CACHE.GAC);
            
            IEnumerator myEnum = a.GetEnumerator();
            while (myEnum.MoveNext()) {
                ainfo = (AssemblyInformation) myEnum.Current;
                if (ainfoHighest.Version == null) {
                    // Use the first valid version number
                    string[]  astrVer1 = ainfo.Version.Split('.');
                    if(astrVer1.Length == 4)
                        ainfoHighest = ainfo;
                }
                else {
                    int compare = 0;
                    if (CompareVersionString(ainfo.Version, ainfoHighest.Version, ref compare) == 0 &&
                        compare > 0)
                        ainfoHighest = ainfo;
                }
            }
            return ainfoHighest;
        }
开发者ID:ArildF,项目名称:masters,代码行数:27,代码来源:assembly.cs

示例3: testFiveSharedNodes

 /// <summary> test the performance with 50 facts and 5 rules. The test measures
 /// the load, assert and fire time.
 /// </summary>
 public virtual void testFiveSharedNodes()
 {
     try
     {
         int factCount = 5000;
         string file = "20rules_2CE_5shared.drl";
         int loop = 5;
         long totalload = 0;
         long totalassert = 0;
         long totalfire = 0;
         long aveloadmem = 0;
         long aveassertmem = 0;
         System.Diagnostics.Process rt = System.Diagnostics.Process.GetCurrentProcess();
         for (int c = 0; c < loop; c++)
         {
             System.GC.Collect();
             //long memt1 = rt.totalMemory();
             //long memf1 = rt.freeMemory();
             //long used1 = memt1 - memf1;
             long loadStart = (System.DateTime.Now.Ticks - 621355968000000000) / 10000;
             RuleBase ruleBase = readRule(file);
             long loadEnd = (System.DateTime.Now.Ticks - 621355968000000000) / 10000;
             //long memt2 = rt.totalMemory();
             //long memf2 = rt.freeMemory();
             //long used2 = memt2 - memf2;
             long loadet = loadEnd - loadStart;
             System.GC.Collect();
             totalload += loadet;
             //aveloadmem += (used2 - used1);
             System.Console.Out.WriteLine("time to load " + file + " " + loadet + "ms");
             //System.Console.Out.WriteLine("load memory used " + ((used2 - used1) / 1024) + " kb");
             WorkingMemory workingMemory = ruleBase.NewWorkingMemory();
             System.Collections.ArrayList objects = new System.Collections.ArrayList();
             Account acc = new Account();
             acc.Status = "standard";
             objects.Add(acc);
             // create the objects
             for (int idx = 0; idx < factCount; idx++)
             {
                 Address addr = new Address();
                 addr.City = "boston";
                 addr.State = "ma";
                 addr.HouseType = "single family";
                 addr.Status = "not listed";
                 addr.Country = "usa";
                 addr.AccountId = "acc" + idx;
                 objects.Add(addr);
             }
             System.Collections.IEnumerator itr = objects.GetEnumerator();
             //long memt3 = rt.totalMemory();
             //long memf3 = rt.freeMemory();
             //long used3 = memt3 - memf3;
             long assertStart = (System.DateTime.Now.Ticks - 621355968000000000) / 10000;
             while (itr.MoveNext())
             {
                 workingMemory.assertObject(itr.Current);
             }
             long assertEnd = (System.DateTime.Now.Ticks - 621355968000000000) / 10000;
             //long memt4 = rt.totalMemory();
             //long memf4 = rt.freeMemory();
             //long used4 = memt4 - memf4;
             long assertet = assertEnd - assertStart;
             totalassert += assertet;
             //aveassertmem += (used4 - used3);
             System.Console.Out.WriteLine("time to assert " + assertet + " ms");
             //System.Console.Out.WriteLine("assert memory used " + ((used4 - used3) / 1024) + " kb");
             long fireStart = (System.DateTime.Now.Ticks - 621355968000000000) / 10000;
             workingMemory.fireAllRules();
             long fireEnd = (System.DateTime.Now.Ticks - 621355968000000000) / 10000;
             long fireet = fireEnd - fireStart;
             totalfire += fireet;
             System.Console.Out.WriteLine("time to fireAllRules " + fireet + " ms");
             workingMemory.dispose();
             System.GC.Collect();
             System.Console.Out.WriteLine("");
         }
         System.Console.Out.WriteLine(file);
         System.Console.Out.WriteLine("number of objects asserted " + factCount);
         System.Console.Out.WriteLine("average load " + (totalload / loop) + " ms");
         //System.Console.Out.WriteLine("average load mem " + (aveloadmem / 1024 / loop) + " kb");
         System.Console.Out.WriteLine("average assert " + (totalassert / loop) + " ms");
         //System.Console.Out.WriteLine("average assert mem " + (aveassertmem / 1024 / loop) + " kb");
         System.Console.Out.WriteLine("average fire " + (totalfire / loop) + " ms");
     }
     catch (System.Exception e)
     {
     //				SupportClass.WriteStackTrace(e, Console.Error);
     }
 }
开发者ID:happy280684,项目名称:droolsdotnet,代码行数:92,代码来源:SharedNode2CEPerformanceTest.cs

示例4: testTwoSharedNodes

 /// <summary> 
 /// 
 /// </summary>
 public virtual void testTwoSharedNodes()
 {
     try
     {
         int factCount = 5000;
         string file = "20rules_2CE_2shared.drl";
         int loop = 5;
         long totalload = 0;
         long totalassert = 0;
         long totalfire = 0;
         System.Diagnostics.Process rt = System.Diagnostics.Process.GetCurrentProcess();
         for (int c = 0; c < loop; c++)
         {
             long loadStart = (System.DateTime.Now.Ticks - 621355968000000000) / 10000;
             RuleBase ruleBase = readRule(file);
             long loadEnd = (System.DateTime.Now.Ticks - 621355968000000000) / 10000;
             long loadet = loadEnd - loadStart;
             totalload += loadet;
             System.GC.Collect();
             System.Console.Out.WriteLine("time to load " + file + " " + loadet + "ms");
             WorkingMemory workingMemory = ruleBase.NewWorkingMemory();
             System.Collections.ArrayList objects = new System.Collections.ArrayList();
             Account acc = new Account();
             acc.Status = "standard";
             objects.Add(acc);
             // create the objects
             for (int idx = 0; idx < factCount; idx++)
             {
                 Address addr = new Address();
                 addr.City = "boston";
                 addr.State = "ma";
                 addr.HouseType = "single family" + idx;
                 addr.Status = "not listed";
                 addr.Country = "usa";
                 objects.Add(addr);
             }
             System.Collections.IEnumerator itr = objects.GetEnumerator();
             long assertStart = (System.DateTime.Now.Ticks - 621355968000000000) / 10000;
             //UPGRADE_TODO: Method 'java.util.Iterator.hasNext' was converted to 'System.Collections.IEnumerator.MoveNext' which has a different behavior. "ms-help://MS.VSCC.v80/dv_commoner/local/redirect.htm?index='!DefaultContextWindowIndex'&keyword='jlca1073_javautilIteratorhasNext'"
             while (itr.MoveNext())
             {
                 //UPGRADE_TODO: Method 'java.util.Iterator.next' was converted to 'System.Collections.IEnumerator.Current' which has a different behavior. "ms-help://MS.VSCC.v80/dv_commoner/local/redirect.htm?index='!DefaultContextWindowIndex'&keyword='jlca1073_javautilIteratornext'"
                 workingMemory.assertObject(itr.Current);
             }
             long assertEnd = (System.DateTime.Now.Ticks - 621355968000000000) / 10000;
             long assertet = assertEnd - assertStart;
             totalassert += assertet;
             System.GC.Collect();
             System.Console.Out.WriteLine("time to assert " + assertet + " ms");
             long fireStart = (System.DateTime.Now.Ticks - 621355968000000000) / 10000;
             workingMemory.fireAllRules();
             long fireEnd = (System.DateTime.Now.Ticks - 621355968000000000) / 10000;
             long fireet = fireEnd - fireStart;
             totalfire += fireet;
             System.Console.Out.WriteLine("time to fireAllRules " + fireet + " ms");
             workingMemory.dispose();
             System.GC.Collect();
         }
         System.Console.Out.WriteLine(file);
         System.Console.Out.WriteLine("number of objects asserted " + factCount);
         System.Console.Out.WriteLine("average load " + (totalload / loop) + " ms");
         System.Console.Out.WriteLine("average assert " + (totalassert / loop) + " ms");
         System.Console.Out.WriteLine("average fire " + (totalfire / loop) + " ms");
     }
     catch (System.Exception e)
     {
     //				SupportClass.WriteStackTrace(e, Console.Error);
     }
 }
开发者ID:happy280684,项目名称:droolsdotnet,代码行数:72,代码来源:SharedNode2CEPerformanceTest.cs

示例5: CreateCompoundFile

		private void  CreateCompoundFile()
		{
			CompoundFileWriter cfsWriter = new CompoundFileWriter(directory, segment + ".cfs");
			
			System.Collections.ArrayList files = new System.Collections.ArrayList(COMPOUND_EXTENSIONS.Length + fieldInfos.Size());
			
			// Basic files
			for (int i = 0; i < COMPOUND_EXTENSIONS.Length; i++)
			{
				files.Add(segment + "." + COMPOUND_EXTENSIONS[i]);
			}
			
			// Field norm files
			for (int i = 0; i < fieldInfos.Size(); i++)
			{
				FieldInfo fi = fieldInfos.FieldInfo(i);
				if (fi.isIndexed)
				{
					files.Add(segment + ".f" + i);
				}
			}
			
			// Vector files
			if (fieldInfos.HasVectors())
			{
				for (int i = 0; i < VECTOR_EXTENSIONS.Length; i++)
				{
					files.Add(segment + "." + VECTOR_EXTENSIONS[i]);
				}
			}
			
			// Now merge all added files
			System.Collections.IEnumerator it = files.GetEnumerator();
			while (it.MoveNext())
			{
				cfsWriter.AddFile((System.String) it.Current);
			}
			
			// Perform the merge
			cfsWriter.Close();
			
			// Now delete the source files
			it = files.GetEnumerator();
			while (it.MoveNext())
			{
				directory.DeleteFile((System.String) it.Current);
			}
		}
开发者ID:emtees,项目名称:old-code,代码行数:48,代码来源:SegmentMerger.cs

示例6: generateGraph

		/// <summary> {@inheritDoc}</summary>
		public virtual void  generateGraph(Graph target, VertexFactory vertexFactory, System.Collections.IDictionary resultMap)
		{
			if (m_size < 1)
			{
				return ;
			}
			
			// A little trickery to intercept the rim generation.  This is
			// necessary since target may be initially non-empty, meaning we can't
			// rely on its vertex set after the rim is generated.
			//UPGRADE_NOTE: Final was removed from the declaration of 'rim '. "ms-help://MS.VSCC.v80/dv_commoner/local/redirect.htm?index='!DefaultContextWindowIndex'&keyword='jlca1003'"
			System.Collections.ICollection rim = new System.Collections.ArrayList();
			VertexFactory rimVertexFactory = new AnonymousClassVertexFactory(vertexFactory, rim, this);
			
			RingGraphGenerator ringGenerator = new RingGraphGenerator(m_size - 1);
			ringGenerator.generateGraph(target, rimVertexFactory, resultMap);
			
			System.Object hubVertex = vertexFactory.createVertex();
			target.addVertex(hubVertex);
			
			if (resultMap != null)
			{
				resultMap[HUB_VERTEX] = hubVertex;
			}
			
			System.Collections.IEnumerator rimIter = rim.GetEnumerator();
			
			//UPGRADE_TODO: Method 'java.util.Iterator.hasNext' was converted to 'System.Collections.IEnumerator.MoveNext' which has a different behavior. "ms-help://MS.VSCC.v80/dv_commoner/local/redirect.htm?index='!DefaultContextWindowIndex'&keyword='jlca1073_javautilIteratorhasNext'"
			while (rimIter.MoveNext())
			{
				//UPGRADE_TODO: Method 'java.util.Iterator.next' was converted to 'System.Collections.IEnumerator.Current' which has a different behavior. "ms-help://MS.VSCC.v80/dv_commoner/local/redirect.htm?index='!DefaultContextWindowIndex'&keyword='jlca1073_javautilIteratornext'"
				System.Object rimVertex = rimIter.Current;
				
				if (m_inwardSpokes)
				{
					target.addEdge(rimVertex, hubVertex);
				}
				else
				{
					target.addEdge(hubVertex, rimVertex);
				}
			}
		}
开发者ID:xuchuansheng,项目名称:GenXSource,代码行数:44,代码来源:WheelGraphGenerator.cs

示例7: Expand

		/// <summary> Perform synonym expansion on a query.
		/// 
		/// </summary>
		/// <param name="">query
		/// </param>
		/// <param name="">syns
		/// </param>
		/// <param name="">a
		/// </param>
		/// <param name="">field
		/// </param>
		/// <param name="">boost
		/// </param>
		public static Query Expand(System.String query, Searcher syns, Analyzer a, System.String field, float boost)
		{
			System.Collections.Hashtable already = new System.Collections.Hashtable(); // avoid dups		
			System.Collections.IList top = new System.Collections.ArrayList(); // needs to be separately listed..
			
			// [1] Parse query into separate words so that when we expand we can avoid dups
			TokenStream ts = a.TokenStream(field, new System.IO.StringReader(query));
			Lucene.Net.Analysis.Token t;
			while ((t = ts.Next()) != null)
			{
				System.String word = t.TermText();
				if (already.Contains(word) == false)
				{
					already.Add(word, word);
					top.Add(word);
				}
			}
			BooleanQuery tmp = new BooleanQuery();
			
			// [2] form query
			System.Collections.IEnumerator it = top.GetEnumerator();
			while (it.MoveNext())
			{
				// [2a] add to level words in
				System.String word = (System.String) it.Current;
				TermQuery tq = new TermQuery(new Term(field, word));
				tmp.Add(tq, BooleanClause.Occur.SHOULD);
				
				// [2b] add in unique synonums
				Hits hits = syns.Search(new TermQuery(new Term(Syns2Index.F_WORD, word)));
				for (int i = 0; i < hits.Length(); i++)
				{
					Document doc = hits.Doc(i);
					System.String[] values = doc.GetValues(Syns2Index.F_SYN);
					for (int j = 0; j < values.Length; j++)
					{
						System.String syn = values[j];
						if (already.Contains(syn) == false)
						{
							already.Add(syn, syn);
							tq = new TermQuery(new Term(field, syn));
							if (boost > 0)
							// else keep normal 1.0
								tq.SetBoost(boost);
							tmp.Add(tq, BooleanClause.Occur.SHOULD);
						}
					}
				}
			}
			
			
			return tmp;
		}
开发者ID:Rationalle,项目名称:ravendb,代码行数:66,代码来源:SynLookup.cs

示例8: CreateCompoundFile

		public /*internal*/ System.Collections.IList CreateCompoundFile(System.String fileName)
		{
			CompoundFileWriter cfsWriter = new CompoundFileWriter(directory, fileName, checkAbort);
			
			System.Collections.IList files = new System.Collections.ArrayList(IndexFileNames.COMPOUND_EXTENSIONS.Length + 1);
			
			// Basic files
			for (int i = 0; i < IndexFileNames.COMPOUND_EXTENSIONS.Length; i++)
			{
				System.String ext = IndexFileNames.COMPOUND_EXTENSIONS[i];
				
				if (ext.Equals(IndexFileNames.PROX_EXTENSION) && !HasProx())
					continue;
				
				if (mergeDocStores || (!ext.Equals(IndexFileNames.FIELDS_EXTENSION) && !ext.Equals(IndexFileNames.FIELDS_INDEX_EXTENSION)))
					files.Add(segment + "." + ext);
			}
			
			// Fieldable norm files
			for (int i = 0; i < fieldInfos.Size(); i++)
			{
				FieldInfo fi = fieldInfos.FieldInfo(i);
				if (fi.isIndexed && !fi.omitNorms)
				{
					files.Add(segment + "." + IndexFileNames.NORMS_EXTENSION);
					break;
				}
			}
			
			// Vector files
			if (fieldInfos.HasVectors() && mergeDocStores)
			{
				for (int i = 0; i < IndexFileNames.VECTOR_EXTENSIONS.Length; i++)
				{
					files.Add(segment + "." + IndexFileNames.VECTOR_EXTENSIONS[i]);
				}
			}
			
			// Now merge all added files
			System.Collections.IEnumerator it = files.GetEnumerator();
			while (it.MoveNext())
			{
				cfsWriter.AddFile((System.String) it.Current);
			}
			
			// Perform the merge
			cfsWriter.Close();
			
			return files;
		}
开发者ID:Rationalle,项目名称:ravendb,代码行数:50,代码来源:SegmentMerger.cs

示例9: test2KRuleFire

 /// <summary> 
 /// 
 /// </summary>
 public virtual void test2KRuleFire()
 {
     try
     {
         int factCount = 50000;
         System.String file = "2000_rules_1condition.rule";
         int loop = 5;
         long totalload = 0;
         long totalassert = 0;
         long totalfire = 0;
         for (int c = 0; c < loop; c++)
         {
             long loadStart = (System.DateTime.Now.Ticks - 621355968000000000) / 10000;
             RuleBase ruleBase = null;
             if (c == 0)
                 ruleBase = readRule(file, "C:\\PerformanceTest_2KRules.rlb");
             else
                 ruleBase = readPrecompiled("C:\\PerformanceTest_2KRules.rlb");
             long loadEnd = (System.DateTime.Now.Ticks - 621355968000000000) / 10000;
             long loadet = loadEnd - loadStart;
             totalload += loadet;
             System.Console.Out.WriteLine("time to load " + file + " " + loadet + "ms");
             WorkingMemory workingMemory = ruleBase.NewWorkingMemory();
             System.Collections.ArrayList objects = new System.Collections.ArrayList();
             // create the objects
             for (int idx = 0; idx < factCount; idx++)
             {
                 Account acc = new Account();
                 acc.AccountId = "acc" + idx;
                 acc.Title = "mr";
                 acc.Status = "standard";
                 objects.Add(acc);
             }
             System.Collections.IEnumerator itr = objects.GetEnumerator();
             long assertStart = (System.DateTime.Now.Ticks - 621355968000000000) / 10000;
             //UPGRADE_TODO: Method 'java.util.Iterator.hasNext' was converted to 'System.Collections.IEnumerator.MoveNext' which has a different behavior. "ms-help://MS.VSCC.v80/dv_commoner/local/redirect.htm?index='!DefaultContextWindowIndex'&keyword='jlca1073_javautilIteratorhasNext'"
             while (itr.MoveNext())
             {
                 //UPGRADE_TODO: Method 'java.util.Iterator.next' was converted to 'System.Collections.IEnumerator.Current' which has a different behavior. "ms-help://MS.VSCC.v80/dv_commoner/local/redirect.htm?index='!DefaultContextWindowIndex'&keyword='jlca1073_javautilIteratornext'"
                 workingMemory.assertObject(itr.Current);
             }
             long assertEnd = (System.DateTime.Now.Ticks - 621355968000000000) / 10000;
             long assertet = assertEnd - assertStart;
             totalassert += assertet;
             System.Console.Out.WriteLine("time to assert " + assertet + " ms");
             long fireStart = (System.DateTime.Now.Ticks - 621355968000000000) / 10000;
             workingMemory.fireAllRules();
             long fireEnd = (System.DateTime.Now.Ticks - 621355968000000000) / 10000;
             long fireet = fireEnd - fireStart;
             totalfire += fireet;
             System.Console.Out.WriteLine("time to fireAllRules " + fireet + " ms");
             workingMemory.dispose();
         }
         System.Console.Out.WriteLine(file);
         System.Console.Out.WriteLine("number of objects asserted " + factCount);
         System.Console.Out.WriteLine("average load " + (totalload / loop) + " ms");
         System.Console.Out.WriteLine("average assert " + (totalassert / loop) + " ms");
         System.Console.Out.WriteLine("average fire " + (totalfire / loop) + " ms");
     }
     catch (System.Exception e)
     {
         //SupportClass.WriteStackTrace(e, Console.Error);
     }
 }
开发者ID:happy280684,项目名称:droolsdotnet,代码行数:67,代码来源:RuleSetPerformanceTest.cs

示例10: parseSmiles


//.........这里部分代码省略.........
						nodeCounter++;
						position = position + currentSymbol.Length;
						bondExists = true;
						bondIsAromatic = false;
					}
					else if (mychar == '=')
					{
						position++;
						if (status == 2 || smiles.Length == position + 1 || !(smiles[position] >= '0' && smiles[position] <= '9'))
						{
							bondStatus = CDKConstants.BONDORDER_DOUBLE;
						}
						else
						{
							bondStatusForRingClosure = CDKConstants.BONDORDER_DOUBLE;
						}
					}
					else if (mychar == '#')
					{
						position++;
						if (status == 2 || smiles.Length == position + 1 || !(smiles[position] >= '0' && smiles[position] <= '9'))
						{
							bondStatus = CDKConstants.BONDORDER_TRIPLE;
						}
						else
						{
							bondStatusForRingClosure = CDKConstants.BONDORDER_TRIPLE;
						}
					}
					else if (mychar == '(')
					{
						atomStack.Add(lastNode);
						//logger.debug("Stack:");
						System.Collections.IEnumerator ses = atomStack.GetEnumerator();
						//UPGRADE_TODO: Method 'java.util.Enumeration.hasMoreElements' was converted to 'System.Collections.IEnumerator.MoveNext' which has a different behavior. "ms-help://MS.VSCC.v80/dv_commoner/local/redirect.htm?index='!DefaultContextWindowIndex'&keyword='jlca1073_javautilEnumerationhasMoreElements'"
						while (ses.MoveNext())
						{
							//UPGRADE_TODO: Method 'java.util.Enumeration.nextElement' was converted to 'System.Collections.IEnumerator.Current' which has a different behavior. "ms-help://MS.VSCC.v80/dv_commoner/local/redirect.htm?index='!DefaultContextWindowIndex'&keyword='jlca1073_javautilEnumerationnextElement'"
							Atom a = (Atom) ses.Current;
							//logger.debug("", a.GetHashCode());
						}
						//logger.debug("------");
						bondStack.Add((double) bondStatus);
						position++;
					}
					else if (mychar == ')')
					{
						lastNode = (Atom) SupportClass.StackSupport.Pop(atomStack);
						//logger.debug("Stack:");
						System.Collections.IEnumerator ses = atomStack.GetEnumerator();
						//UPGRADE_TODO: Method 'java.util.Enumeration.hasMoreElements' was converted to 'System.Collections.IEnumerator.MoveNext' which has a different behavior. "ms-help://MS.VSCC.v80/dv_commoner/local/redirect.htm?index='!DefaultContextWindowIndex'&keyword='jlca1073_javautilEnumerationhasMoreElements'"
						while (ses.MoveNext())
						{
							//UPGRADE_TODO: Method 'java.util.Enumeration.nextElement' was converted to 'System.Collections.IEnumerator.Current' which has a different behavior. "ms-help://MS.VSCC.v80/dv_commoner/local/redirect.htm?index='!DefaultContextWindowIndex'&keyword='jlca1073_javautilEnumerationnextElement'"
							Atom a = (Atom) ses.Current;
							//logger.debug("", a.GetHashCode());
						}
						//logger.debug("------");
						bondStatus = ((System.Double) SupportClass.StackSupport.Pop(bondStack));
						position++;
					}
					else if (mychar >= '0' && mychar <= '9')
					{
						status = 2;
						chars[0] = mychar;
						currentSymbol = new System.String(chars);
开发者ID:xuchuansheng,项目名称:GenXSource,代码行数:67,代码来源:SmilesParser.cs

示例11: GetBestTextFragments

		/// <summary> Low level api to get the most relevant (formatted) sections of the document.
		/// This method has been made public to allow visibility of score information held in TextFragment objects.
		/// Thanks to Jason Calabrese for help in redefining the interface.  
		/// </summary>
		/// <param name="">tokenStream
		/// </param>
		/// <param name="">text
		/// </param>
		/// <param name="">maxNumFragments
		/// </param>
		/// <param name="">mergeContiguousFragments
		/// </param>
		/// <throws>  IOException </throws>
		public TextFragment[] GetBestTextFragments(TokenStream tokenStream, System.String text, bool mergeContiguousFragments, int maxNumFragments)
		{
			System.Collections.ArrayList docFrags = new System.Collections.ArrayList();
			System.Text.StringBuilder newText = new System.Text.StringBuilder();
			
			TextFragment currentFrag = new TextFragment(newText, newText.Length, docFrags.Count);
			fragmentScorer.StartFragment(currentFrag);
			docFrags.Add(currentFrag);
			
			FragmentQueue fragQueue = new FragmentQueue(maxNumFragments);
			
			try
			{
				Lucene.Net.Analysis.Token token;
				System.String tokenText;
				int startOffset;
				int endOffset;
				int lastEndOffset = 0;
				textFragmenter.Start(text);
				
				TokenGroup tokenGroup = new TokenGroup();
				token = tokenStream.Next();
				while ((token != null) && (token.StartOffset() < maxDocBytesToAnalyze))
				{
					if ((tokenGroup.numTokens > 0) && (tokenGroup.IsDistinct(token)))
					{
						//the current token is distinct from previous tokens - 
						// markup the cached token group info
						startOffset = tokenGroup.matchStartOffset;
						endOffset = tokenGroup.matchEndOffset;
						tokenText = text.Substring(startOffset, (endOffset) - (startOffset));
						System.String markedUpText = formatter.HighlightTerm(encoder.EncodeText(tokenText), tokenGroup);
						//store any whitespace etc from between this and last group
						if (startOffset > lastEndOffset)
							newText.Append(encoder.EncodeText(text.Substring(lastEndOffset, (startOffset) - (lastEndOffset))));
						newText.Append(markedUpText);
						lastEndOffset = System.Math.Max(endOffset, lastEndOffset);
						tokenGroup.Clear();
						
						//check if current token marks the start of a new fragment						
						if (textFragmenter.IsNewFragment(token))
						{
							currentFrag.SetScore(fragmentScorer.GetFragmentScore());
							//record stats for a new fragment
							currentFrag.textEndPos = newText.Length;
							currentFrag = new TextFragment(newText, newText.Length, docFrags.Count);
							fragmentScorer.StartFragment(currentFrag);
							docFrags.Add(currentFrag);
						}
					}
					
					tokenGroup.AddToken(token, fragmentScorer.GetTokenScore(token));
					
					//				if(lastEndOffset>maxDocBytesToAnalyze)
					//				{
					//					break;
					//				}
					token = tokenStream.Next();
				}
				currentFrag.SetScore(fragmentScorer.GetFragmentScore());
				
				if (tokenGroup.numTokens > 0)
				{
					//flush the accumulated text (same code as in above loop)
					startOffset = tokenGroup.matchStartOffset;
					endOffset = tokenGroup.matchEndOffset;
					tokenText = text.Substring(startOffset, (endOffset) - (startOffset));
					System.String markedUpText = formatter.HighlightTerm(encoder.EncodeText(tokenText), tokenGroup);
					//store any whitespace etc from between this and last group
					if (startOffset > lastEndOffset)
						newText.Append(encoder.EncodeText(text.Substring(lastEndOffset, (startOffset) - (lastEndOffset))));
					newText.Append(markedUpText);
					lastEndOffset = System.Math.Max(lastEndOffset, endOffset);
				}
				
				//Test what remains of the original text beyond the point where we stopped analyzing 
				if ((lastEndOffset < text.Length) && (text.Length < maxDocBytesToAnalyze))
				{
					//append it to the last fragment
					newText.Append(encoder.EncodeText(text.Substring(lastEndOffset)));
				}
				
				currentFrag.textEndPos = newText.Length;
				
				//sort the most relevant sections of the text
				for (System.Collections.IEnumerator i = docFrags.GetEnumerator(); i.MoveNext(); )
				{
//.........这里部分代码省略.........
开发者ID:vikasraz,项目名称:indexsearchutils,代码行数:101,代码来源:Highlighter.cs

示例12: TestAllFoldings


//.........这里部分代码省略.........
       "‼"  // U+203C: DOUBLE EXCLAMATION MARK
      ,"!!", // Folded result

       "⁉"  // U+2049: EXCLAMATION QUESTION MARK
      ,"!?", // Folded result

       "#"  // U+FF03: FULLWIDTH NUMBER SIGN
      ,"#", // Folded result

       "$"  // U+FF04: FULLWIDTH DOLLAR SIGN
      ,"$", // Folded result

       "⁒"  // U+2052: COMMERCIAL MINUS SIGN
       + "%"  // U+FF05: FULLWIDTH PERCENT SIGN
      ,"%", // Folded result

       "&"  // U+FF06: FULLWIDTH AMPERSAND
      ,"&", // Folded result

       "⁎"  // U+204E: LOW ASTERISK
       + "*"  // U+FF0A: FULLWIDTH ASTERISK
      ,"*", // Folded result

       ","  // U+FF0C: FULLWIDTH COMMA
      ,",", // Folded result

       "."  // U+FF0E: FULLWIDTH FULL STOP
      ,".", // Folded result

       "⁄"  // U+2044: FRACTION SLASH
       + "/"  // U+FF0F: FULLWIDTH SOLIDUS
      ,"/", // Folded result

       ":"  // U+FF1A: FULLWIDTH COLON
      ,":", // Folded result

       "⁏"  // U+204F: REVERSED SEMICOLON
       + ";"  // U+FF1B: FULLWIDTH SEMICOLON
      ,";", // Folded result

       "?"  // U+FF1F: FULLWIDTH QUESTION MARK
      ,"?", // Folded result

       "⁇"  // U+2047: DOUBLE QUESTION MARK
      ,"??", // Folded result

       "⁈"  // U+2048: QUESTION EXCLAMATION MARK
      ,"?!", // Folded result

       "@"  // U+FF20: FULLWIDTH COMMERCIAL AT
      ,"@", // Folded result

       "\"  // U+FF3C: FULLWIDTH REVERSE SOLIDUS
      ,"\\", // Folded result

       "‸"  // U+2038: CARET
       + "^"  // U+FF3E: FULLWIDTH CIRCUMFLEX ACCENT
      ,"^", // Folded result

       "_"  // U+FF3F: FULLWIDTH LOW LINE
      ,"_", // Folded result

       "⁓"  // U+2053: SWUNG DASH
       + "~"  // U+FF5E: FULLWIDTH TILDE
      ,"~", // Folded result
                };
            
            // Construct input text and expected output tokens
            System.Collections.IList expectedOutputTokens = new System.Collections.ArrayList();
            System.Text.StringBuilder inputText = new System.Text.StringBuilder();
            for (int n = 0; n < foldings.Length; n += 2)
            {
                if (n > 0)
                {
                    inputText.Append(' '); // Space between tokens
                }
                inputText.Append(foldings[n]);
                
                // Construct the expected output token: the ASCII string to fold to,
                // duplicated as many times as the number of characters in the input text.
                System.Text.StringBuilder expected = new System.Text.StringBuilder();
                int numChars = foldings[n].Length;
                for (int m = 0; m < numChars; ++m)
                {
                    expected.Append(foldings[n + 1]);
                }
                expectedOutputTokens.Add(expected.ToString());
            }
            
            TokenStream stream = new WhitespaceTokenizer(new System.IO.StringReader(inputText.ToString()));
            ASCIIFoldingFilter filter = new ASCIIFoldingFilter(stream);
            ITermAttribute termAtt = filter.GetAttribute<ITermAttribute>();
            System.Collections.IEnumerator expectedIter = expectedOutputTokens.GetEnumerator();
            while (expectedIter.MoveNext())
            {
                ;
                AssertTermEquals((System.String) expectedIter.Current, filter, termAtt);
            }
            Assert.IsFalse(filter.IncrementToken());
        }
开发者ID:Nangal,项目名称:lucene.net,代码行数:101,代码来源:TestASCIIFoldingFilter.cs

示例13: testTwoSharedNodes

 /// <summary> 
 /// 
 /// </summary>
 public void testTwoSharedNodes()
 {
     try
     {
         int factCount = 5000;
         string file = "20rules_2shared.drl";
         int loop = 5;
         long totalload = 0;
         long totalassert = 0;
         long totalfire = 0;
         System.Diagnostics.Process rt = System.Diagnostics.Process.GetCurrentProcess();
         for (int c = 0; c < loop; c++)
         {
             System.GC.Collect();
             long loadStart = (System.DateTime.Now.Ticks - 621355968000000000) / 10000;
             RuleBase ruleBase = readRule(file);
             long loadEnd = (System.DateTime.Now.Ticks - 621355968000000000) / 10000;
             long loadet = loadEnd - loadStart;
             totalload += loadet;
             System.GC.Collect();
             System.Console.Out.WriteLine("time to load " + file + " " + loadet + "ms");
             WorkingMemory workingMemory = ruleBase.NewWorkingMemory();
             System.Collections.ArrayList objects = new System.Collections.ArrayList();
             // create the objects
             for (int idx = 0; idx < factCount; idx++)
             {
                 Address addr = new Address();
                 addr.City = "boston";
                 addr.State = "ma";
                 addr.HouseType = "single family" + idx;
                 addr.Status = "not listed";
                 addr.Country = "usa";
                 objects.Add(addr);
             }
             System.Collections.IEnumerator itr = objects.GetEnumerator();
             long assertStart = (System.DateTime.Now.Ticks - 621355968000000000) / 10000;
             while (itr.MoveNext())
             {
                 workingMemory.assertObject(itr.Current);
             }
             long assertEnd = (System.DateTime.Now.Ticks - 621355968000000000) / 10000;
             long assertet = assertEnd - assertStart;
             totalassert += assertet;
             System.GC.Collect();
             System.Console.Out.WriteLine("time to assert " + assertet + " ms");
             long fireStart = (System.DateTime.Now.Ticks - 621355968000000000) / 10000;
             workingMemory.fireAllRules();
             long fireEnd = (System.DateTime.Now.Ticks - 621355968000000000) / 10000;
             long fireet = fireEnd - fireStart;
             totalfire += fireet;
             System.Console.Out.WriteLine("time to fireAllRules " + fireet + " ms");
             workingMemory.dispose();
             System.GC.Collect();
         }
         System.Console.Out.WriteLine(file);
         System.Console.Out.WriteLine("number of objects asserted " + factCount);
         System.Console.Out.WriteLine("average load " + (totalload / loop) + " ms");
         System.Console.Out.WriteLine("average assert " + (totalassert / loop) + " ms");
         System.Console.Out.WriteLine("average fire " + (totalfire / loop) + " ms");
     }
     catch (System.Exception e)
     {
         //SupportClass.WriteStackTrace(e, Console.Error);
     }
 }
开发者ID:happy280684,项目名称:droolsdotnet,代码行数:68,代码来源:SharedNodePerformanceTest.cs

示例14: ListCacheEntries

		string ListCacheEntries()
		{
			System.Collections.ArrayList cacheKeys = new System.Collections.ArrayList();

			System.Collections.IDictionaryEnumerator enumerator = System.Web.HttpContext.Current.Cache.GetEnumerator();
			while (enumerator.MoveNext())
			{
				System.Collections.DictionaryEntry de = enumerator.Entry;
				cacheKeys.Add(de.Key);
			}
			cacheKeys.Sort();
			System.Collections.IEnumerator e = cacheKeys.GetEnumerator();
			System.Text.StringBuilder output = new System.Text.StringBuilder();
			output.Append("<table width=100%>\n");

			if (cacheKeys.Count > 0 || OnRefresh != null)
			{
				if (_authenticated)
				{
					output.AppendFormat("<tr><td><form method=post action=''>");
					output.AppendFormat("<tr><td><input type=submit value='Remove' />");
					output.AppendFormat("<input type=button value='Check all' onClick='value=check(form.cache)'>");
					output.AppendFormat("</td></tr>");

					output.Append("<SCRIPT LANGUAGE='JavaScript'><!-- \n");
					output.Append("var checkflag = 'false';function check(field) {if (checkflag == 'false') {  for (i = 0; i < field.length; i++) {  field[i].checked = true;}  checkflag = 'true';  return 'Uncheck all'; }else {  for (i = 0; i < field.length; i++) {  field[i].checked = false; }  checkflag = 'false';  return 'Check all'; }}\n");
					output.Append("//  End --></script>");
				}

				if (OnRefresh != null)
				{
					output.AppendFormat("<tr><td colspan=3>");
					if (_authenticated)
						output.AppendFormat("<input type=checkbox name='custom' value='true' />");
					output.AppendFormat(OnRefresh.GetInvocationList().Length + " Custom Cached Object(s)</td></tr>");
				}

				while (e.MoveNext())
				{
					output.AppendFormat("<tr>");
					int columns = 0;
					do
					{
						output.AppendFormat("<td width=33% nowrap>");
						if (_authenticated)
						{
							output.AppendFormat("<input type=checkbox name='cache' value='{0}' /> ", e.Current);
						}
						output.AppendFormat("{0}</td>", e.Current);
						columns++;
					} while (columns < 3 && e.MoveNext());
					output.AppendFormat("</tr>\r");
				}

				if (_authenticated)
				{
					output.AppendFormat("<tr><td><input type=submit value='Remove' />");
					output.AppendFormat("</form></td></tr>");
				}
			}
			else
			{
				output.Append("<tr><td>Cache is empty.</tr></td>\n");
			}
			output.Append("</table>\n");
			return output.ToString();
		}
开发者ID:joaomajesus,项目名称:Tarantino,代码行数:67,代码来源:Cache.cs

示例15: Rewrite

			public override Query Rewrite(IndexReader reader, MultiTermQuery query)
			{
				// Get the enum and start visiting terms.  If we
				// exhaust the enum before hitting either of the
				// cutoffs, we use ConstantBooleanQueryRewrite; else,
				// ConstantFilterRewrite:
				System.Collections.ArrayList pendingTerms = new System.Collections.ArrayList();
				int docCountCutoff = (int) ((docCountPercent / 100.0) * reader.MaxDoc());
				int termCountLimit = System.Math.Min(BooleanQuery.GetMaxClauseCount(), termCountCutoff);
				int docVisitCount = 0;
				
				FilteredTermEnum enumerator = query.GetEnum(reader);
				try
				{
					while (true)
					{
						Term t = enumerator.Term();
						if (t != null)
						{
							pendingTerms.Add(t);
							// Loading the TermInfo from the terms dict here
							// should not be costly, because 1) the
							// query/filter will load the TermInfo when it
							// runs, and 2) the terms dict has a cache:
							docVisitCount += reader.DocFreq(t);
						}
						
						if (pendingTerms.Count >= termCountLimit || docVisitCount >= docCountCutoff)
						{
							// Too many terms -- make a filter.
							Query result = new ConstantScoreQuery(new MultiTermQueryWrapperFilter(query));
							result.SetBoost(query.GetBoost());
							return result;
						}
						else if (!enumerator.Next())
						{
							// Enumeration is done, and we hit a small
							// enough number of terms & docs -- just make a
							// BooleanQuery, now
							System.Collections.IEnumerator it = pendingTerms.GetEnumerator();
							BooleanQuery bq = new BooleanQuery(true);
							while (it.MoveNext())
							{
								TermQuery tq = new TermQuery((Term) it.Current);
								bq.Add(tq, BooleanClause.Occur.SHOULD);
							}
							// Strip scores
							Query result = new ConstantScoreQuery(new QueryWrapperFilter(bq));
							result.SetBoost(query.GetBoost());
							query.IncTotalNumberOfTerms(pendingTerms.Count);
							return result;
						}
					}
				}
				finally
				{
					enumerator.Close();
				}
			}
开发者ID:Inzaghi2012,项目名称:teamlab.v7.5,代码行数:59,代码来源:MultiTermQuery.cs


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