GME
13
|
00001 00028 #ifndef SVN_SORTS_H 00029 #define SVN_SORTS_H 00030 00031 #include <apr.h> /* for apr_ssize_t */ 00032 #include <apr_pools.h> /* for apr_pool_t */ 00033 #include <apr_tables.h> /* for apr_array_header_t */ 00034 #include <apr_hash.h> /* for apr_hash_t */ 00035 00036 /* Define a MAX macro if we don't already have one */ 00037 #ifndef MAX 00038 #define MAX(a, b) ((a) < (b) ? (b) : (a)) 00039 #endif 00040 00041 /* Define a MIN macro if we don't already have one */ 00042 #ifndef MIN 00043 #define MIN(a, b) ((a) < (b) ? (a) : (b)) 00044 #endif 00045 00046 #ifdef __cplusplus 00047 extern "C" { 00048 #endif /* __cplusplus */ 00049 00050 00051 00055 typedef struct svn_sort__item_t { 00057 const void *key; 00058 00060 apr_ssize_t klen; 00061 00063 void *value; 00064 } svn_sort__item_t; 00065 00066 00091 int 00092 svn_sort_compare_items_as_paths(const svn_sort__item_t *a, 00093 const svn_sort__item_t *b); 00094 00095 00101 int 00102 svn_sort_compare_items_lexically(const svn_sort__item_t *a, 00103 const svn_sort__item_t *b); 00104 00116 int 00117 svn_sort_compare_revisions(const void *a, 00118 const void *b); 00119 00120 00130 int 00131 svn_sort_compare_paths(const void *a, 00132 const void *b); 00133 00148 int 00149 svn_sort_compare_ranges(const void *a, 00150 const void *b); 00151 00168 apr_array_header_t * 00169 svn_sort__hash(apr_hash_t *ht, 00170 int (*comparison_func)(const svn_sort__item_t *, 00171 const svn_sort__item_t *), 00172 apr_pool_t *pool); 00173 00174 /* Return the lowest index at which the element @a *key should be inserted into 00175 * the array @a array, according to the ordering defined by @a compare_func. 00176 * The array must already be sorted in the ordering defined by @a compare_func. 00177 * @a compare_func is defined as for the C stdlib function bsearch(). 00178 * 00179 * @note Private. For use by Subversion's own code only. 00180 */ 00181 int 00182 svn_sort__bsearch_lower_bound(const void *key, 00183 const apr_array_header_t *array, 00184 int (*compare_func)(const void *, const void *)); 00185 00186 /* Insert a shallow copy of @a *new_element into the array @a array at the index 00187 * @a insert_index, growing the array and shuffling existing elements along to 00188 * make room. 00189 * 00190 * @note Private. For use by Subversion's own code only. 00191 */ 00192 void 00193 svn_sort__array_insert(const void *new_element, 00194 apr_array_header_t *array, 00195 int insert_index); 00196 00197 00198 /* Remove @a elements_to_delete elements starting at @a delete_index from the 00199 * array @a arr. If @a delete_index is not a valid element of @a arr, 00200 * @a elements_to_delete is not greater than zero, or 00201 * @a delete_index + @a elements_to_delete is greater than @a arr->nelts, 00202 * then do nothing. 00203 * 00204 * @note Private. For use by Subversion's own code only. 00205 */ 00206 void 00207 svn_sort__array_delete(apr_array_header_t *arr, 00208 int delete_index, 00209 int elements_to_delete); 00210 00211 /* Reverse the order of elements in @a array, in place. 00212 * 00213 * @note Private. For use by Subversion's own code only. 00214 */ 00215 void 00216 svn_sort__array_reverse(apr_array_header_t *array, 00217 apr_pool_t *scratch_pool); 00218 00219 #ifdef __cplusplus 00220 } 00221 #endif /* __cplusplus */ 00222 00223 #endif /* SVN_SORTS_H */