Beispiel #1
0
        protected void InsertChar(char sym)
        {
            int first = SearchInsertPosition(sym.ToString());

            array.Insert(first, arrayLength);
            lcp.Insert(first, 0);
            if (first != arrayLength && stringBuilder[array[first + 1]] == sym)
            {
                lcp[first]++;
                boundarySuffix.Add(arrayLength);
            }

            stringBuilder.Append(sym);
            charCollector.AddChar(sym);
            arrayLength++;
        }
        public void AddCharAtBegin(char ch)
        {
            if (StreamString.Length == 0)
            {
                Array.Insert(0, 0);
                StreamString.AddCharAtBegging(ch);

                return;
            }

            int pos = Array.GetInverse(StreamString.Length - 1);

            InvertedSuffixArrayInsertSearchStrategy strategy = new InvertedSuffixArrayInsertSearchStrategy(this, pos, ch);
            int first = global::SuffixArray.BinarySearch.BinarySearch.Instance.BinarySearchFirst(0, StreamString.Length, strategy);

            Array.Insert(first, StreamString.Length);

            StreamString.AddCharAtBegging(ch);
        }
Beispiel #3
0
        private static void GenerateTreap(IInverseIntTreap <int> treap, int seed)
        {
            Random random = new Random(seed);

            for (int i = 0; i < 1000; i++)
            {
                treap.Insert(i, i + 1);
            }

            for (int i = 0; i < 1000; i++)
            {
                int source = random.Next() % treap.Count;
                int dest   = random.Next() % treap.Count;
                treap.Move(source, dest);
            }
        }