-
Notifications
You must be signed in to change notification settings - Fork 5
Expand file tree
/
Copy pathpqueue.h
More file actions
52 lines (41 loc) · 1.12 KB
/
Copy pathpqueue.h
File metadata and controls
52 lines (41 loc) · 1.12 KB
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
// Copyright 2023 Joshua J Baker. All rights reserved.
// Use of this source code is governed by an MIT-style
// license that can be found in the LICENSE file.
#ifndef PQUEUE_H
#define PQUEUE_H
#include <stdbool.h>
#include <stddef.h>
#include "modules.h"
struct pqueue;
/**
* @brief 返回一个新的队列,如果内存不足,则返回 NULL
*/
struct pqueue* pqueue_new(size_t elsize,
int (*compare)(const void* a, const void* b,
void* udata),
void* udata);
/**
* @brief 释放队列
*/
void pqueue_free(struct pqueue* queue);
/**
* @brief 清空队列
*/
void pqueue_clear(struct pqueue* queue);
/**
* @brief 将一个项插入队列。如果内存不足,返回 false
*/
bool pqueue_push(struct pqueue* queue, const void* item);
/**
* @brief 返回队列中的项数
*/
size_t pqueue_count(const struct pqueue* queue);
/**
* @brief 返回最小项,但不删除它
*/
const void* pqueue_peek(const struct pqueue* queue);
/**
* @brief 删除最小项并返回它
*/
const void* pqueue_pop(struct pqueue* queue);
#endif