apr-dev mailing list archives

Site index · List index
Message view « Date » · « Thread »
Top « Date » · « Thread »
From "Mladen Turk" <mt...@mappingsoft.com>
Subject [ADDON] apr_hlist -- Was [PATCH] apr_hash.c
Date Thu, 11 Oct 2001 17:33:56 GMT
Hi,

This is the apr_hash on steroids :)

It enables to do 'worker' things like:

static int lwr_worker( const void **key, apr_ssize_t klen, void **val)
{
	if (!key)
	return -1;
	*val = strlwr(*val);
	return 0;
}
...

apr_hlist_walk(list, lwr_worker);

or sorting:

static int sort_icase(apr_hlist_entry_t *a, apr_hlist_entry_t *b)
{
	const void *n1, *n2;
	apr_ssize_t  l1, l2;
	apr_hlist_entry(a, &n1, &l1, NULL);
	apr_hlist_entry(b, &n2, &l2, NULL);
	return strnicmp(n1, n2, l1 < l2 ? l1 : l2);
}
...
/* now sort the list */
apr_hlist_sort(list, sort_icase);

Don't now if anyone would find it usefull, but here it is :)

MT.

Mime
View raw message