Pathfinding.PointKDTree.MaxAllowedSize C# (CSharp) Method

MaxAllowedSize() static private method

static private MaxAllowedSize ( int numNodes, int depth ) : int
numNodes int
depth int
return int
		static int MaxAllowedSize (int numNodes, int depth) {
			// Allow a node to be 2.5 times as full as it should ideally be
			// but do not allow it to contain more than 3/4ths of the total number of nodes
			// (important to make sure nodes near the top of the tree also get rebalanced).
			// A node should ideally contain numNodes/(2^depth) nodes below it (^ is exponentiation, not xor)
			return System.Math.Min(((5 * numNodes) / 2) >> depth, (3 * numNodes) / 4);
		}

Usage Example

Ejemplo n.º 1
0
 private void Add(GraphNode point, int index, int depth = 0)
 {
     while (this.tree[index].data == null)
     {
         index = 2 * index + ((point.position[(int)this.tree[index].splitAxis] >= this.tree[index].split) ? 1 : 0);
         depth++;
     }
     this.tree[index].data.Add(point);
     if (this.tree[index].data.Count > PointKDTree.LeafSize * 2)
     {
         int num = 0;
         while (depth - num > 0 && this.Size(index >> num) > PointKDTree.MaxAllowedSize(this.numNodes, depth - num))
         {
             num++;
         }
         this.Rebalance(index >> num);
     }
 }
All Usage Examples Of Pathfinding.PointKDTree::MaxAllowedSize