apr-dev mailing list archives

Site index · List index
Message view « Date » · « Thread »
Top « Date » · « Thread »
From Branko ─îibej <br...@apache.org>
Subject Re: Sorting an apr_array
Date Tue, 29 Apr 2014 04:57:07 GMT
On 28.04.2014 20:35, Jeff Trawick wrote:
> On Mon, Apr 28, 2014 at 9:16 AM, Branko ─îibej <brane@apache.org
> <mailto:brane@apache.org>> wrote:
>
>     On 28.04.2014 13:06, Nick Kew wrote:
>     > I find myself wanting to sort an APR array.
>     >
>     > As it stands I can hack it using the array innards from
>     apr_tables.h:
>     >
>     >     qsort(arr->elts, arr->nelts, arr->elt_size, my_compare);
>     >
>     > Any interest in APR-izing that into an apr_array_sort function
>     > (and a complementary apr_array_sort_r)?
>
>     Subversion uses this in any number of places. We also have
>     functions for
>     sorting hash tables into arrays, if you're looking for code examples.
>
>     -- Brane
>
>
> I'm not sure how feasible this is without writing the code, but in
> lieu of the dearth of high level array support (think of the mess of
> casting and counting asterisks) perhaps it is feasible to save a
> function with the array that can identify the "key" data in an array
> element, and sorting or testing membership or perhaps other operations
> would use the same mechanism.  I dunno.

http://svn.apache.org/viewvc/subversion/trunk/subversion/libsvn_subr/sorts.c?revision=1577079&view=markup

Look for svn_sort__array() and svn_sort__hash(), lines 138 and 146.

-- Brane


Mime
View raw message