Subversion 1.6.16
|
all sorts of sorts. More...
#include <apr.h>
#include <apr_pools.h>
#include <apr_tables.h>
#include <apr_hash.h>
Go to the source code of this file.
Data Structures | |
struct | svn_sort__item_t |
This structure is used to hold a key/value from a hash table. More... | |
Defines | |
#define | MAX(a, b) ((a) < (b) ? (b) : (a)) |
#define | MIN(a, b) ((a) < (b) ? (a) : (b)) |
Typedefs | |
typedef struct svn_sort__item_t | svn_sort__item_t |
This structure is used to hold a key/value from a hash table. | |
Functions | |
int | svn_sort_compare_items_as_paths (const svn_sort__item_t *a, const svn_sort__item_t *b) |
Compare two svn_sort__item_t's , returning an integer greater than, equal to, or less than 0, according to whether the key of a is greater than, equal to, or less than the key of b as determined by comparing them with svn_path_compare_paths(). | |
int | svn_sort_compare_items_lexically (const svn_sort__item_t *a, const svn_sort__item_t *b) |
Compare two svn_sort__item_t's , returning an integer greater than, equal to, or less than 0, according as a is greater than, equal to, or less than b according to a lexical key comparison. | |
int | svn_sort_compare_revisions (const void *a, const void *b) |
Compare two svn_revnum_t's , returning an integer greater than, equal to, or less than 0, according as b is greater than, equal to, or less than a. | |
int | svn_sort_compare_paths (const void *a, const void *b) |
Compare two const char * paths, returning an integer greater than, equal to, or less than 0, using the same comparison rules as are used by svn_path_compare_paths(). | |
int | svn_sort_compare_ranges (const void *a, const void *b) |
Compare two svn_merge_range_t *'s, returning an integer greater than, equal to, or less than 0 if the first range is greater than, equal to, or less than, the second range. | |
apr_array_header_t * | svn_sort__hash (apr_hash_t *ht, int(*comparison_func)(const svn_sort__item_t *, const svn_sort__item_t *), apr_pool_t *pool) |
Sort ht according to its keys, return an apr_array_header_t containing svn_sort__item_t structures holding those keys and values (i.e. | |
int | svn_sort__bsearch_lower_bound (const void *key, apr_array_header_t *array, int(*compare_func)(const void *, const void *)) |
void | svn_sort__array_insert (const void *new_element, apr_array_header_t *array, int insert_index) |
all sorts of sorts.
Definition in file svn_sorts.h.
typedef struct svn_sort__item_t svn_sort__item_t |
This structure is used to hold a key/value from a hash table.
apr_array_header_t* svn_sort__hash | ( | apr_hash_t * | ht, |
int(*)(const svn_sort__item_t *, const svn_sort__item_t *) | comparison_func, | ||
apr_pool_t * | pool | ||
) |
Sort ht according to its keys, return an apr_array_header_t
containing svn_sort__item_t
structures holding those keys and values (i.e.
for each svn_sort__item_t
item in the returned array, item->key and item->size are the hash key, and item->data points to the hash value).
Storage is shared with the original hash, not copied.
comparison_func should take two svn_sort__item_t's
and return an integer greater than, equal to, or less than 0, according as the first item is greater than, equal to, or less than the second.
svn_sort__item_t
should go over to APR. int svn_sort_compare_items_as_paths | ( | const svn_sort__item_t * | a, |
const svn_sort__item_t * | b | ||
) |
Compare two svn_sort__item_t's
, returning an integer greater than, equal to, or less than 0, according to whether the key of a is greater than, equal to, or less than the key of b as determined by comparing them with svn_path_compare_paths().
The key strings must be NULL-terminated, even though klen does not include the terminator.
This is useful for converting a hash into a sorted apr_array_header_t
. For example, to convert hash hsh to a sorted array, do this:
apr_array_header_t *hdr; hdr = svn_sort__hash (hsh, @c svn_sort_compare_items_as_paths, pool);
int svn_sort_compare_items_lexically | ( | const svn_sort__item_t * | a, |
const svn_sort__item_t * | b | ||
) |
Compare two svn_sort__item_t's
, returning an integer greater than, equal to, or less than 0, according as a is greater than, equal to, or less than b according to a lexical key comparison.
The keys are not required to be zero-terminated.
int svn_sort_compare_paths | ( | const void * | a, |
const void * | b | ||
) |
Compare two const
char * paths, returning an integer greater than, equal to, or less than 0, using the same comparison rules as are used by svn_path_compare_paths().
This function is compatible for use with qsort().
int svn_sort_compare_ranges | ( | const void * | a, |
const void * | b | ||
) |
Compare two svn_merge_range_t
*'s, returning an integer greater than, equal to, or less than 0 if the first range is greater than, equal to, or less than, the second range.
Both svn_merge_range_t
*'s must describe forward merge ranges.
If a and b intersect then the range with the lower start revision is considered the lesser range. If the ranges' start revisions are equal then the range with the lower end revision is considered the lesser range.
int svn_sort_compare_revisions | ( | const void * | a, |
const void * | b | ||
) |
Compare two svn_revnum_t's
, returning an integer greater than, equal to, or less than 0, according as b is greater than, equal to, or less than a.
Note that this sorts newest revision to oldest (IOW, descending order).
This function is compatible for use with qsort().
This is useful for converting an array of revisions into a sorted apr_array_header_t
. You are responsible for detecting, preventing or removing duplicates.