Exemplo n.º 1
0
        /// <summary>
        /// Updates indices of items which is greater than or equal to the specified index
        /// with the specified value.
        /// </summary>
        /// <param name="index">Index from which update has to be done.</param>
        /// <param name="value">Value with which positions have to be updated.</param>
        private void UpdatePositions(int index, int value)
        {
            List <int> itemsPositionToUpdate = _updatedItems.Keys.Where(I => I >= index).ToList();

            itemsPositionToUpdate.Sort();

            if (value > 0)
            {
                for (int i = itemsPositionToUpdate.Count - 1; i >= 0; i--)
                {
                    int key = itemsPositionToUpdate[i];
                    UpdatedSequenceItem item = _updatedItems[key];
                    _updatedItems.Remove(key);
                    _updatedItems.Add(key + value, item);
                }
            }
            else if (value < 0)
            {
                for (int i = 0; i < itemsPositionToUpdate.Count; i++)
                {
                    int key = itemsPositionToUpdate[i];
                    UpdatedSequenceItem item = _updatedItems[key];
                    _updatedItems.Remove(key);
                    _updatedItems.Add(key + value, item);
                }
            }
        }
Exemplo n.º 2
0
        /// <summary>
        /// Constructor for clone method.
        /// </summary>
        /// <param name="otherDerivedSequence">otherDerivedSequence to clone.</param>
        private DerivedSequence(DerivedSequence otherDerivedSequence)
        {
            _source       = otherDerivedSequence._source.Clone();
            _updatedItems = new SortedDictionary <int, UpdatedSequenceItem>();

            foreach (int key in otherDerivedSequence._updatedItems.Keys)
            {
                UpdatedSequenceItem item = new UpdatedSequenceItem(
                    otherDerivedSequence._updatedItems[key].SequenceItem,
                    otherDerivedSequence._updatedItems[key].Type);

                if (item.SequenceItem != Alphabet.LookupBySymbol(item.SequenceItem.Symbol))
                {
                    item.SequenceItem = item.SequenceItem.Clone();
                }

                _updatedItems.Add(key, item);
            }
        }