Scroll to navigation

dbh_sweep(3) DBHashTables Programmers' Manual dbh_sweep(3)
-

NAME

dbh_sweep, dbh_fanout, dbh_foreach_sweep, dbh_foreach_fanout, dbh_exit_sweep, dbh_exit_fanout - apply a function to all or part of the DBHashtable

SYNOPSIS

#include <dbh.h>

int dbh_foreach_sweep (DBHashTable *dbh, DBHashFunc operate);
int dbh_foreach_fanout (DBHashTable *dbh, DBHashFunc operate);
int dbh_sweep (DBHashTable *dbh, DBHashFunc operate, unsigned char *key1, unsigned char *key2, unsigned char ignore_portion);
int dbh_fanout (DBHashTable *dbh, DBHashFunc operate, unsigned char *key1, unsigned char *key2, unsigned char ignore_portion);
void dbh_exit_sweep (DBHashTable *dbh);
void dbh_exit_fanout (DBHashTable *dbh);

DESCRIPTION

dbh_foreach_sweep applies function operate to each member of the hash, following a sweep trajectory. Sweep is done by traversing the DBHashTable in a vertical direction through all branches.

dbh_foreach_fanout applies a function operate to each member of the hash, following a fanout trajectory. Fanout is done by traversing the DBHashTable in a horizontal direction through all records.

dbh_sweep and dbh_fanout apply a function to subtree members of the hash, where dbh_sweep follows a sweep trajectory (vertically through branches) and dbh_fanout follows a fanout trajectory (horizontally through branches).

key1 is the key from which to start the sweep or NULL if you don't care and want to start at the top. If you decide to define key1 make sure it is a top level node of a subtree. This is done with dbh_find
key2 is the key which will trigger an exit condition, or NULL if don't care and want to continue until the end of the DBHashTable
ignore_portion allows you to define the ignored trailing bytes of key1 which will define the size of the subtree to be sweeped, or zero if you don't care and want to process all branches.

In these functions, operate ( void (*operate) (DBHashTable *dbh) ) is the function to apply to each selected member of the DBHashTable

dbh_exit_sweep and dbh_exit_fanout within the operate function will cause the exit of a currently running sweep or fanout.

RETURN VALUE

0 on error, 1 otherwise.

NOTES

In order for sweep/fanout functions to be extremely fast, you should prepare the DBHashTable for the trajectory you intend to use with dbh_regen_sweep or dbh_regen_fanout first. This allows for extremely efficient use of hardware and operating system caches.

SEE ALSO

dbh (0), dbh_regen_sweep (3), dbh_regen_fanout (3), dbh_find (3), dbh_settempdir (3)

Author

Edscott Wilson Garcia <edscott@xfce.org>

DBH DBHashTables