Main Page | Modules | Data Structures | File List | Data Fields | Globals

svn_sorts.h

Go to the documentation of this file.
00001 /**
00002  * @copyright
00003  * ====================================================================
00004  * Copyright (c) 2000-2004 CollabNet.  All rights reserved.
00005  *
00006  * This software is licensed as described in the file COPYING, which
00007  * you should have received as part of this distribution.  The terms
00008  * are also available at http://subversion.tigris.org/license-1.html.
00009  * If newer versions of this license are posted there, you may use a
00010  * newer version instead, at your option.
00011  *
00012  * This software consists of voluntary contributions made by many
00013  * individuals.  For exact contribution history, see the revision
00014  * history and logs, available at http://subversion.tigris.org/.
00015  * ====================================================================
00016  * @endcopyright
00017  *
00018  * @file svn_sorts.h
00019  * @brief all sorts of sorts.
00020  */
00021 
00022 
00023 #ifndef SVN_SORTS_H
00024 #define SVN_SORTS_H
00025 
00026 #include <apr_pools.h>
00027 #include <apr_tables.h>         /* for apr_array_header_t */
00028 #include <apr_hash.h>
00029 
00030 
00031 #ifdef __cplusplus
00032 extern "C" {
00033 #endif /* __cplusplus */
00034 
00035 
00036 
00037 /** This structure is used to hold a key/value from a hash table.
00038  * NOTE: Private. For use by Subversion's own code only. See issue #1644.
00039  */
00040 typedef struct svn_sort__item_t {
00041   /** pointer to the key */
00042   const void *key;
00043 
00044   /** size of the key */
00045   apr_ssize_t klen;
00046 
00047   /** pointer to the value */
00048   void *value;
00049 } svn_sort__item_t;
00050 
00051 
00052 /** Compare two @c svn_sort__item_t's, returning an integer greater than,
00053  * equal to, or less than 0, according as @a a is greater than, equal to,
00054  * or less than @a b.
00055  * 
00056  * This is useful for converting a hash into a sorted
00057  * @c apr_array_header_t.  For example, to convert hash @a hsh to a sorted
00058  * array, do this:
00059  * 
00060  *<pre>   apr_array_header_t *hdr;
00061  *   hdr = svn_sort__hash (hsh, @c svn_sort_compare_items_as_paths, pool);</pre>
00062  *
00063  * The key strings must be null-terminated, even though klen does not
00064  * include the terminator.
00065  */
00066 int svn_sort_compare_items_as_paths (const svn_sort__item_t *a,
00067                                      const svn_sort__item_t *b);
00068 
00069 
00070 /** Compare two @c svn_revnum_t's, returning an integer greater than, equal
00071  * to, or less than 0, according as @a b is greater than, equal to, or less
00072  * than @a a. Note that this sorts newest revision to oldest (IOW, descending
00073  * order).
00074  *
00075  * This is useful for converting an array of revisions into a sorted
00076  * @c apr_array_header_t. You are responsible for detecting, preventing or
00077  * removing duplicates.
00078  */
00079 int svn_sort_compare_revisions (const void *a, const void *b);
00080 
00081 
00082 /** Sort @a ht according to its keys, return an @c apr_array_header_t
00083  * containing @c svn_sort__item_t structures holding those keys and values
00084  * (i.e. for each @c svn_sort__item_t @a item in the returned array,
00085  * @a item->key and @a item->size are the hash key, and @a item->data points to
00086  * the hash value).
00087  *
00088  * Storage is shared with the original hash, not copied.
00089  *
00090  * @a comparison_func should take two @c svn_sort__item_t's and return an
00091  * integer greater than, equal to, or less than 0, according as the first item
00092  * is greater than, equal to, or less than the second.
00093  *
00094  * NOTE: Private. For use by Subversion's own code only. See issue #1644.
00095  *
00096  * NOTE: This function and the @a svn_sort__item_t should go over to APR.
00097  */
00098 apr_array_header_t *
00099 svn_sort__hash (apr_hash_t *ht,
00100                 int (*comparison_func) (const svn_sort__item_t *,
00101                                         const svn_sort__item_t *),
00102                 apr_pool_t *pool);
00103 
00104 
00105 #ifdef __cplusplus
00106 }
00107 #endif /* __cplusplus */
00108 
00109 #endif /* SVN_SORTS_H */

Generated on Mon Oct 18 17:33:13 2004 for Subversion by doxygen 1.3.5