7 static gint compare_int(gconstpointer a, gconstpointer b) {
8 gint i = GPOINTER_TO_INT(a), j = GPOINTER_TO_INT(b);
10 return i < j ? -1 : (i > j ? 1 : 0);
13 static int compare_ptr(gconstpointer a, gconstpointer b) {
14 return a < b ? -1 : (a > b ? 1 : 0);
17 static void rec(flxPrioQueueNode *n) {
22 g_assert(n->left->parent == n);
25 g_assert(n->right->parent == n);
28 g_assert(n->parent->left == n || n->parent->right == n);
30 if (n->parent->left == n)
31 g_assert(n->next == n->parent->right);
35 g_assert(n->queue->last == n);
37 if (n->parent && n->parent->left == n)
38 g_assert(n->parent->right == NULL);
43 int a = GPOINTER_TO_INT(n->parent->data), b = GPOINTER_TO_INT(n->data);
45 printf("%i <= %i: NO\n", a, b);
54 int main(int argc, char *argv[]) {
58 q = flx_prio_queue_new(compare_int);
59 q2 = flx_prio_queue_new(compare_ptr);
63 for (i = 0; i < 10000; i++)
64 flx_prio_queue_put(q2, flx_prio_queue_put(q, GINT_TO_POINTER(random() & 0xFFFF)));
70 g_assert(q->n_nodes == q2->n_nodes);
72 printf("%i\n", GPOINTER_TO_INT(((flxPrioQueueNode*)q2->root->data)->data));
74 flx_prio_queue_remove(q, q2->root->data);
75 flx_prio_queue_remove(q2, q2->root);
80 /* while (q->root) { */
81 /* gint v = GPOINTER_TO_INT(q->root->data); */
83 /* printf("%i\n", v); */
84 /* flx_prio_queue_remove(q, q->root); */
85 /* g_assert(v >= prev); */
89 flx_prio_queue_free(q);