示例#1
0
        public static IntervalTree <N, T> FromEnumerable(IEnumerable <Interval <N, T> > values)
        {
            var result = new IntervalTree <N, T> ();

            foreach (var item in values)
            {
                result.Add(item.Low, item.High, item.Data);
            }
            return(result);
        }
示例#2
0
        public void Add(Aabb <Vec2> rect, T value)
        {
            var xival = _tree.Add(rect.Left, rect.Right, null);

            if (xival.Data == null)
            {
                xival.Data = new IntervalTree <float, Seq <T> > ();
            }
            var yival = xival.Data.Add(rect.Bottom, rect.Top, null);

            if (!yival.Data.Contains(value))
            {
                yival.Data = Seq.Cons(value, yival.Data);
                _count++;
            }
        }
示例#3
0
        public void Add(Aabb <Vec3> rect, T value)
        {
            var xival = _tree.Add(rect.Left, rect.Right, null);

            if (xival.Data == null)
            {
                xival.Data = new IntervalTree <float, IntervalTree <float, Seq <T> > > ();
            }
            var yival = xival.Data.Add(rect.Bottom, rect.Top, null);

            if (yival.Data == null)
            {
                yival.Data = new IntervalTree <float, Seq <T> > ();
            }
            var zival = yival.Data.Add(rect.Back, rect.Front, null);

            if (zival.Data.Contains(value))
            {
                throw new InvalidOperationException("Same value added twice.");
            }
            zival.Data = Seq.Cons(value, zival.Data);
            _count++;
        }