ATLAS Offline Software
Toggle main menu visibility
Loading...
Searching...
No Matches
Control
CxxUtils
CxxUtils
libcalg
binary-heap.h
Go to the documentation of this file.
1
/*
2
3
Copyright (c) 2005-2008, Simon Howard
4
5
Permission to use, copy, modify, and/or distribute this software
6
for any purpose with or without fee is hereby granted, provided
7
that the above copyright notice and this permission notice appear
8
in all copies.
9
10
THE SOFTWARE IS PROVIDED "AS IS" AND THE AUTHOR DISCLAIMS ALL
11
WARRANTIES WITH REGARD TO THIS SOFTWARE INCLUDING ALL IMPLIED
12
WARRANTIES OF MERCHANTABILITY AND FITNESS. IN NO EVENT SHALL THE
13
AUTHOR BE LIABLE FOR ANY SPECIAL, DIRECT, INDIRECT, OR
14
CONSEQUENTIAL DAMAGES OR ANY DAMAGES WHATSOEVER RESULTING FROM
15
LOSS OF USE, DATA OR PROFITS, WHETHER IN AN ACTION OF CONTRACT,
16
NEGLIGENCE OR OTHER TORTIOUS ACTION, ARISING OUT OF OR IN
17
CONNECTION WITH THE USE OR PERFORMANCE OF THIS SOFTWARE.
18
19
*/
20
37
38
#ifndef ALGORITHM_BINARY_HEAP_H
39
#define ALGORITHM_BINARY_HEAP_H
40
41
#ifdef __cplusplus
42
extern
"C"
{
43
#endif
44
52
53
typedef
enum
{
55
56
BINARY_HEAP_TYPE_MIN
,
57
59
60
BINARY_HEAP_TYPE_MAX
61
}
BinaryHeapType
;
62
66
67
typedef
void
*
BinaryHeapValue
;
68
72
73
#define BINARY_HEAP_NULL ((void *) 0)
74
84
85
typedef
int (*
BinaryHeapCompareFunc
)(
BinaryHeapValue
value1,
86
BinaryHeapValue
value2);
87
91
92
typedef
struct
_BinaryHeap
BinaryHeap
;
93
103
104
BinaryHeap
*
binary_heap_new
(
BinaryHeapType
heap_type,
105
BinaryHeapCompareFunc
compare_func);
106
112
113
void
binary_heap_free
(
BinaryHeap
*heap);
114
124
125
int
binary_heap_insert
(
BinaryHeap
*heap,
BinaryHeapValue
value);
126
134
135
BinaryHeapValue
binary_heap_pop
(
BinaryHeap
*heap);
136
143
144
int
binary_heap_num_entries
(
BinaryHeap
*heap);
145
146
#ifdef __cplusplus
147
}
148
#endif
149
150
#endif
/* #ifndef ALGORITHM_BINARY_HEAP_H */
151
BinaryHeapValue
void * BinaryHeapValue
A value stored in a BinaryHeap.
Definition
binary-heap.h:67
BinaryHeapCompareFunc
int(* BinaryHeapCompareFunc)(BinaryHeapValue value1, BinaryHeapValue value2)
Type of function used to compare values in a binary heap.
Definition
binary-heap.h:85
BinaryHeap
struct _BinaryHeap BinaryHeap
A binary heap data structure.
Definition
binary-heap.h:92
binary_heap_num_entries
int binary_heap_num_entries(BinaryHeap *heap)
Find the number of values stored in a binary heap.
binary_heap_insert
int binary_heap_insert(BinaryHeap *heap, BinaryHeapValue value)
Insert a value into a binary heap.
binary_heap_new
BinaryHeap * binary_heap_new(BinaryHeapType heap_type, BinaryHeapCompareFunc compare_func)
Create a new BinaryHeap.
binary_heap_free
void binary_heap_free(BinaryHeap *heap)
Destroy a binary heap.
binary_heap_pop
BinaryHeapValue binary_heap_pop(BinaryHeap *heap)
Remove the first value from a binary heap.
BinaryHeapType
BinaryHeapType
Heap type.
Definition
binary-heap.h:53
BINARY_HEAP_TYPE_MAX
@ BINARY_HEAP_TYPE_MAX
A maximum heap.
Definition
binary-heap.h:60
BINARY_HEAP_TYPE_MIN
@ BINARY_HEAP_TYPE_MIN
A minimum heap.
Definition
binary-heap.h:56
Generated on
for ATLAS Offline Software by
1.17.0