Преглед изворни кода

Changed _Bool to bool

ahc_fix_select
tedbullock пре 17 година
родитељ
комит
9368c8cbd4
2 измењених фајлова са 17 додато и 19 уклоњено
  1. +11
    -13
      httperf/src/lib/heap.c
  2. +6
    -6
      httperf/src/lib/heap.h

+ 11
- 13
httperf/src/lib/heap.c Прегледај датотеку

@@ -31,7 +31,6 @@
#include "config.h"

#include <stdlib.h>
#include <stdbool.h>

#include <generic_types.h>

@@ -40,12 +39,12 @@
struct Heap {
u_long array_size;
u_long num_elements;
_Bool (*compare)(Any_Type, Any_Type);
bool (*compare) (Any_Type, Any_Type);
Any_Type storage[]; /* c99 Flexible Array Member */
};

struct Heap *
create_heap(u_long size, _Bool (*compare_callback) (Any_Type, Any_Type))
create_heap(u_long size, bool(*compare_callback) (Any_Type, Any_Type))
{
struct Heap *h;

@@ -66,13 +65,13 @@ create_heap(u_long size, _Bool (*compare_callback) (Any_Type, Any_Type))
return h;
}

_Bool
bool
is_heap_empty(struct Heap * h)
{
return h->num_elements == 0;
}

_Bool
bool
is_heap_full(struct Heap * h)
{
return h->array_size == h->num_elements;
@@ -92,7 +91,7 @@ free_heap(struct Heap *h)
}

#define PARENT(i) (i/2)
_Bool
bool
insert(Any_Type a, struct Heap *h)
{
u_long i, parent;
@@ -134,15 +133,15 @@ percolate(struct Heap *h, u_long hole)
}

Any_Type
remove_min(struct Heap * h)
remove_min(struct Heap *h)
{
if(is_heap_empty(h))
if (is_heap_empty(h))
return (Any_Type) 0;
else {
Any_Type min = h->storage[1];
h->storage[1] = h->storage[h->num_elements--];
percolate(h, 1);
return min;
}
}
@@ -150,7 +149,7 @@ remove_min(struct Heap * h)
Any_Type
poll_min(struct Heap * h)
{
if(is_heap_empty(h))
if (is_heap_empty(h))
return (Any_Type) 0;
else
return h->storage[1];
@@ -159,8 +158,7 @@ poll_min(struct Heap * h)
void
heap_for_each(struct Heap *h, void (*action) (Any_Type))
{
for(u_long i = 1; i <= h->num_elements; i++)
{
(*action)(h->storage[i]);
for (u_long i = 1; i <= h->num_elements; i++) {
(*action) (h->storage[i]);
}
}

+ 6
- 6
httperf/src/lib/heap.h Прегледај датотеку

@@ -33,18 +33,18 @@

struct Heap;

typedef _Bool (*heap_compare) (Any_Type, Any_Type);
typedef bool(*heap_compare) (Any_Type, Any_Type);
typedef void (*heap_for_each_action) (Any_Type);

struct Heap *create_heap(u_long, heap_compare);
_Bool is_heap_empty(struct Heap *);
_Bool is_heap_full(struct Heap *);
bool is_heap_empty(struct Heap *);
bool is_heap_full(struct Heap *);
u_long num_heap_elements(struct Heap *);
void free_heap(struct Heap *);

_Bool insert(Any_Type, struct Heap *);
Any_Type remove_min(struct Heap *);
Any_Type poll_min(struct Heap *);
bool insert(Any_Type, struct Heap *);
Any_Type remove_min(struct Heap *);
Any_Type poll_min(struct Heap *);

void heap_for_each(struct Heap *, heap_for_each_action);



Loading…
Откажи
Сачувај