Lucene.Net.Analysis.Tokenattributes.CharTermAttribute.Equals C# (CSharp) Method

Equals() public method

public Equals ( object other ) : bool
other object
return bool
        public override bool Equals(object other)
        {
            if (other == this)
            {
                return true;
            }

            if (other is CharTermAttribute)
            {
                CharTermAttribute o = ((CharTermAttribute)other);
                if (TermLength != o.TermLength)
                {
                    return false;
                }
                for (int i = 0; i < TermLength; i++)
                {
                    if (TermBuffer[i] != o.TermBuffer[i])
                    {
                        return false;
                    }
                }
                return true;
            }

            return false;
        }

Usage Example

Exemplo n.º 1
0
        public virtual void TestEquals()
        {
            CharTermAttribute t1a = new CharTermAttribute();

            char[] content1a = "hello".ToCharArray();
            t1a.CopyBuffer(content1a, 0, 5);
            CharTermAttribute t1b = new CharTermAttribute();

            char[] content1b = "hello".ToCharArray();
            t1b.CopyBuffer(content1b, 0, 5);
            CharTermAttribute t2 = new CharTermAttribute();

            char[] content2 = "hello2".ToCharArray();
            t2.CopyBuffer(content2, 0, 6);
            Assert.IsTrue(t1a.Equals(t1b));
            Assert.IsFalse(t1a.Equals(t2));
            Assert.IsFalse(t2.Equals(t1b));
        }
All Usage Examples Of Lucene.Net.Analysis.Tokenattributes.CharTermAttribute::Equals