From b323c27d886586b7ceccd5ba33091851457deec9 Mon Sep 17 00:00:00 2001 From: Panu Matilainen Date: Wed, 5 Sep 2012 10:37:28 +0300 Subject: [PATCH] Add hash table methodn for (pre)calculating base hash of a key --- lib/rpmhash.C | 5 +++++ lib/rpmhash.H | 8 ++++++++ 2 files changed, 13 insertions(+) diff --git a/lib/rpmhash.C b/lib/rpmhash.C index a307bd9a1..34a3c58da 100644 --- a/lib/rpmhash.C +++ b/lib/rpmhash.C @@ -102,6 +102,11 @@ static void HASHPREFIX(Resize)(HASHTYPE ht, int numBuckets) { ht->numBuckets = numBuckets; } +unsigned int HASHPREFIX(KeyHash)(HASHTYPE ht, HTKEYTYPE key) +{ + return ht->fn(key); +} + void HASHPREFIX(AddEntry)(HASHTYPE ht, HTKEYTYPE key #ifdef HTDATATYPE , HTDATATYPE data diff --git a/lib/rpmhash.H b/lib/rpmhash.H index e9db2ea2f..3583bdc5c 100644 --- a/lib/rpmhash.H +++ b/lib/rpmhash.H @@ -62,6 +62,14 @@ HASHTYPE HASHPREFIX(Free)( HASHTYPE ht); RPM_GNUC_INTERNAL void HASHPREFIX(Empty)(HASHTYPE ht); +/** + * Calculate hash for key. + * @param @ht pointer to hash table + * @param @key key + */ +RPM_GNUC_INTERNAL +unsigned int HASHPREFIX(KeyHash)(HASHTYPE ht, HTKEYTYPE key); + /** * Add item to hash table. * @param ht pointer to hash table