]> granicus.if.org Git - apache/commitdiff
standardize the syntax here
authorCliff Woolley <jwoolley@apache.org>
Wed, 14 Aug 2002 00:07:44 +0000 (00:07 +0000)
committerCliff Woolley <jwoolley@apache.org>
Wed, 14 Aug 2002 00:07:44 +0000 (00:07 +0000)
git-svn-id: https://svn.apache.org/repos/asf/httpd/httpd/trunk@96369 13f79535-47bb-0310-9956-ffa450edef68

modules/experimental/cache_pqueue.c
modules/experimental/cache_pqueue.h

index 02dcec5bde0b9c398e978da3534331619fffd78b..fbedfe75df6c3abe5a718b8bab9e0310faed2784 100644 (file)
@@ -81,14 +81,14 @@ struct cache_pqueue_t
     apr_ssize_t size;
     apr_ssize_t avail;
     apr_ssize_t step;
-    cache_pqueue_get_priority* pri;
-    cache_pqueue_getpos* get;
-    cache_pqueue_setpos* set;
+    cache_pqueue_get_priority pri;
+    cache_pqueue_getpos get;
+    cache_pqueue_setpos set;
     void **d;
 };
 
 cache_pqueue_t *cache_pq_init(apr_ssize_t n,
-                              cache_pqueue_get_priority* pri,
+                              cache_pqueue_get_priority pri,
                               cache_pqueue_getpos get,
                               cache_pqueue_setpos set)
 {
@@ -250,31 +250,16 @@ apr_status_t cache_pq_remove(cache_pqueue_t *q, void *d)
 
 void *cache_pq_pop(cache_pqueue_t *q)
 {
-    void *tmp;
-    void *d;
-    int i = 1;
-    int j;
+    void *head;
 
     if (!q || q->size == 1)
         return NULL;
 
-    d = q->d[1];
-    tmp = q->d[--q->size];
-    while (i <= q->size / 2) {
-        j = 2 * i;
-        if (j < q->size && q->pri(q->d[j]) < q->pri(q->d[j + 1])) {
-            j++;
-        }
-        if (q->pri(q->d[j]) <= q->pri(tmp)) {
-            break;
-        }
-        q->d[i] = q->d[j];
-        q->set(q->d[i], i);
-        i = j;
-    }
-    q->d[i] = tmp;
-    q->set(q->d[i], i);
-    return d;
+    head = q->d[1];
+    q->d[1] = q->d[--q->size];
+    cache_pq_percolate_down(q, 1);
+
+    return head;
 }
 
 void *cache_pq_peek(cache_pqueue_t *q)
index f3efea48788d4be1ef591ff10ee20bd10f809e78..14d2ccad6c6f72b4811c33728e72906a3ca2757a 100644 (file)
@@ -78,21 +78,21 @@ typedef struct cache_pqueue_t cache_pqueue_t;
  * @param a the element
  * @return  the score (the lower the score the longer it is kept int the queue)
  */
-typedef long cache_pqueue_set_priority(long queue_clock, void*a);
-typedef long cache_pqueue_get_priority(void*a);
+typedef long (*cache_pqueue_set_priority)(long queue_clock, void *a);
+typedef long (*cache_pqueue_get_priority)(void *a);
 
 /** callback function to get a position of a element */
-typedef apr_ssize_t cache_pqueue_getpos(void *a);
+typedef apr_ssize_t (*cache_pqueue_getpos)(void *a);
 
 /**
  * callback function to set a position of a element
  * @param a   the element
  * @param pos the position to set it to
  */
-typedef void cache_pqueue_setpos(void *a, apr_ssize_t pos);
+typedef void (*cache_pqueue_setpos)(void *a, apr_ssize_t pos);
 
 /** debug callback function to print a entry */
-typedef void cache_pqueue_print_entry(FILE *out, void *a);
+typedef void (*cache_pqueue_print_entry)(FILE *out, void *a);
 
 /**
  * initialize the queue
@@ -106,7 +106,7 @@ typedef void cache_pqueue_print_entry(FILE *out, void *a);
  * @Return the handle or NULL for insufficent memory
  */
 cache_pqueue_t *cache_pq_init(apr_ssize_t n,
-                              cache_pqueue_get_priority *pri,
+                              cache_pqueue_get_priority pri,
                               cache_pqueue_getpos get,
                               cache_pqueue_setpos set);
 /**