Skip to content

Commit

Permalink
heap: Change type of "priority" in "struct heap".
Browse files Browse the repository at this point in the history
This commit changes the variable type of priority in "struct heap"
from uint32_t to uint64_t.

Signed-off-by: Alex Wang <[email protected]>
Signed-off-by: Ethan Jackson <[email protected]>
Acked-by: Ethan Jackson <[email protected]>
  • Loading branch information
yew011 authored and ejj committed Oct 17, 2013
1 parent e441a80 commit 1a29a79
Show file tree
Hide file tree
Showing 2 changed files with 9 additions and 9 deletions.
6 changes: 3 additions & 3 deletions lib/heap.c
Original file line number Diff line number Diff line change
Expand Up @@ -65,7 +65,7 @@ heap_swap(struct heap *a, struct heap *b)
*
* This takes time O(lg n). */
void
heap_insert(struct heap *heap, struct heap_node *node, uint32_t priority)
heap_insert(struct heap *heap, struct heap_node *node, uint64_t priority)
{
heap_raw_insert(heap, node, priority);
float_up(heap, node->idx);
Expand All @@ -89,7 +89,7 @@ heap_remove(struct heap *heap, struct heap_node *node)
*
* This takes time O(lg n). */
void
heap_change(struct heap *heap, struct heap_node *node, uint32_t priority)
heap_change(struct heap *heap, struct heap_node *node, uint64_t priority)
{
heap_raw_change(node, priority);
float_up_or_down(heap, node->idx);
Expand All @@ -104,7 +104,7 @@ heap_change(struct heap *heap, struct heap_node *node, uint32_t priority)
*
* This takes time O(1). */
void
heap_raw_insert(struct heap *heap, struct heap_node *node, uint32_t priority)
heap_raw_insert(struct heap *heap, struct heap_node *node, uint64_t priority)
{
if (heap->n >= heap->allocated) {
heap->allocated = heap->n == 0 ? 1 : 2 * heap->n;
Expand Down
12 changes: 6 additions & 6 deletions lib/heap.h
Original file line number Diff line number Diff line change
Expand Up @@ -24,7 +24,7 @@
/* A heap node, to be embedded inside the data structure in the heap. */
struct heap_node {
size_t idx;
uint32_t priority;
uint64_t priority;
};

/* A max-heap. */
Expand All @@ -43,8 +43,8 @@ static inline size_t heap_count(const struct heap *);
static inline bool heap_is_empty(const struct heap *);

/* Insertion and deletion. */
void heap_insert(struct heap *, struct heap_node *, uint32_t priority);
void heap_change(struct heap *, struct heap_node *, uint32_t priority);
void heap_insert(struct heap *, struct heap_node *, uint64_t priority);
void heap_change(struct heap *, struct heap_node *, uint64_t priority);
void heap_remove(struct heap *, struct heap_node *);
static inline struct heap_node *heap_pop(struct heap *);

Expand All @@ -54,8 +54,8 @@ static inline struct heap_node *heap_max(const struct heap *);
/* The "raw" functions below do not preserve the heap invariants. After you
* call them, heap_max() will not necessarily return the right value until you
* subsequently call heap_rebuild(). */
void heap_raw_insert(struct heap *, struct heap_node *, uint32_t priority);
static inline void heap_raw_change(struct heap_node *, uint32_t priority);
void heap_raw_insert(struct heap *, struct heap_node *, uint64_t priority);
static inline void heap_raw_change(struct heap_node *, uint64_t priority);
void heap_raw_remove(struct heap *, struct heap_node *);
void heap_rebuild(struct heap *);

Expand Down Expand Up @@ -155,7 +155,7 @@ heap_pop(struct heap *heap)
*
* This takes time O(1). */
static inline void
heap_raw_change(struct heap_node *node, uint32_t priority)
heap_raw_change(struct heap_node *node, uint64_t priority)
{
node->priority = priority;
}
Expand Down

0 comments on commit 1a29a79

Please sign in to comment.