Loading...
Searching...
No Matches
svn_sorts.h File Reference

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.

## Macros

#define | MAX(a, b)
#define | MIN(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, *a and *b, 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, *a and *b, 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.

## Detailed Description

all sorts of sorts.

# autotoc_md117

Definition in file svn_sorts.h.

## Macro Definition Documentation

## MAX

#define MAX | ( |  | a,
|  |  | b )

Value:
((a) < (b) ? (b) : (a))

Definition at line 38 of file svn_sorts.h.

## MIN

#define MIN | ( |  | a,
|  |  | b )

Value:
((a) < (b) ? (a) : (b))

Definition at line 43 of file svn_sorts.h.

## Typedef Documentation

## svn_sort__item_t

typedef struct svn_sort__item_t svn_sort__item_t

This structure is used to hold a key/value from a hash table.

Note
  Private. For use by Subversion's own code only. See issue #1644.

Definition at line 55 of file svn_sorts.h.

## Function Documentation

## svn_sort_compare_items_as_paths()

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 *array;
array = svn_sort__hash(hsh, svn_sort_compare_items_as_paths, pool);
svn_sort_compare_items_as_paths
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,...

This function works like svn_sort_compare_items_lexically() except that it orders children in subdirectories directly after their parents. This allows using the given ordering for a depth first walk, but at a performance penalty. Code that doesn't need this special behavior for children, e.g. when sorting files at a single directory level should use svn_sort_compare_items_lexically() instead.

## svn_sort_compare_items_lexically()

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.

## svn_sort_compare_paths()

int svn_sort_compare_paths | ( | const void * | a,
|  | const void * | b )

Compare two `const` char * paths, *a and *b, 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().

Since
  New in 1.1.

## svn_sort_compare_ranges()

int svn_sort_compare_ranges | ( | const void * | a,
|  | const void * | b )

Compare two `svn_merge_range_t` *'s, *a and *b, 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.

Since
  New in 1.5

## svn_sort_compare_revisions()

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.