public List <T> Get(D time, StabMode mode) { Build(); List <T> stubedIntervals; switch (mode) { case StabMode.Contains: stubedIntervals = head.Stab(time, ContainConstrains.None); break; case StabMode.ContainsStart: stubedIntervals = head.Stab(time, ContainConstrains.IncludeStart); break; case StabMode.ContainsStartThenEnd: stubedIntervals = head.Stab(time, ContainConstrains.IncludeStart); if (stubedIntervals.Count == 0) { stubedIntervals = head.Stab(time, ContainConstrains.IncludeEnd); } break; default: throw new ArgumentException("Invalid StubMode " + mode, "mode"); } return(stubedIntervals); }
/// <summary> /// Perform a stabbing Query on the node /// </summary> /// <param name="time">the time to Query at</param> /// <returns>all stubedIntervals containing time</returns> public List <T> Stab(D time, ContainConstrains constraint) { List <T> result = new List <T>(); if (totalInterval != null && totalInterval.Contains(time, constraint)) { foreach (var entry in intervals) { if (entry.Key.Contains(time, constraint)) { result.AddRange(entry.Value); } } } if (time.CompareTo(center) < 0 && leftNode != null) { result.AddRange(leftNode.Stab(time, constraint)); } else if (time.CompareTo(center) > 0 && rightNode != null) { result.AddRange(rightNode.Stab(time, constraint)); } return(result); }