Exemple #1
0
        public ArrayList DiffReport()
        {
            ArrayList retval = new ArrayList();
            int       dcount = _dest.Count();
            int       scount = _source.Count();

            //Deal with the special case of empty files
            if (dcount == 0)
            {
                if (scount > 0)
                {
                    retval.Add(DiffResultSpan.CreateDeleteSource(0, scount));
                }
                return(retval);
            }
            else
            {
                if (scount == 0)
                {
                    retval.Add(DiffResultSpan.CreateAddDestination(0, dcount));
                    return(retval);
                }
            }


            _matchList.Sort();
            int            curDest   = 0;
            int            curSource = 0;
            DiffResultSpan last      = null;

            //Process each match record
            foreach (DiffResultSpan drs in _matchList)
            {
                if ((!AddChanges(retval, curDest, drs.DestIndex, curSource, drs.SourceIndex)) &&
                    (last != null))
                {
                    last.AddLength(drs.Length);
                }
                else
                {
                    retval.Add(drs);
                }
                curDest   = drs.DestIndex + drs.Length;
                curSource = drs.SourceIndex + drs.Length;
                last      = drs;
            }

            //Process any tail end data
            AddChanges(retval, curDest, dcount, curSource, scount);

            return(retval);
        }
Exemple #2
0
        public DiffResultSpanCollection DiffReport()
        {
            DiffResultSpanCollection returnResultSpanCollection = new DiffResultSpanCollection();
            int dcount = _dest.Count();
            int scount = _source.Count();

            //Deal with the special case of empty files
            if (dcount == 0)
            {
                if (scount > 0)
                {
                    returnResultSpanCollection.Add(DiffResultSpan.CreateDeleteSource(0, scount));
                }
                return(returnResultSpanCollection);
            }
            else
            {
                if (scount == 0)
                {
                    returnResultSpanCollection.Add(DiffResultSpan.CreateAddDestination(0, dcount));
                    return(returnResultSpanCollection);
                }
            }


            _matchList.Sort();
            int            curDest        = 0;
            int            curSource      = 0;
            DiffResultSpan lastResultSpan = null;

            //Process each match record
            foreach (DiffResultSpan resultSpan in _matchList)
            {
                if ((!AddChanges(returnResultSpanCollection, curDest, resultSpan.DestIndex, curSource, resultSpan.SourceIndex)) &&
                    (lastResultSpan != null))
                {
                    lastResultSpan.AddLength(resultSpan.Length);
                }
                else
                {
                    returnResultSpanCollection.Add(resultSpan);
                }
                curDest        = resultSpan.DestIndex + resultSpan.Length;
                curSource      = resultSpan.SourceIndex + resultSpan.Length;
                lastResultSpan = resultSpan;
            }

            //Process any tail end data
            AddChanges(returnResultSpanCollection, curDest, dcount, curSource, scount);

            return(returnResultSpanCollection);
        }
Exemple #3
0
        //添加不同行的区域块,从第一行到最后一行,相邻的行状态相同为一个区域块
        //DiffReport返回参数解释:
        //int DestIndex   ---区域块第一行在新版本文件中的原来的索引
        //SourceIndex     ---区域块第一行在老版本文件中的原来的索引
        //int Length      ---当前区域块中的行的个数
        //Status          ---改区域块中所有行共同的状态(Add/Delete/Modify)
        public ArrayList DiffReport()
        {
            ArrayList resultList = new ArrayList();//返回值
            int       dcount     = _dest.Count();
            int       scount     = _source.Count();

            //处理空文件
            if (dcount == 0)
            {
                if (scount > 0)
                {
                    resultList.Add(DiffResultSpan.CreateDeleteSource(0, scount));
                }
                return(resultList);
            }
            else
            {
                if (scount == 0)
                {
                    resultList.Add(DiffResultSpan.CreateAddDestination(0, dcount));
                    return(resultList);
                }
            }

            //_matchList添加了相同行和不同行区域块,但是不同行又分为:新增、删除、修改三个状态没有区分
            _matchList.Sort();
            int            curNewIndex = 0;
            int            curOldIndex = 0;
            DiffResultSpan last        = null;

            //Process each match record
            foreach (DiffResultSpan drs in _matchList)
            {
                if ((!AddChanges(resultList, curNewIndex, drs.DestIndex, curOldIndex, drs.SourceIndex)) &&
                    (last != null))
                {
                    last.AddLength(drs.Length);
                }
                else
                {
                    resultList.Add(drs);
                }
                curNewIndex = drs.DestIndex + drs.Length;//新版本当前区域块第一行的索引。
                curOldIndex = drs.SourceIndex + drs.Length;
                last        = drs;
            }

            //Process any tail end data
            AddChanges(resultList, curNewIndex, dcount, curOldIndex, scount);

            return(resultList);
        }
Exemple #4
0
        public double ProcessDiff(IDiffList source, IDiffList destination)
        {
            DateTime dt = DateTime.Now;

            _source    = source;
            _dest      = destination;
            _matchList = new ArrayList();
            int dcount = _dest.Count();
            int scount = _source.Count();

            if ((dcount > 0) && (scount > 0))
            {
                _stateList = new DiffStateList(dcount);
                ProcessRange(0, dcount - 1, 0, scount - 1);
            }
            TimeSpan ts = DateTime.Now - dt;

            return(ts.TotalSeconds);
        }
Exemple #5
0
        public double ProcessDiff(IDiffList source, IDiffList destination)
        {
            var dt = DateTime.Now;

            this.source = source;
            dest        = destination;
            matchList   = new ArrayList();

            var dcount = dest.Count();
            var scount = this.source.Count();

            if ((dcount > 0) && (scount > 0))
            {
                stateList = new DiffStateList(dcount);
                ProcessRange(0, dcount - 1, 0, scount - 1);
            }

            var ts = DateTime.Now - dt;

            return(ts.TotalSeconds);
        }
Exemple #6
0
        public double ProcessDiff(IDiffList source, IDiffList destination)
        {
            var dt = DateTime.Now;

            _source    = source;
            _dest      = destination;
            _matchList = new List <DiffResultSpan>();

            var dcount = _dest.Count();
            var scount = _source.Count();


            if ((dcount > 0) && (scount > 0))
            {
                _stateList = new DiffStateList(dcount);
                ProcessRange(0, dcount - 1, 0, scount - 1);
            }

            var ts = DateTime.Now - dt;

            return(ts.TotalSeconds);
        }
		public double ProcessDiff(IDiffList source, IDiffList destination)
		{
			DateTime dt = DateTime.Now;
			_source = source;
			_dest = destination;
			_matchList = new ArrayList();
			
			int dcount = _dest.Count();
			int scount = _source.Count();
			
			
			if ((dcount > 0)&&(scount > 0))
			{
				_stateList = new DiffStateList(dcount);
				ProcessRange(0,dcount - 1,0, scount - 1);
			}

			TimeSpan ts = DateTime.Now - dt;
			return ts.TotalSeconds;
		}
Exemple #8
0
        public double ProcessDiff(IDiffList source, IDiffList destination)
        {
            var dt = DateTime.Now;
            _source = source;
            _dest = destination;
            _matchList = new List<DiffResultSpan>();

            var dcount = _dest.Count();
            var scount = _source.Count();

            if ((dcount > 0)&&(scount > 0))
            {
                _stateList = new DiffStateList(dcount);
                ProcessRange(0,dcount - 1,0, scount - 1);
            }

            var ts = DateTime.Now - dt;
            return ts.TotalSeconds;
        }