2N/A * The contents of this file are subject to the terms of the 2N/A * Common Development and Distribution License (the "License"). 2N/A * You may not use this file except in compliance with the License. 2N/A * See the License for the specific language governing permissions 2N/A * and limitations under the License. 2N/A * When distributing Covered Code, include this CDDL HEADER in each 2N/A * If applicable, add the following below this CDDL HEADER, with the 2N/A * fields enclosed by brackets "[]" replaced with your own identifying 2N/A * information: Portions Copyright [yyyy] [name of copyright owner] 2N/A * Copyright (c) 2009, 2011, Oracle and/or its affiliates. All rights reserved. 2N/A * Common implementation for priority queues. Currently we have only a single 2N/A * priority queue per handle, so this may be a little overboard, but this 2N/A * isolates the implementation and allows us to easily expand in the future. 2N/A * Bubble the node up until heap criteria are met. 2N/A for (; i !=
1; i = j) {
2N/A /* Swap parent and child. */ 2N/A /* Choose the child with lower priority. */ 2N/A /* Swap parent and (smaller) child. */ 2N/A * Try to shrink the table if it's more than four times the required 2N/A * size. If we can't allocate memory, just press on. 2N/A * Remove an element from the heap. This is a O(n) operation so should not be 2N/A * used for common operations. This could be improved (to O(log n)) by having 2N/A * each node keep track of its index.