Wrap another comparator for use with HashedSequence<S> .

This comparator acts as a proxy for the real comparator, evaluating the cached hash code before testing the underlying comparator's equality. Comparators of this type must be used with a HashedSequence<S> .

To construct an instance of this type use HashedSequencePair<S> .

Inheritance: SequenceComparator>
Esempio n. 1
0
 internal State(HistogramDiff _enclosing, EditList edits, HashedSequenceComparator
                <S> cmp, HashedSequence <S> a, HashedSequence <S> b)
 {
     this._enclosing = _enclosing;
     this.cmp        = cmp;
     this.a          = a;
     this.b          = b;
     this.edits      = edits;
 }
Esempio n. 2
0
        private MyersDiff(EditList edits, HashedSequenceComparator <S> cmp, HashedSequence
                          <S> a, HashedSequence <S> b, Edit region)
        {
            middle = new MyersDiff <S> .MiddleEdit(this);

            this.edits = edits;
            this.cmp   = cmp;
            this.a     = a;
            this.b     = b;
            CalculateEdits(region);
        }
        public override EditList DiffNonCommon <S>(SequenceComparator <S> cmp, S a,
                                                   S b)
        {
            HashedSequencePair <S>       p  = new HashedSequencePair <S>(cmp, a, b);
            HashedSequenceComparator <S> hc = p.GetComparator();
            HashedSequence <S>           ha = p.GetA();
            HashedSequence <S>           hb = p.GetB();

            p = null;
            EditList res    = new EditList();
            Edit     region = new Edit(0, a.Size(), 0, b.Size());

            DiffNonCommon(res, hc, ha, hb, region);
            return(res);
        }
Esempio n. 4
0
        internal HistogramDiffIndex(int maxChainLength, HashedSequenceComparator <S> cmp,
                                    HashedSequence <S> a, HashedSequence <S> b, Edit r)
        {
            this.maxChainLength = maxChainLength;
            this.cmp            = cmp;
            this.a      = a;
            this.b      = b;
            this.region = r;
            if (region.endA >= MAX_PTR)
            {
                throw new ArgumentException(JGitText.Get().sequenceTooLargeForDiffAlgorithm);
            }
            int sz        = r.GetLengthA();
            int tableBits = TableBits(sz);

            table    = new int[1 << tableBits];
            keyShift = 32 - tableBits;
            ptrShift = r.beginA;
            recs     = new long[Math.Max(4, (int)(((uint)sz) >> 3))];
            next     = new int[sz];
            recIdx   = new int[sz];
        }
Esempio n. 5
0
 public override void DiffNonCommon <S>(EditList edits, HashedSequenceComparator <S>
                                        cmp, HashedSequence <S> a, HashedSequence <S> b, Edit region)
 {
     new HistogramDiff.State <S>(this, edits, cmp, a, b).DiffReplace(region);
 }
 /// <summary>Compare two sequences and identify a list of edits between them.</summary>
 /// <remarks>
 /// Compare two sequences and identify a list of edits between them.
 /// This method should be invoked only after the two sequences have been
 /// proven to have no common starting or ending elements. The expected
 /// elimination of common starting and ending elements is automatically
 /// performed by the
 /// <see cref="DiffAlgorithm.Diff{S}(SequenceComparator{S}, Sequence, Sequence)">DiffAlgorithm.Diff&lt;S&gt;(SequenceComparator&lt;S&gt;, Sequence, Sequence)
 ///     </see>
 /// method, which invokes this method using
 /// <see cref="Subsequence{S}">Subsequence&lt;S&gt;</see>
 /// s.
 /// </remarks>
 /// <?></?>
 /// <param name="edits">result list to append the region's edits onto.</param>
 /// <param name="cmp">the comparator supplying the element equivalence function.</param>
 /// <param name="a">
 /// the first (also known as old or pre-image) sequence. Edits
 /// returned by this algorithm will reference indexes using the
 /// 'A' side:
 /// <see cref="Edit.GetBeginA()">Edit.GetBeginA()</see>
 /// ,
 /// <see cref="Edit.GetEndA()">Edit.GetEndA()</see>
 /// .
 /// </param>
 /// <param name="b">
 /// the second (also known as new or post-image) sequence. Edits
 /// returned by this algorithm will reference indexes using the
 /// 'B' side:
 /// <see cref="Edit.GetBeginB()">Edit.GetBeginB()</see>
 /// ,
 /// <see cref="Edit.GetEndB()">Edit.GetEndB()</see>
 /// .
 /// </param>
 /// <param name="region">the region being compared within the two sequences.</param>
 public abstract void DiffNonCommon <S>(EditList edits, HashedSequenceComparator <S>
                                        cmp, HashedSequence <S> a, HashedSequence <S> b, Edit region) where S : Sequence;
Esempio n. 7
0
 public override void DiffNonCommon <S>(EditList edits, HashedSequenceComparator <S>
                                        cmp, HashedSequence <S> a, HashedSequence <S> b, Edit region)
 {
     new NGit.Diff.MyersDiff <S>(edits, cmp, a, b, region);
 }