Lucene.Net.Codecs.Lucene3x.TermBuffer.CompareTo C# (CSharp) Method

CompareTo() public method

public CompareTo ( TermBuffer other ) : int
other TermBuffer
return int
        public int CompareTo(TermBuffer other)
        {
            if (Field == other.Field) // fields are interned
            // (only by PreFlex codec)
            {
                return Utf8AsUTF16Comparator.Compare(Bytes, other.Bytes);
            }
            else
            {
                return Field.CompareTo(other.Field);
            }
        }

Usage Example

Example #1
0
        /* Optimized scan, without allocating new terms.
         *  Return number of invocations to next().
         *
         * NOTE: LUCENE-3183: if you pass Term("", "") here then this
         * will incorrectly return before positioning the enum,
         * and position will be -1; caller must detect this. */

        internal int ScanTo(Term term)
        {
            scanBuffer.Set(term);
            int count = 0;

            if (first)
            {
                // Always force initial next() in case term is
                // Term("", "")
                Next();
                first = false;
                count++;
            }
            while (scanBuffer.CompareTo(termBuffer) > 0 && Next())
            {
                count++;
            }
            return(count);
        }