debian: new upstream point release
[git/debian.git] / reftable / pq.h
blobf796c2317948be2c82aaa15c29b5e9aba1730168
1 /*
2 Copyright 2020 Google LLC
4 Use of this source code is governed by a BSD-style
5 license that can be found in the LICENSE file or at
6 https://developers.google.com/open-source/licenses/bsd
7 */
9 #ifndef PQ_H
10 #define PQ_H
12 #include "record.h"
14 struct pq_entry {
15 size_t index;
16 struct reftable_record *rec;
19 struct merged_iter_pqueue {
20 struct pq_entry *heap;
21 size_t len;
22 size_t cap;
25 void merged_iter_pqueue_check(struct merged_iter_pqueue pq);
26 struct pq_entry merged_iter_pqueue_remove(struct merged_iter_pqueue *pq);
27 void merged_iter_pqueue_add(struct merged_iter_pqueue *pq, const struct pq_entry *e);
28 void merged_iter_pqueue_release(struct merged_iter_pqueue *pq);
29 int pq_less(struct pq_entry *a, struct pq_entry *b);
31 static inline struct pq_entry merged_iter_pqueue_top(struct merged_iter_pqueue pq)
33 return pq.heap[0];
36 static inline int merged_iter_pqueue_is_empty(struct merged_iter_pqueue pq)
38 return pq.len == 0;
41 #endif