예제 #1
0
            public void Remove(DDLElement node)
            {
                var prev = node.Previous;
                var next = node.Next;

                if (null != prev)
                {
                    prev.Next = next;
                }
                else
                {
                    _first = next;
                }

                if (null != next)
                {
                    next.Previous = prev;
                }
                else
                {
                    _last = prev;
                }

                --_count;
            }
예제 #2
0
            public DDLElement()
            {
                IntervalBegin = this;
                IntervalEnd   = this;
                IntervalSize  = 1;
                Clean         = true;

#if LinkedListDebug
                DebugId = ++DebugIdGen;
#endif
            }
예제 #3
0
        private void create_interval(DDLElement end, DDLElement begin, int lcp, int size, bool clean)
        {
            begin.IntervalBegin = begin;
            begin.IntervalEnd   = end;

            end.Lcp           = lcp;
            end.IntervalBegin = begin;
            end.IntervalEnd   = end;
            end.IntervalSize  = size;
            end.Clean         = clean;
        }
예제 #4
0
            public DDLElement(int text)
            {
                Text          = text;
                Clean         = true;
                IntervalBegin = this;
                IntervalEnd   = this;
                IntervalSize  = 1;
#if LinkedListDebug
                DebugId = ++DebugIdGen;
#endif
            }
예제 #5
0
 public void AddLast(DDLElement node)
 {
     if (null == _last)
     {
         _last         = node;
         _first        = node;
         node.Next     = null;
         node.Previous = null;
     }
     else
     {
         node.Next     = null;
         node.Previous = _last;
         _last.Next    = node;
         _last         = node;
     }
     ++_count;
 }
예제 #6
0
        private void InitializeIntermediates()
        {
            // initialize items
            list_sizes = new int[_numberOfWords];
            for (int i = 0; i < list_sizes.Length; ++i)
            {
                list_sizes[i] = (_x_repeats[i] > 0) ? _x_repeats[i] : 1;
            }

            _preResults = new List <PreResult>();
            _ddlList    = new LinkedObjectList();
            _items      = new DDLElement[_numberOfWords][];
            for (int i = 0; i < _items.Length; ++i)
            {
                int list_size_i = list_sizes[i];
                _items[i] = new DDLElement[list_size_i];
                for (int j = 0; j < list_size_i; ++j)
                {
                    DDLElement ele;
                    _items[i][j] = ele = new DDLElement()
                    {
                        Text = i
                    };
                    ele.IntervalSize = 0;
                    _ddlList.AddLast(ele);
                }
                if (_x_repeats[i] > 0)
                {
                    _items[i][0].IntervalSize = 1;
                }
            }

            // initialize intermediates
            _last_index = new int[_numberOfWords];
            _pqls       = new MinimumOnSlidingWindow[_numberOfWords];
            for (int i = 0; i < _numberOfWords; ++i)
            {
                _pqls[i].Initialize(_x_repeats[i], 0);
                //_pqls[i].add_value(0);
            }

            _lastLcp = new DDLElement[_maximumLcp + 1];

            var        begin = _ddlList.Last.Previous; // front.prev->prev;
            DDLElement end   = _ddlList.First;         // originally back.next

            begin.IntervalEnd = end;
            end.IntervalBegin = begin;
            if (_x_repeats[_ddlList.Last.Text] > 1)
            {
                end.IntervalSize = _numberOfWords;
            }
            else
            {
                end.IntervalSize = _numberOfWords - 1;
            }
            for (int i = 0; i < _numberOfWords - 1; ++i)
            {
                if (_x_repeats[i] == 0)
                {
                    end.IntervalSize = -1;
                    end.Clean        = false;
                }
            }
            _lastLcp[0] = end;
        }