Equals() public method

public Equals ( NGit.Diff.HashedSequence a, int ai, NGit.Diff.HashedSequence b, int bi ) : bool
a NGit.Diff.HashedSequence
ai int
b NGit.Diff.HashedSequence
bi int
return bool
Esempio n. 1
0
 private bool ScanA()
 {
     // Scan the elements backwards, inserting them into the hash table
     // as we go. Going in reverse places the earliest occurrence of any
     // element at the start of the chain, so we consider earlier matches
     // before later matches.
     //
     for (int ptr = region.endA - 1; region.beginA <= ptr; ptr--)
     {
         int tIdx     = Hash(a, ptr);
         int chainLen = 0;
         for (int rIdx = table[tIdx]; rIdx != 0;)
         {
             long rec = recs[rIdx];
             if (cmp.Equals(a, RecPtr(rec), a, ptr))
             {
                 // ptr is identical to another element. Insert it onto
                 // the front of the existing element chain.
                 //
                 int newCnt = RecCnt(rec) + 1;
                 if (MAX_CNT < newCnt)
                 {
                     newCnt = MAX_CNT;
                 }
                 recs[rIdx]             = RecCreate(RecNext(rec), ptr, newCnt);
                 next[ptr - ptrShift]   = RecPtr(rec);
                 recIdx[ptr - ptrShift] = rIdx;
                 goto SCAN_continue;
             }
             rIdx = RecNext(rec);
             chainLen++;
         }
         if (chainLen == maxChainLength)
         {
             return(false);
         }
         // This is the first time we have ever seen this particular
         // element in the sequence. Construct a new chain for it.
         //
         int rIdx_1 = ++recCnt;
         if (rIdx_1 == recs.Length)
         {
             int    sz = Math.Min(recs.Length << 1, 1 + region.GetLengthA());
             long[] n  = new long[sz];
             System.Array.Copy(recs, 0, n, 0, recs.Length);
             recs = n;
         }
         recs[rIdx_1]           = RecCreate(table[tIdx], ptr, 1);
         recIdx[ptr - ptrShift] = rIdx_1;
         table[tIdx]            = rIdx_1;
         SCAN_continue :;
     }
     SCAN_break :;
     return(true);
 }