return hp;
}
-
/*
* Free memory used by a heap. Does not free the metadata pointed to by the
* heap nodes, only the heap's internal memory.
return elm;
}
-
/*
* Delete ELM while maintaining the heap property. ELM may be modified.
* Assumes that ELM is not NULL and frees it. Returns the data pointed to
}
#endif /* heap_gen_key */
-
/*
* Returns the data of the node with the largest KEY value and removes that
* node from the heap. Returns NULL if the heap was empty.
return data;
}
-
/*
* Remove the last node in HP. Frees the heap internal structure and
* returns the data pointes to by the last node.
return data;
}
-
/*
* The semantics of this routine is the same as the followings:
* heap_delete(hp, elm);
return old;
}
-
/*
* A pointer to the root node's DATA.
*/
return hp->nodes[0]->data;
}
-
/*
* The KEY of the root node.
*/
return hp->nodes[0]->key;
}
-
/*
* Same as heap_peep except that this return the KEY of the node.
* Only meant for iteration.
return hp->nodes[n]->key;
}
-
/*
* A pointer to Nth node's DATA. The caller can iterate through HP by
* calling this routine. eg. Caller can execute the following code:
return data;
}
-
#ifndef heap_nodes
/*
* Current number of nodes in HP.
}
#endif /* heap_nodes */
-
#ifndef heap_empty
/*
* Determine if the heap is empty. Returns 1 if HP has no elements and 0
}
}
-
/*
* Maintain the heap property above ELM. Caller has locked the heap.
*/
}
}
-
/*
* Swap the position of ELM1 and ELM2 in heap structure. Their IDs are also
* swapped.
hp->nodes[elm2->id] = elm2;
}
-
-
#ifdef NOTDEF
/*
* Copy KEY and DATA fields of SRC to DEST. ID field is NOT copied.
#endif /* NOTDEF */
-
/*
* True if HP needs to be grown in size.
*/
return 0;
}
-
/*
* Grow HP.
*/
hp->size = newSize;
}
-
/*
* True if a node with ID exists in HP.
*/