/// <summary> /// Initialize a node based on elements. /// </summary> private void InitializeNode(KdNode <T> n, IEnumerable <T> vecs) { T first = Numbered.First(vecs); if (n.Vectors == null) { n.Vectors = new List <T>(); } n.Vectors.Clear(); n.Vectors.AddRange(vecs); if (n.InternalBounds == null) { n.InternalBounds = new AABB(first.Dimensions); } n.InternalBounds.Reset(); n.InternalBounds.Enlarge(vecs); }
/// <summary> /// First element of enumeration /// </summary> public static T SecondOrDefault <T>(IEnumerable <T> e) { return(Numbered.NthOrDefault(e, 1)); }
/// <summary> /// Try accessing third element or return false /// </summary> public static bool TryThird <T>(IEnumerable <T> e, out T value) { return(Numbered.TryNth(e, 2, out value)); }
/// <summary> /// First element of enumeration /// </summary> public static T FirstOrDefault <T>(IEnumerable <T> e) { return(Numbered.NthOrDefault(e, 0)); }
/// <summary> /// Try accessing first element or return false /// </summary> public static bool TryFirst <T>(IEnumerable <T> e, out T value) { return(Numbered.TryNth(e, 0, out value)); }
/// <summary> /// Try accessing second element or return false /// </summary> public static bool TrySecond <T>(IEnumerable <T> e, out T value) { return(Numbered.TryNth(e, 1, out value)); }
/// <summary> /// First element of enumeration /// </summary> public static T Third <T>(IEnumerable <T> e) { return(Numbered.Nth(e, 2)); }
/// <summary> /// First element of enumeration /// </summary> public static T Second <T>(IEnumerable <T> e) { return(Numbered.Nth(e, 1)); }
/// <summary> /// First element of enumeration /// </summary> public static T First <T>(IEnumerable <T> e) { return(Numbered.Nth(e, 0)); }
/// <summary> /// First element of enumeration /// </summary> public static T ThirdOrDefault <T>(IEnumerable <T> e) { return(Numbered.NthOrDefault(e, 2)); }
/// <summary> /// Determines whether the kd-tree contains a specific element. /// </summary> public bool Contains(T item) { Searches.ExactSearch <T> es = new Accelerators.Searches.ExactSearch <T>(this.Root); es.CountLimit = 1; return(!Numbered.Empty(es.FindExact(item))); }