tlds
Transactional Operations for Linked Data Structures
 All Classes Namespaces Files Functions Variables Typedefs Enumerations Enumerator Friends Macros
heap.h
Go to the documentation of this file.
1 /* =============================================================================
2  *
3  * heap.c
4  *
5  * =============================================================================
6  *
7  * Copyright (C) Stanford University, 2006. All Rights Reserved.
8  * Author: Chi Cao Minh
9  *
10  * =============================================================================
11  *
12  * For the license of bayes/sort.h and bayes/sort.c, please see the header
13  * of the files.
14  *
15  * ------------------------------------------------------------------------
16  *
17  * For the license of kmeans, please see kmeans/LICENSE.kmeans
18  *
19  * ------------------------------------------------------------------------
20  *
21  * For the license of ssca2, please see ssca2/COPYRIGHT
22  *
23  * ------------------------------------------------------------------------
24  *
25  * For the license of lib/mt19937ar.c and lib/mt19937ar.h, please see the
26  * header of the files.
27  *
28  * ------------------------------------------------------------------------
29  *
30  * For the license of lib/rbtree.h and lib/rbtree.c, please see
31  * lib/LEGALNOTICE.rbtree and lib/LICENSE.rbtree
32  *
33  * ------------------------------------------------------------------------
34  *
35  * Unless otherwise noted, the following license applies to STAMP files:
36  *
37  * Copyright (c) 2007, Stanford University
38  * All rights reserved.
39  *
40  * Redistribution and use in source and binary forms, with or without
41  * modification, are permitted provided that the following conditions are
42  * met:
43  *
44  * * Redistributions of source code must retain the above copyright
45  * notice, this list of conditions and the following disclaimer.
46  *
47  * * Redistributions in binary form must reproduce the above copyright
48  * notice, this list of conditions and the following disclaimer in
49  * the documentation and/or other materials provided with the
50  * distribution.
51  *
52  * * Neither the name of Stanford University nor the names of its
53  * contributors may be used to endorse or promote products derived
54  * from this software without specific prior written permission.
55  *
56  * THIS SOFTWARE IS PROVIDED BY STANFORD UNIVERSITY ``AS IS'' AND ANY
57  * EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE
58  * IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR
59  * PURPOSE ARE DISCLAIMED. IN NO EVENT SHALL STANFORD UNIVERSITY BE LIABLE
60  * FOR ANY DIRECT, INDIRECT, INCIDENTAL, SPECIAL, EXEMPLARY, OR
61  * CONSEQUENTIAL DAMAGES (INCLUDING, BUT NOT LIMITED TO, PROCUREMENT OF
62  * SUBSTITUTE GOODS OR SERVICES; LOSS OF USE, DATA, OR PROFITS; OR BUSINESS
63  * INTERRUPTION) HOWEVER CAUSED AND ON ANY THEORY OF LIABILITY, WHETHER IN
64  * CONTRACT, STRICT LIABILITY, OR TORT (INCLUDING NEGLIGENCE OR OTHERWISE)
65  * ARISING IN ANY WAY OUT OF THE USE OF THIS SOFTWARE, EVEN IF ADVISED OF
66  * THE POSSIBILITY OF SUCH DAMAGE.
67  *
68  * =============================================================================
69  */
70 
71 
72 #ifndef HEAP_H
73 #define HEAP_H 1
74 
75 
76 #include "tm.h"
77 #include "types.h"
78 #include "lehigh.h"
79 
80 typedef struct heap heap_t;
81 
82 
83 /* =============================================================================
84  * heap_alloc
85  * -- Returns NULL on failure
86  * =============================================================================
87  */
88 heap_t*
89 heap_alloc (long initCapacity, comparator_t* compare);
90 heap_t*
91 TMheap_alloc (TM_ARGDECL long initCapacity, comparator_t* compare);
92 
93 
94 
95 /* =============================================================================
96  * heap_free
97  * =============================================================================
98  */
99 void
100 heap_free (heap_t* heapPtr);
101 
102 
103 /* =============================================================================
104  * heap_insert
105  * -- Returns FALSE on failure
106  * =============================================================================
107  */
108 bool_t
109 heap_insert (heap_t* heapPtr, void* dataPtr);
110 
111 
112 /* =============================================================================
113  * TMheap_insert
114  * -- Returns FALSE on failure
115  * =============================================================================
116  */
118 bool_t
119 TMheap_insert (TM_ARGDECL heap_t* heapPtr, void* dataPtr);
120 
121 
122 /* =============================================================================
123  * heap_remove
124  * -- Returns NULL if empty
125  * =============================================================================
126  */
127 void*
128 heap_remove (heap_t* heapPtr);
129 
130 
131 /* =============================================================================
132  * TMheap_remove
133  * -- Returns NULL if empty
134  * =============================================================================
135  */
137 void*
138 TMheap_remove (TM_ARGDECL heap_t* heapPtr);
139 
140 
141 /* =============================================================================
142  * heap_isValid
143  * =============================================================================
144  */
145 bool_t
146 heap_isValid (heap_t* heapPtr);
147 
148 
149 #define TMHEAP_INSERT(h, d) TMheap_insert(TM_ARG (h), (d))
150 #define TMHEAP_REMOVE(h) TMheap_remove(TM_ARG (h))
151 
152 
153 #endif /* HEAP_H */
154 
155 
156 /* =============================================================================
157  *
158  * End of heap.c
159  *
160  * =============================================================================
161  */
#define TM_CALLABLE
Definition: cxxtm.hpp:32
comparator_t * compare
Definition: heap.c:82
heap_t * heap_alloc(long initCapacity, comparator_t *compare)
Definition: heap.c:110
int bool_t
Definition: portable_defns.h:32
#define TM_ARGDECL
Definition: tm.h:532
TM_CALLABLE bool_t TMheap_insert(TM_ARGDECL heap_t *heapPtr, void *dataPtr)
Definition: heap.c:250
void * heap_remove(heap_t *heapPtr)
Definition: heap.c:382
void heap_free(heap_t *heapPtr)
Definition: heap.c:151
bool_t heap_insert(heap_t *heapPtr, void *dataPtr)
Definition: heap.c:215
TM_CALLABLE void * TMheap_remove(TM_ARGDECL heap_t *heapPtr)
Definition: heap.c:406
Definition: heap.c:78
Definition: lehigh.h:29
heap_t * TMheap_alloc(TM_ARGDECL long initCapacity, comparator_t *compare)
Definition: heap.c:128
bool_t heap_isValid(heap_t *heapPtr)
Definition: heap.c:429