Britbot
template<T >
bool Britbot.PriorityQueue.HeapPriorityQueue< T >.IsValidQueue ( ) [inline]

Should not be called in production code. Checks to make sure the queue is still in a valid state. Used for testing/debugging the queue.

Definition at line 313 of file HeapPriorityQueue.cs.

        {
            for (int i = 1; i < this._nodes.Length; i++)
            {
                if (this._nodes[i] != null)
                {
                    int childLeftIndex = 2 * i;
                    if (childLeftIndex < this._nodes.Length && this._nodes[childLeftIndex] != null &&
                        this.HasHigherPriority(this._nodes[childLeftIndex], this._nodes[i]))
                        return false;

                    int childRightIndex = childLeftIndex + 1;
                    if (childRightIndex < this._nodes.Length && this._nodes[childRightIndex] != null &&
                        this.HasHigherPriority(this._nodes[childRightIndex], this._nodes[i]))
                        return false;
                }
            }
            return true;
        }