Lucene.Net.Search.TermsFilter.GetHashCode C# (CSharp) Method

GetHashCode() public method

public GetHashCode ( ) : int
return int
        public override int GetHashCode()
        {
            int hash = 9;
            foreach (Term t in this.terms)
            {
                hash = 31 * hash + t.GetHashCode();
            }
            return hash;
        }

Usage Example

コード例 #1
0
ファイル: TermsFilterTest.cs プロジェクト: mundher/lucene.net
        public void Cachability_Test()
        {
            TermsFilter a = new TermsFilter();

            a.AddTerm(new Term("field1", "a"));
            a.AddTerm(new Term("field1", "b"));

            // original test used placing filters in a HashSet to
            // determine equality, where the FilterManager uses
            // the hash code of the filters as the key, so
            // it makes more sense to just test the equality of the
            // hash codes.

            TermsFilter b = new TermsFilter();

            b.AddTerm(new Term("field1", "a"));
            b.AddTerm(new Term("field1", "b"));
            Assert.AreEqual(a.GetHashCode(), b.GetHashCode(), "Hashes do not match");

            b.AddTerm(new Term("field1", "a")); //duplicate term
            Assert.AreEqual(a.GetHashCode(), b.GetHashCode(), "Hashes do not match");

            b.AddTerm(new Term("field1", "c"));
            Assert.AreNotEqual(a.GetHashCode(), b.GetHashCode(), "Hashes match");
        }
All Usage Examples Of Lucene.Net.Search.TermsFilter::GetHashCode