예제 #1
0
 /// <returns>wrapper around B that includes cached hash codes.</returns>
 public virtual HashedSequence <S> GetB()
 {
     if (cachedB == null)
     {
         cachedB = Wrap(baseB);
     }
     return(cachedB);
 }
예제 #2
0
 /// <returns>wrapper around A that includes cached hash codes.</returns>
 public virtual HashedSequence <S> GetA()
 {
     if (cachedA == null)
     {
         cachedA = Wrap(baseA);
     }
     return(cachedA);
 }
예제 #3
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;
 }
예제 #4
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);
        }
예제 #6
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];
        }
예제 #7
0
 private int Hash(HashedSequence <S> s, int idx)
 {
     return((int)(((uint)(cmp.Hash(s, idx) *unchecked ((int)(0x9e370001)))) >> keyShift
                  ));
 }
예제 #8
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;
 public override int Hash(HashedSequence <S> seq, int ptr)
 {
     return(seq.hashes[ptr]);
 }
 public override bool Equals(HashedSequence <S> a, int ai, HashedSequence <S> b, int
                             bi)
 {
     //
     return(a.hashes[ai] == b.hashes[bi] && cmp.Equals(a.@base, ai, b.@base, bi));
 }
예제 #12
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);
 }