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); }
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++; } }
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++; }