File: priority_queue.h

package info (click to toggle)
sphinxtrain 5.0.0-1
  • links: PTS, VCS
  • area: main
  • in suites: forky, sid
  • size: 32,572 kB
  • sloc: ansic: 94,052; perl: 8,939; python: 6,702; cpp: 2,044; makefile: 6
file content (45 lines) | stat: -rw-r--r-- 1,091 bytes parent folder | download | duplicates (5)
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
#ifndef __PRIORITY_QUEUE_H__
#define __PRIORITY_QUEUE_H__

#include <stdlib.h>
#include <sphinxbase/sphinxbase_export.h>

#ifdef __cplusplus
extern "C" {
#endif
#if 0
/* Fool Emacs. */
}
#endif

/**
 * Priority queue for max element tracking.
 * The one expects heap here, but for current application
 * (sorting of ngram entries one per order, i.e. maximum 10)
 * i'll put just and array here, so each operation takes linear time.
 * I swear to rework it some day!
 * TODOTODOTODOTODOTODOTODOTODOTODOTODOTODOTODOTODOTODOTODO!!!!!
 */

typedef struct priority_queue_s priority_queue_t;

SPHINXBASE_EXPORT
priority_queue_t* priority_queue_create(size_t len, int (*compare)(const void *a, const void *b));

SPHINXBASE_EXPORT
void* priority_queue_poll(priority_queue_t *queue);

SPHINXBASE_EXPORT
void priority_queue_add(priority_queue_t *queue, void *element);

SPHINXBASE_EXPORT
size_t priority_queue_size(priority_queue_t *queue);

SPHINXBASE_EXPORT
void priority_queue_free(priority_queue_t *queue, void (*free_ptr)(void *a));

#ifdef __cplusplus
}
#endif

#endif /* __PRIORITY_QUEUE_H__ */