示例#1
0
        internal void Remove(GeneratorPosition position, int count)
        {
            CheckOffsetAndRealized(position, count);

            int index = IndexFromGeneratorPosition(position);

            for (int i = 0; i < count; i++)
            {
                var container = ContainerIndexMap [index + i];
                var item      = ContainerItemMap [container];
                ContainerIndexMap.Remove(container, index + i);
                ContainerItemMap.Remove(container);
                RealizedElements.Remove(index + i);
                Owner.ClearContainerForItem(container, item);
            }
        }
示例#2
0
        void MoveExistingItems(int index, int offset)
        {
            // This is a little horrible. I should really collapse the existing
            // RangeCollection so that every > the current index is decremented by 1.
            // This is easier for now though. I may think of a better way later on.
            RangeCollection newRanges = new RangeCollection();
            List <int>      list      = new List <int> ();

            for (int i = 0; i < RealizedElements.Count; i++)
            {
                list.Add(RealizedElements [i]);
            }

            if (offset > 0)
            {
                list.Reverse();
            }

            foreach (int i in list)
            {
                int oldIndex = i;
                if (oldIndex < index)
                {
                    newRanges.Add(oldIndex);
                }
                else
                {
                    newRanges.Add(oldIndex + offset);
                    var container = ContainerIndexMap [oldIndex];
                    ContainerIndexMap.Remove(container, oldIndex);
                    ContainerIndexMap.Add(container, oldIndex + offset);
                }
            }

            RealizedElements = newRanges;
        }