Ejemplo n.º 1
0
 public void Set(IntervalIntSet set, TAttr attr)
 {
     foreach (var interval in set.EnumerateIntervals())
     {
         Set(new IntArrow <TAttr>(interval, attr));
     }
 }
Ejemplo n.º 2
0
        public override IntSet Complement(IntSet vocabulary0)
        {
            var vocabulary = vocabulary0 as IntervalIntSetBase;

            if (vocabulary == null)
            {
                throw new ArgumentException("Unsupported set type:" + vocabulary0, "vocabulary");
            }

            var result   = new IntervalIntSet(setType);
            Int previous = setType.MinValue;

            foreach (var interval in intervals)
            {
                if (interval.First != previous)
                {
                    var set = setType.Range(previous, interval.First - 1);
                    result.AddAll(set.Intersect(vocabulary));
                }

                previous = interval.Last + 1;
            }

            if (previous != setType.MaxValue)
            {
                var set = setType.Range(previous, setType.MaxValue);
                result.AddAll(set.Intersect(vocabulary));
            }

            result.UpdateHash();
            return(result);
        }
 public override IntSet CompleteAndDestroy()
 {
     var result = new IntervalIntSet(setType, this.intervals);
     this.intervals = new List<IntInterval>();
     UpdateHashAndBounds();
     return result;
 }
        public override IntSet CompleteAndDestroy()
        {
            var result = new IntervalIntSet(setType, this.intervals);

            this.intervals = new List <IntInterval>();
            UpdateHashAndBounds();
            return(result);
        }
Ejemplo n.º 5
0
        internal IntervalIntSet TypedClone()
        {
            var result = new IntervalIntSet(setType);

            foreach (var item in intervals)
            {
                result.intervals.Add(item);
            }

            result.bounds = bounds;
            return(result);
        }
Ejemplo n.º 6
0
        public override IntSet Intersect(IntSet other0)
        {
            IntervalIntSetBase other = (IntervalIntSetBase)other0;

            if (bounds.Intersects(other.bounds))
            {
                var result = new IntervalIntSet(setType);

                var otherIntervals = other.intervals;
                int myCount = intervals.Count;
                int theirCount = otherIntervals.Count;
                int i = 0, j = 0;

                while (i != myCount && j != theirCount)
                {
                    IntInterval mine   = intervals[i];
                    IntInterval theirs = otherIntervals[j];

                    switch (mine.RelationTo(theirs))
                    {
                    case IntIntervalRelation.Less:
                    {
                        ++i;
                        break;
                    }

                    case IntIntervalRelation.Greater:
                    {
                        ++j;
                        break;
                    }

                    case IntIntervalRelation.Equal:
                    case IntIntervalRelation.Contains:
                    {
                        result.Add(theirs);
                        ++j;
                        break;
                    }

                    case IntIntervalRelation.Contained:
                    {
                        result.Add(mine);
                        ++i;
                        break;
                    }

                    case IntIntervalRelation.OverlapFirst:
                    {
                        result.Add(mine * theirs);
                        ++i;
                        break;
                    }

                    case IntIntervalRelation.OverlapLast:
                    {
                        result.Add(mine * theirs);
                        ++j;
                        break;
                    }

                    default:
                        throw new InvalidOperationException("Internal error");
                    }
                }

                result.UpdateHash();
                return(result);
            }

            return(setType.Empty);
        }
Ejemplo n.º 7
0
        internal IntervalIntSet TypedClone()
        {
            var result = new IntervalIntSet(setType);
            foreach (var item in intervals)
            {
                result.intervals.Add(item);
            }

            result.bounds = bounds;
            return result;
        }
Ejemplo n.º 8
0
        public override IntSet Intersect(IntSet other0)
        {
            IntervalIntSetBase other = (IntervalIntSetBase)other0;

            if (bounds.Intersects(other.bounds))
            {
                var result = new IntervalIntSet(setType);

                var otherIntervals = other.intervals;
                int myCount = intervals.Count;
                int theirCount = otherIntervals.Count;
                int i = 0, j = 0;

                while (i != myCount && j != theirCount)
                {
                    IntInterval mine = intervals[i];
                    IntInterval theirs = otherIntervals[j];

                    switch (mine.RelationTo(theirs))
                    {
                        case IntIntervalRelation.Less:
                        {
                            ++i;
                            break;
                        }
                        case IntIntervalRelation.Greater:
                        {
                            ++j;
                            break;
                        }
                        case IntIntervalRelation.Equal:
                        case IntIntervalRelation.Contains:
                        {
                            result.Add(theirs);
                            ++j;
                            break;
                        }
                        case IntIntervalRelation.Contained:
                        {
                            result.Add(mine);
                            ++i;
                            break;
                        }
                        case IntIntervalRelation.OverlapFirst:
                        {
                            result.Add(mine * theirs);
                            ++i;
                            break;
                        }
                        case IntIntervalRelation.OverlapLast:
                        {
                            result.Add(mine * theirs);
                            ++j;
                            break;
                        }
                        default:
                            throw new InvalidOperationException("Internal error");
                    }
                }

                result.UpdateHash();
                return result;
            }

            return setType.Empty;
        }
Ejemplo n.º 9
0
        public override IntSet Complement(IntSet vocabulary0)
        {
            var vocabulary = vocabulary0 as IntervalIntSetBase;
            if (vocabulary == null)
            {
                throw new ArgumentException("Unsupported set type:" + vocabulary0, "vocabulary");
            }

            var result = new IntervalIntSet(setType);
            Int previous = setType.MinValue;
            foreach (var interval in intervals)
            {
                if (interval.First != previous)
                {
                    var set = setType.Range(previous, interval.First - 1);
                    result.AddAll(set.Intersect(vocabulary));
                }

                previous = interval.Last + 1;
            }

            if (previous != setType.MaxValue)
            {
                var set = setType.Range(previous, setType.MaxValue);
                result.AddAll(set.Intersect(vocabulary));
            }

            result.UpdateHash();
            return result;
        }