00001 /* 00002 * Copyright 1999-2006 University of Chicago 00003 * 00004 * Licensed under the Apache License, Version 2.0 (the "License"); 00005 * you may not use this file except in compliance with the License. 00006 * You may obtain a copy of the License at 00007 * 00008 * http://www.apache.org/licenses/LICENSE-2.0 00009 * 00010 * Unless required by applicable law or agreed to in writing, software 00011 * distributed under the License is distributed on an "AS IS" BASIS, 00012 * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. 00013 * See the License for the specific language governing permissions and 00014 * limitations under the License. 00015 */ 00016 00022 #ifndef GLOBUS_PRIORITY_Q_H 00023 #define GLOBUS_PRIORITY_Q_H 00024 00025 #include "globus_types.h" 00026 #include "globus_memory.h" 00027 00028 #ifdef __cplusplus 00029 extern "C" { 00030 #endif 00031 00086 typedef int (*globus_priority_q_cmp_func_t)( 00087 void * priority_1, 00088 void * priority_2); 00089 00098 typedef struct globus_priority_q_s 00099 { 00100 struct globus_l_priority_q_entry_s ** heap; 00101 int next_slot; 00102 size_t max_len; 00103 globus_memory_t memory; 00104 globus_priority_q_cmp_func_t cmp_func; 00105 } globus_priority_q_t; 00106 00107 int 00108 globus_priority_q_init( 00109 globus_priority_q_t * priority_q, 00110 globus_priority_q_cmp_func_t cmp_func); 00111 00112 int 00113 globus_priority_q_destroy( 00114 globus_priority_q_t * priority_q); 00115 00116 globus_bool_t 00117 globus_priority_q_empty( 00118 globus_priority_q_t * priority_q); 00119 00120 int 00121 globus_priority_q_size( 00122 globus_priority_q_t * priority_q); 00123 00124 int 00125 globus_priority_q_enqueue( 00126 globus_priority_q_t * priority_q, 00127 void * datum, 00128 void * priority); 00129 00130 void * 00131 globus_priority_q_remove( 00132 globus_priority_q_t * priority_q, 00133 void * datum); 00134 00135 /* 00136 * it is acceptable to modify the priority already stored within the queue 00137 * before making this call. The old priority is not looked at 00138 */ 00139 void * 00140 globus_priority_q_modify( 00141 globus_priority_q_t * priority_q, 00142 void * datum, 00143 void * new_priority); 00144 00145 void * 00146 globus_priority_q_dequeue( 00147 globus_priority_q_t * priority_q); 00148 00149 void * 00150 globus_priority_q_first( 00151 globus_priority_q_t * priority_q); 00152 00153 void * 00154 globus_priority_q_first_priority( 00155 globus_priority_q_t * priority_q); 00156 00157 00158 #ifdef __cplusplus 00159 } 00160 #endif 00161 00162 #endif /* GLOBUS_PRIORITY_Q_H */