summaryrefslogtreecommitdiffhomepage
path: root/examples
diff options
context:
space:
mode:
authorTyge Løvset <[email protected]>2020-07-18 20:19:20 +0200
committerTyge Løvset <[email protected]>2020-07-18 20:19:20 +0200
commitb26e0e9556a2331e99090857fdd02fa0775e53b9 (patch)
tree77fd87bbf6c4e1f9fe98d744c90a694fb7e79b98 /examples
parentc4382861b07a4d48e86b9a4cca602aacf549e912 (diff)
downloadSTC-modified-b26e0e9556a2331e99090857fdd02fa0775e53b9.tar.gz
STC-modified-b26e0e9556a2331e99090857fdd02fa0775e53b9.zip
Some API changes on vec heap.
Diffstat (limited to 'examples')
-rw-r--r--examples/geek7.c14
1 files changed, 9 insertions, 5 deletions
diff --git a/examples/geek7.c b/examples/geek7.c
index b2bda51c..4bf57174 100644
--- a/examples/geek7.c
+++ b/examples/geek7.c
@@ -22,9 +22,11 @@ After inserting all the elements excluding the ones which are to be deleted, Pop
#include <stdio.h>
#include <stc/clist.h>
#include <stc/cmap.h>
-#include <stc/cvec.h>
+#include <stc/cvecque.h>
declare_CMap(ii, int, int);
+declare_CVec(i, int);
+declare_CVec_heap(i);
// Find k minimum element from arr[0..m-1] after deleting
// elements from del[0..n-1]
@@ -39,7 +41,7 @@ void findElementsAfterDel(int arr[], int m, int del[],
cmap_ii_at(&mp, del[i], 0)->value++;
}
- priority_queue<int, vector<int>, greater<int> > heap;
+ CVec_i heap = CVec_init;
for (int i = 0; i < m; ++i) {
@@ -58,15 +60,17 @@ void findElementsAfterDel(int arr[], int m, int del[],
// Else push it in the min heap
else
- heap.push(arr[i]);
+ cvecheap_i_push(&heap, arr[i]);
+
+ CVecHeap_i Text
}
// Print top k elements in the min heap
for (int i = 0; i < k; ++i) {
- cout << heap.top() << " ";
+ printf("%d ", cvecque_i_top(&heap));
// Pop the top element
- heap.pop();
+ cvecque_i_pop(&heap);
}
}