Example #1
0
        /// <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);
        }
Example #2
0
 /// <summary>
 /// First element of enumeration
 /// </summary>
 public static T SecondOrDefault <T>(IEnumerable <T> e)
 {
     return(Numbered.NthOrDefault(e, 1));
 }
Example #3
0
 /// <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));
 }
Example #4
0
 /// <summary>
 /// First element of enumeration
 /// </summary>
 public static T FirstOrDefault <T>(IEnumerable <T> e)
 {
     return(Numbered.NthOrDefault(e, 0));
 }
Example #5
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));
 }
Example #6
0
 /// <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));
 }
Example #7
0
 /// <summary>
 /// First element of enumeration
 /// </summary>
 public static T Third <T>(IEnumerable <T> e)
 {
     return(Numbered.Nth(e, 2));
 }
Example #8
0
 /// <summary>
 /// First element of enumeration
 /// </summary>
 public static T Second <T>(IEnumerable <T> e)
 {
     return(Numbered.Nth(e, 1));
 }
Example #9
0
 /// <summary>
 /// First element of enumeration
 /// </summary>
 public static T First <T>(IEnumerable <T> e)
 {
     return(Numbered.Nth(e, 0));
 }
Example #10
0
 /// <summary>
 /// First element of enumeration
 /// </summary>
 public static T ThirdOrDefault <T>(IEnumerable <T> e)
 {
     return(Numbered.NthOrDefault(e, 2));
 }
Example #11
0
 /// <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)));
 }