コード例 #1
0
ファイル: LongestCommonRepeatA.cs プロジェクト: olesar/Altaxo
        /// <summary>To understand the principles of this algorithm see the paper by Michael Arnold and Enno Ohlebusch given in the remarks of the class description (<see cref="LongestCommonRepeatA"/>).</summary>
        /// <param name="lcp_i">The lcp_i.</param>
        /// <param name="index">The index.</param>
        private void lcp_update(int lcp_i, int index)
        {
            var L            = _ddlList.L;
            var current      = _ddlList.Last;
            var last_updated = current;

            current = L[current].Previous;
            int list_pos = 0;

            while (current >= 0 && L[L[current].IntervalEnd].Lcp >= lcp_i)
            {
                current      = L[current].IntervalEnd;
                last_updated = current;
                list_pos    += L[current].IntervalSize;

                // Storing the results
                int currentLcp = L[current].Lcp;
                if (_useVerboseResults)
                {
                    if (currentLcp >= _lcsOfNumberOfWords[list_pos])
                    {
                        bool lcslIsReallyGreaterThanBefore = currentLcp > _lcsOfNumberOfWords[list_pos];
                        _lcsOfNumberOfWords[list_pos] = currentLcp;
                        StoreVerboseResult(list_pos, L[current].Idx, index - 1, lcslIsReallyGreaterThanBefore);
                    }
                }
                else
                {
                    if (currentLcp > _lcsOfNumberOfWords[list_pos])
                    {
                        _lcsOfNumberOfWords[list_pos]          = currentLcp;
                        _singleResultOfNumberOfWords[list_pos] = new SuffixArrayRegion(L[current].Idx, index - 1);
                    }
                } // end storing the results

                if (_lastLcp[L[last_updated].Lcp] == last_updated)
                {
                    _lastLcp[L[last_updated].Lcp] = -1;
                }
                current = L[current].Previous;
            } // end while

            L[_ddlList.Last].IntervalEnd  = last_updated;
            L[last_updated].IntervalBegin = _ddlList.Last;
            L[last_updated].IntervalSize  = list_pos;
            if (_lastLcp[L[last_updated].Lcp] == last_updated)
            {
                _lastLcp[L[last_updated].Lcp] = -1;
            }
            L[last_updated].Lcp = lcp_i;
            _lastLcp[lcp_i]     = last_updated;
        }
コード例 #2
0
 private void InitializeResults()
 {
     // initialize results
     _lcsOfNumberOfWords            = new int[_numberOfWords + 1];
     _verboseResultsOfNumberOfWords = null;
     _singleResultOfNumberOfWords   = null;
     if (_useVerboseResults)
     {
         _verboseResultsOfNumberOfWords = new List <SuffixArrayRegion> [_numberOfWords + 1];
     }
     else
     {
         _singleResultOfNumberOfWords = new SuffixArrayRegion[_numberOfWords + 1];
     }
 }
コード例 #3
0
        private void lcp_update(int lcp_i, int index)
        {
            var current      = _ddlList.Last;
            var last_updated = current;

            current = current.Previous;
            int list_pos = 1;

            while (null != current && current.IntervalEnd.Lcp >= lcp_i)
            {
                current      = current.IntervalEnd;
                last_updated = current;
                list_pos    += current.IntervalSize;

                // Storing the results
                if (_useVerboseResults)
                {
                    if (current.Lcp >= _lcsOfNumberOfWords[list_pos])
                    {
                        bool lcslIsReallyGreaterThanBefore = current.Lcp > _lcsOfNumberOfWords[list_pos];
                        _lcsOfNumberOfWords[list_pos] = current.Lcp;
                        StoreVerboseResult(list_pos, current.Idx, index - 1, lcslIsReallyGreaterThanBefore);
                    }
                }
                else
                {
                    if (current.Lcp > _lcsOfNumberOfWords[list_pos])
                    {
                        _lcsOfNumberOfWords[list_pos]          = current.Lcp;
                        _singleResultOfNumberOfWords[list_pos] = new SuffixArrayRegion(current.Idx, index - 1);
                    }
                } // end storing the results

                current = current.Previous;
            } // end while

            _ddlList.Last.IntervalEnd  = last_updated;
            last_updated.IntervalBegin = _ddlList.Last;
            last_updated.IntervalSize  = list_pos;
            last_updated.Lcp           = lcp_i;
            _lastLcp[lcp_i]            = last_updated;
        }
コード例 #4
0
ファイル: LongestCommonRepeatL.cs プロジェクト: Altaxo/Altaxo
		/// <summary>To understand the principles of this algorithm see the paper by Michael Arnold and Enno Ohlebusch given in the remarks of the class description (<see cref="LongestCommonRepeatL"/>).</summary>
		/// <param name="lcp_i">The lcp_i.</param>
		/// <param name="index">The index.</param>
		private void lcp_update(int lcp_i, int index)
		{
			var current = _ddlList.Last;
			var last_updated = current;
			current = current.Previous;
			int list_pos = 0;

			while (null != current && current.IntervalEnd.Lcp >= lcp_i)
			{
				current = current.IntervalEnd;
				last_updated = current;
				list_pos += current.IntervalSize;

				// Storing the results
				if (_useVerboseResults)
				{
					if (current.Lcp >= _lcsOfNumberOfWords[list_pos])
					{
						bool lcslIsReallyGreaterThanBefore = current.Lcp > _lcsOfNumberOfWords[list_pos];
						_lcsOfNumberOfWords[list_pos] = current.Lcp;
						StoreVerboseResult(list_pos, current.Idx, index - 1, lcslIsReallyGreaterThanBefore);
					}
				}
				else
				{
					if (current.Lcp > _lcsOfNumberOfWords[list_pos])
					{
						_lcsOfNumberOfWords[list_pos] = current.Lcp;
						_singleResultOfNumberOfWords[list_pos] = new SuffixArrayRegion(current.Idx, index - 1);
					}
				} // end storing the results

				if (_lastLcp[last_updated.Lcp] == last_updated)
				{
					_lastLcp[last_updated.Lcp] = null;
				}
				current = current.Previous;
			} // end while

			_ddlList.Last.IntervalEnd = last_updated;
			last_updated.IntervalBegin = _ddlList.Last;
			last_updated.IntervalSize = list_pos;
			if (_lastLcp[last_updated.Lcp] == last_updated)
			{
				_lastLcp[last_updated.Lcp] = null;
			}
			last_updated.Lcp = lcp_i;
			_lastLcp[lcp_i] = last_updated;
		}
コード例 #5
0
ファイル: LongestCommonRepeatL.cs プロジェクト: Altaxo/Altaxo
		private void InitializeResults()
		{
			// initialize results
			_lcsOfNumberOfWords = new int[_numberOfWords + 1];
			_verboseResultsOfNumberOfWords = null;
			_singleResultOfNumberOfWords = null;
			if (_useVerboseResults)
				_verboseResultsOfNumberOfWords = new List<SuffixArrayRegion>[_numberOfWords + 1];
			else
				_singleResultOfNumberOfWords = new SuffixArrayRegion[_numberOfWords + 1];
		}
コード例 #6
0
		/// <summary>To understand the principles of this algorithm see the paper by Michael Arnold and Enno Ohlebusch given in the remarks of the class description (<see cref="LongestCommonSubstringA"/>).</summary>
		/// <param name="lcp_i">The lcp_i.</param>
		/// <param name="index">The index.</param>
		private void lcp_update(int lcp_i, int index)
		{
			var L = _ddlList.L;
			var current = _ddlList.Last;
			var last_updated = current;
			current = L[current].Previous;
			int list_pos = 1;
			while (current >= 0 && L[(L[current]).IntervalEnd].Lcp >= lcp_i)
			{
				last_updated = current = L[current].IntervalEnd;
				list_pos += L[current].IntervalSize;

				// Storing the results
				int currentLcp = L[current].Lcp;
				if (_useVerboseResults)
				{
					if (currentLcp >= _lcsOfNumberOfWords[list_pos])
					{
						bool lcslIsReallyGreaterThanBefore = currentLcp > _lcsOfNumberOfWords[list_pos];
						_lcsOfNumberOfWords[list_pos] = currentLcp;
						StoreVerboseResult(list_pos, L[current].Idx, index - 1, lcslIsReallyGreaterThanBefore);
					}
				}
				else
				{
					if (currentLcp > _lcsOfNumberOfWords[list_pos])
					{
						_lcsOfNumberOfWords[list_pos] = currentLcp;
						_singleResultOfNumberOfWords[list_pos] = new SuffixArrayRegion(L[current].Idx, index - 1);
					}
				} // end storing the results

				current = L[current].Previous;
			} // end while

			L[_ddlList.Last].IntervalEnd = last_updated;
			L[last_updated].IntervalBegin = _ddlList.Last;
			L[last_updated].IntervalSize = list_pos;
			L[last_updated].Lcp = lcp_i;
			_lastLcp[lcp_i] = last_updated;
		}