示例#1
0
        unsafe void CollectSubtreesForNodeDirect(int nodeIndex, int remainingDepth,
                                                 ref QuickList <int> subtrees, ref QuickQueue <int> internalNodes, out float treeletCost)
        {
            internalNodes.EnqueueUnsafely(nodeIndex);

            treeletCost = 0;
            ref var node     = ref Nodes[nodeIndex];
        unsafe void CollectSubtreesForNodeDirect(int nodeIndex, int remainingDepth,
                                                 ref QuickList <int> subtrees, ref QuickQueue <int> internalNodes, out float treeletCost)
        {
            internalNodes.EnqueueUnsafely(nodeIndex);

            treeletCost = 0;
            var node     = nodes + nodeIndex;
            var children = &node->A;

            --remainingDepth;
            if (remainingDepth >= 0)
            {
                for (int i = 0; i < 2; ++i)
                {
                    ref var child = ref children[i];
                    if (child.Index >= 0)
                    {
                        treeletCost += ComputeBoundsMetric(ref child.Min, ref child.Max);
                        float childCost;
                        CollectSubtreesForNodeDirect(child.Index, remainingDepth, ref subtrees, ref internalNodes, out childCost);
                        treeletCost += childCost;
                    }
                    else
                    {
                        //It's a leaf, immediately add it to subtrees.
                        subtrees.AddUnsafely(child.Index);
                    }
                }
            }
 public void Add(double time)
 {
     if (queue.Count == Capacity)
     {
         queue.Dequeue();
     }
     queue.EnqueueUnsafely(time);
 }