コード例 #1
0
        /// <summary>
        /// Unions the current range set with the given range set.
        /// </summary>
        public void Union(SelectableRangeSet unionTo)
        {
            List <SelectableRange> inputSet = unionTo.rangeSet;

            int inSz = inputSet.Count;
            int n    = 0;

            while (n < inSz)
            {
                SelectableRange        inRange = (SelectableRange)inputSet[n];
                int                    sz      = rangeSet.Count;
                List <SelectableRange> i       = rangeSet.GetRange(0, rangeSet.Count);
                int                    j       = 0;
                while (j < i.Count)
                {
                    SelectableRange range = i[j];
                    if (RangeIntersectedBy(inRange, range))
                    {
                        i.RemoveAt(j);
                        inRange = ChangeRangeSizeToEncompass(inRange, range);
                    }
                    j++;
                }

                // Insert into sorted position
                RangePosition startPoint = inRange.StartPosition;
                DataObject    start      = inRange.Start;
                RangePosition endPoint   = inRange.EndPosition;
                DataObject    end        = inRange.End;

                if (start == SelectableRange.FirstInSet)
                {
                    rangeSet.Insert(0, inRange);
                }
                else
                {
                    DataObject startCell = start;
                    i = rangeSet.GetRange(0, rangeSet.Count);
                    j = 0;
                    while (j < i.Count)
                    {
                        SelectableRange range    = i[j];
                        DataObject      curStart = range.Start;
                        if (curStart != SelectableRange.FirstInSet)
                        {
                            if (curStart.CompareTo(startCell) > 0)
                            {
                                i[j] = i[j - 1];
                                break;
                            }
                        }
                        j++;
                    }
                    i.Add(inRange);
                }
                n++;
            }
        }
コード例 #2
0
        /// <summary>
        /// Unions the current range set with the given range set.
        /// </summary>
        public void Union(SelectableRangeSet unionTo)
        {
            List<SelectableRange> inputSet = unionTo.rangeSet;

            int inSz = inputSet.Count;
            int n = 0;
            while (n < inSz) {
                SelectableRange inRange = (SelectableRange)inputSet[n];
                int sz = rangeSet.Count;
                List<SelectableRange> i = rangeSet.GetRange(0, rangeSet.Count);
                int j = 0;
                while (j < i.Count) {
                    SelectableRange range = i[j];
                    if (RangeIntersectedBy(inRange, range)) {
                        i.RemoveAt(j);
                        inRange = ChangeRangeSizeToEncompass(inRange, range);
                    }
                    j++;
                }

                // Insert into sorted position
                RangePosition startPoint = inRange.StartPosition;
                DataObject start = inRange.Start;
                RangePosition endPoint = inRange.EndPosition;
                DataObject end = inRange.End;

                if (start == SelectableRange.FirstInSet) {
                    rangeSet.Insert(0, inRange);
                } else {
                    DataObject startCell = start;
                    i = rangeSet.GetRange(0, rangeSet.Count);
                    j = 0;
                    while (j < i.Count) {
                        SelectableRange range = i[j];
                        DataObject curStart = range.Start;
                        if (curStart != SelectableRange.FirstInSet) {
                            if (curStart.CompareTo(startCell) > 0) {
                                i[j] = i[j - 1];
                                break;
                            }
                        }
                        j++;
                    }
                    i.Add(inRange);
                }
                n++;
            }
        }