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


C# Term.CompareTo方法代码示例

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


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

示例1: CheckDeleteTerm

 // used only by assert
 private bool CheckDeleteTerm(Term term) 
 {
     if (term != null) {
         System.Diagnostics.Debug.Assert(lastDeleteTerm == null || term.CompareTo(lastDeleteTerm) > 0, "lastTerm=" + lastDeleteTerm + " vs term=" + term);
     }
     lastDeleteTerm = term;
     return true;
 }
开发者ID:mindis,项目名称:Transformalize,代码行数:9,代码来源:DocumentsWriter.cs

示例2: TestCompareTo

 public virtual void TestCompareTo()
 {
     Term term = new Term("field" + Random().Next(NUMBER_OF_FIELDS), Text);
     for (int i = 0; i < Index.Length(); i++)
     {
         Term t = Index.GetTerm(i);
         int compareTo = term.CompareTo(t);
         Assert.AreEqual(compareTo, Index.CompareTo(term, i));
     }
 }
开发者ID:ChristopherHaws,项目名称:lucenenet,代码行数:10,代码来源:TestTermInfosReaderIndex.cs

示例3: GetPosition

		/// <summary>Returns the position of a Term in the set or -1. </summary>
		internal long GetPosition(Term term)
		{
			if (size == 0)
				return - 1;
			
			EnsureIndexIsRead();
			int indexOffset = GetIndexOffset(term);
			
			SegmentTermEnum enumerator = GetThreadResources().termEnum;
			SeekEnum(enumerator, indexOffset);
			
			while (term.CompareTo(enumerator.Term) > 0 && enumerator.Next())
			{
			}
			
			if (term.CompareTo(enumerator.Term) == 0)
				return enumerator.position;
			else
				return - 1;
		}
开发者ID:mindis,项目名称:Transformalize,代码行数:21,代码来源:TermInfosReader.cs

示例4: Get

		/// <summary>Returns the TermInfo for a Term in the set, or null. </summary>
		private TermInfo Get(Term term, bool useCache)
		{
			if (size == 0)
				return null;
			
			EnsureIndexIsRead();
			
			TermInfo ti;
			ThreadResources resources = GetThreadResources();
			Cache<Term, TermInfo> cache = null;
			
			if (useCache)
			{
				cache = resources.termInfoCache;
				// check the cache first if the term was recently looked up
				ti = cache.Get(term);
				if (ti != null)
				{
					return ti;
				}
			}
			
			// optimize sequential access: first try scanning cached enum w/o seeking
			SegmentTermEnum enumerator = resources.termEnum;
			if (enumerator.Term != null && ((enumerator.Prev() != null && term.CompareTo(enumerator.Prev()) > 0) || term.CompareTo(enumerator.Term) >= 0))
			{
				int enumOffset = (int) (enumerator.position / totalIndexInterval) + 1;
				if (indexTerms.Length == enumOffset || term.CompareTo(indexTerms[enumOffset]) < 0)
				{
					// no need to seek
					
					int numScans = enumerator.ScanTo(term);
					if (enumerator.Term != null && term.CompareTo(enumerator.Term) == 0)
					{
						ti = enumerator.TermInfo();
						if (cache != null && numScans > 1)
						{
							// we only  want to put this TermInfo into the cache if
							// scanEnum skipped more than one dictionary entry.
							// This prevents RangeQueries or WildcardQueries to 
							// wipe out the cache when they iterate over a large numbers
							// of terms in order
							cache.Put(term, ti);
						}
					}
					else
					{
						ti = null;
					}
					
					return ti;
				}
			}
			
			// random-access: must seek
			SeekEnum(enumerator, GetIndexOffset(term));
			enumerator.ScanTo(term);
			if (enumerator.Term != null && term.CompareTo(enumerator.Term) == 0)
			{
				ti = enumerator.TermInfo();
				if (cache != null)
				{
					cache.Put(term, ti);
				}
			}
			else
			{
				ti = null;
			}
			return ti;
		}
开发者ID:mindis,项目名称:Transformalize,代码行数:72,代码来源:TermInfosReader.cs

示例5: GetIndexOffset

		/// <summary>Returns the offset of the greatest index entry which is less than or equal to term.</summary>
		private int GetIndexOffset(Term term)
		{
			int lo = 0; // binary search indexTerms[]
			int hi = indexTerms.Length - 1;
			
			while (hi >= lo)
			{
				int mid = Number.URShift((lo + hi), 1);
				int delta = term.CompareTo(indexTerms[mid]);
				if (delta < 0)
					hi = mid - 1;
				else if (delta > 0)
					lo = mid + 1;
				else
					return mid;
			}
			return hi;
		}
开发者ID:mindis,项目名称:Transformalize,代码行数:19,代码来源:TermInfosReader.cs

示例6: Next

 public override bool Next()
 {
     foreach (SegmentMergeInfo smi in matchingSegments)
     {
     	if (smi == null)
     		break;
     	if (smi.Next())
     		queue.Add(smi);
     	else
     		smi.Dispose(); // done with segment
     }
     
     int numMatchingSegments = 0;
     matchingSegments[0] = null;
     
     SegmentMergeInfo top = queue.Top();
     
     if (top == null)
     {
         term = null;
         return false;
     }
     
     term = top.term;
     docFreq = 0;
     
     while (top != null && term.CompareTo(top.term) == 0)
     {
         matchingSegments[numMatchingSegments++] = top;
         queue.Pop();
         docFreq += top.termEnum.DocFreq(); // increment freq
         top = queue.Top();
     }
     
     matchingSegments[numMatchingSegments] = null;
     return true;
 }
开发者ID:mindis,项目名称:Transformalize,代码行数:37,代码来源:DirectoryReader.cs


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