svn_sorts.h

Go to the documentation of this file.
00001 /**
00002  * @copyright
00003  * ====================================================================
00004  *    Licensed to the Apache Software Foundation (ASF) under one
00005  *    or more contributor license agreements.  See the NOTICE file
00006  *    distributed with this work for additional information
00007  *    regarding copyright ownership.  The ASF licenses this file
00008  *    to you under the Apache License, Version 2.0 (the
00009  *    "License"); you may not use this file except in compliance
00010  *    with the License.  You may obtain a copy of the License at
00011  *
00012  *      http://www.apache.org/licenses/LICENSE-2.0
00013  *
00014  *    Unless required by applicable law or agreed to in writing,
00015  *    software distributed under the License is distributed on an
00016  *    "AS IS" BASIS, WITHOUT WARRANTIES OR CONDITIONS OF ANY
00017  *    KIND, either express or implied.  See the License for the
00018  *    specific language governing permissions and limitations
00019  *    under the License.
00020  * ====================================================================
00021  * @endcopyright
00022  *
00023  * @file svn_sorts.h
00024  * @brief all sorts of sorts.
00025  */
00026 
00027 
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 
00052 /** This structure is used to hold a key/value from a hash table.
00053  * @note Private. For use by Subversion's own code only. See issue #1644.
00054  */
00055 typedef struct svn_sort__item_t svn_sort__item_t;
00056 
00057 
00058 /** Compare two @c svn_sort__item_t's, returning an integer greater than,
00059  * equal to, or less than 0, according to whether the key of @a a is
00060  * greater than, equal to, or less than the key of @a b as determined
00061  * by comparing them with svn_path_compare_paths().
00062  *
00063  * The key strings must be NULL-terminated, even though klen does not
00064  * include the terminator.
00065  *
00066  * This is useful for converting a hash into a sorted
00067  * @c apr_array_header_t.  For example, to convert hash @a hsh to a sorted
00068  * array, do this:
00069  *
00070  * @code
00071      apr_array_header_t *array;
00072      array = svn_sort__hash(hsh, svn_sort_compare_items_as_paths, pool);
00073    @endcode
00074  *
00075  * This function works like svn_sort_compare_items_lexically() except that it
00076  * orders children in subdirectories directly after their parents. This allows
00077  * using the given ordering for a depth first walk, but at a performance
00078  * penalty. Code that doesn't need this special behavior for children, e.g. when
00079  * sorting files at a single directory level should use
00080  * svn_sort_compare_items_lexically() instead.
00081  */
00082 int
00083 svn_sort_compare_items_as_paths(const svn_sort__item_t *a,
00084                                 const svn_sort__item_t *b);
00085 
00086 
00087 /** Compare two @c svn_sort__item_t's, returning an integer greater than,
00088  * equal to, or less than 0, according as @a a is greater than, equal to,
00089  * or less than @a b according to a lexical key comparison.  The keys are
00090  * not required to be zero-terminated.
00091  */
00092 int
00093 svn_sort_compare_items_lexically(const svn_sort__item_t *a,
00094                                  const svn_sort__item_t *b);
00095 
00096 /** Compare two @c svn_revnum_t's, returning an integer greater than, equal
00097  * to, or less than 0, according as @a b is greater than, equal to, or less
00098  * than @a a. Note that this sorts newest revision to oldest (IOW, descending
00099  * order).
00100  *
00101  * This function is compatible for use with qsort().
00102  *
00103  * This is useful for converting an array of revisions into a sorted
00104  * @c apr_array_header_t. You are responsible for detecting, preventing or
00105  * removing duplicates.
00106  */
00107 int
00108 svn_sort_compare_revisions(const void *a,
00109                            const void *b);
00110 
00111 
00112 /**
00113  * Compare two @c const char * paths, @a *a and @a *b, returning an
00114  * integer greater than, equal to, or less than 0, using the same
00115  * comparison rules as are used by svn_path_compare_paths().
00116  *
00117  * This function is compatible for use with qsort().
00118  *
00119  * @since New in 1.1.
00120  */
00121 int
00122 svn_sort_compare_paths(const void *a,
00123                        const void *b);
00124 
00125 /**
00126  * Compare two @c svn_merge_range_t *'s, @a *a and @a *b, returning an
00127  * integer greater than, equal to, or less than 0 if the first range is
00128  * greater than, equal to, or less than, the second range.
00129  *
00130  * Both @c svn_merge_range_t *'s must describe forward merge ranges.
00131  *
00132  * If @a *a and @a *b intersect then the range with the lower start revision
00133  * is considered the lesser range.  If the ranges' start revisions are
00134  * equal then the range with the lower end revision is considered the
00135  * lesser range.
00136  *
00137  * @since New in 1.5
00138  */
00139 int
00140 svn_sort_compare_ranges(const void *a,
00141                         const void *b);
00142 
00143 #ifdef __cplusplus
00144 }
00145 #endif /* __cplusplus */
00146 
00147 #endif /* SVN_SORTS_H */

Generated on Tue Aug 4 16:58:20 2015 for Subversion by  doxygen 1.4.7