- PriorityQueue* pq = priorityqueue_new(int, MIN_T, 3);
-
- priorityqueue_insert(pq, 1, 1.0);
- priorityqueue_insert(pq, 2, 3.0);
- priorityqueue_insert(pq, 3, 2.0);
- priorityqueue_insert(pq, 4, 4.0);
- priorityqueue_insert(pq, 5, 0.0);
-
- int a;
- priorityqueue_peek(pq, a);
- lu_assert_int_eq(a, 5); //5 has "highest" priority (0.0, MIN_T)
- priorityqueue_pop(pq);
- priorityqueue_peek(pq, a);
- lu_assert_int_eq(a, 1); //1 -> 1.0
- priorityqueue_pop(pq);
- priorityqueue_peek(pq, a);
- lu_assert_int_eq(a, 3); //3 -> 2.0
- priorityqueue_pop(pq);
- priorityqueue_peek(pq, a);
- lu_assert_int_eq(a, 2); //2 -> 3.0
- priorityqueue_pop(pq);
- priorityqueue_peek(pq, a);
- lu_assert_int_eq(a, 4); //4 -> 4.0
- priorityqueue_pop(pq);
- lu_assert(priorityqueue_empty(pq));
-
- pq->heap->hType = MAX_T; //HACK... (why not?)
- priorityqueue_insert(pq, 1, 1.0);
- priorityqueue_insert(pq, 2, 3.0);
- priorityqueue_insert(pq, 3, 2.0);
- priorityqueue_insert(pq, 4, 4.0);
- priorityqueue_insert(pq, 5, 0.0);
- priorityqueue_insert(pq, 6, 0.0);
- priorityqueue_insert(pq, 7, 6.0);
- priorityqueue_remove(pq, 6);
- priorityqueue_remove(pq, 7);
- priorityqueue_set(pq, 3, 5.0);
- priorityqueue_set(pq, 5, 2.0);
-
- priorityqueue_peek(pq, a);
- lu_assert_int_eq(a, 3); //3 has highest priority (5.0, MAX_T)
- priorityqueue_pop(pq);
- priorityqueue_peek(pq, a);
- lu_assert_int_eq(a, 4); //4 -> 4.0
- priorityqueue_pop(pq);
- priorityqueue_peek(pq, a);
- lu_assert_int_eq(a, 2); //2 -> 3.0
- priorityqueue_pop(pq);
- priorityqueue_peek(pq, a);
- lu_assert_int_eq(a, 5); //5 -> 2.0
- priorityqueue_pop(pq);
- priorityqueue_peek(pq, a);
- lu_assert_int_eq(a, 1); // 1 -> 1.0
- priorityqueue_pop(pq);
-
- lu_assert(priorityqueue_empty(pq));
- priorityqueue_destroy(pq);
+ PriorityQueue* pq = priorityqueue_new(int, MIN_T, 3);
+
+ priorityqueue_insert(pq, 1, 1.0);
+ priorityqueue_insert(pq, 2, 3.0);
+ priorityqueue_insert(pq, 3, 2.0);
+ priorityqueue_insert(pq, 4, 4.0);
+ priorityqueue_insert(pq, 5, 0.0);
+
+ int a;
+ priorityqueue_peek(pq, a);
+ lu_assert_int_eq(a, 5); //5 has "highest" priority (0.0, MIN_T)
+ priorityqueue_pop(pq);
+ priorityqueue_peek(pq, a);
+ lu_assert_int_eq(a, 1); //1 -> 1.0
+ priorityqueue_pop(pq);
+ priorityqueue_peek(pq, a);
+ lu_assert_int_eq(a, 3); //3 -> 2.0
+ priorityqueue_pop(pq);
+ priorityqueue_peek(pq, a);
+ lu_assert_int_eq(a, 2); //2 -> 3.0
+ priorityqueue_pop(pq);
+ priorityqueue_peek(pq, a);
+ lu_assert_int_eq(a, 4); //4 -> 4.0
+ priorityqueue_pop(pq);
+ lu_assert(priorityqueue_empty(pq));
+
+ pq->heap->hType = MAX_T; //HACK... (why not?)
+ priorityqueue_insert(pq, 1, 1.0);
+ priorityqueue_insert(pq, 2, 3.0);
+ priorityqueue_insert(pq, 3, 2.0);
+ priorityqueue_insert(pq, 4, 4.0);
+ priorityqueue_insert(pq, 5, 0.0);
+ priorityqueue_insert(pq, 6, 0.0);
+ priorityqueue_insert(pq, 7, 6.0);
+ priorityqueue_remove(pq, 6);
+ priorityqueue_remove(pq, 7);
+ priorityqueue_set(pq, 3, 5.0);
+ priorityqueue_set(pq, 5, 2.0);
+
+ priorityqueue_peek(pq, a);
+ lu_assert_int_eq(a, 3); //3 has highest priority (5.0, MAX_T)
+ priorityqueue_pop(pq);
+ priorityqueue_peek(pq, a);
+ lu_assert_int_eq(a, 4); //4 -> 4.0
+ priorityqueue_pop(pq);
+ priorityqueue_peek(pq, a);
+ lu_assert_int_eq(a, 2); //2 -> 3.0
+ priorityqueue_pop(pq);
+ priorityqueue_peek(pq, a);
+ lu_assert_int_eq(a, 5); //5 -> 2.0
+ priorityqueue_pop(pq);
+ priorityqueue_peek(pq, a);
+ lu_assert_int_eq(a, 1); // 1 -> 1.0
+ priorityqueue_pop(pq);
+
+ lu_assert(priorityqueue_empty(pq));
+ priorityqueue_destroy(pq);