From aafd8500d3235b1c8e54c838924c3f5b490c9148 Mon Sep 17 00:00:00 2001 From: Florian Festi Date: Wed, 5 May 2010 12:48:41 +0200 Subject: [PATCH] rpmhash: Accessor functions for the size and usage --- lib/rpmhash.C | 24 ++++++++++++++++++++++-- lib/rpmhash.H | 35 +++++++++++++++++++++++++++++++++++ 2 files changed, 57 insertions(+), 2 deletions(-) diff --git a/lib/rpmhash.C b/lib/rpmhash.C index d8cfdd7..dbbb9e4 100644 --- a/lib/rpmhash.C +++ b/lib/rpmhash.C @@ -211,6 +211,28 @@ int HASHPREFIX(GetEntry)(HASHTYPE ht, HTKEYTYPE key, HTDATATYPE** data, return rc; } +#endif + + +unsigned int HASHPREFIX(NumBuckets)(HASHTYPE ht) { + return ht->numBuckets; +} + +unsigned int HASHPREFIX(UsedBuckets)(HASHTYPE ht) { + return ht->bucketCount; +} + +unsigned int HASHPREFIX(NumKeys)(HASHTYPE ht) { + return ht->keyCount; +} + +#ifdef HTDATATYPE +unsigned int HASHPREFIX(NumData)(HASHTYPE ht) { + return ht->dataCount; +} +#endif + + void HASHPREFIX(PrintStats)(HASHTYPE ht) { int i; Bucket bucket; @@ -236,5 +258,3 @@ void HASHPREFIX(PrintStats)(HASHTYPE ht) { fprintf(stderr, "Values: %i\n", datacnt); fprintf(stderr, "Max Keys/Bucket: %i\n", maxbuckets); } - -#endif diff --git a/lib/rpmhash.H b/lib/rpmhash.H index e6fcd29..ad791cf 100644 --- a/lib/rpmhash.H +++ b/lib/rpmhash.H @@ -96,6 +96,41 @@ RPM_GNUC_INTERNAL int HASHPREFIX(HasEntry)(HASHTYPE ht, HTKEYTYPE key); /** + * How many buckets are currently allocated (result is implementation + * dependent) + * @param ht pointer to hash table + * @result number of buckets allocated + */ +RPM_GNUC_INTERNAL +unsigned int HASHPREFIX(NumBuckets)(HASHTYPE ht); + +/** + * How many buckets are used (result is implementation dependent) + * @param ht pointer to hash table + * @result number of buckets used + */ +RPM_GNUC_INTERNAL +unsigned int HASHPREFIX(UsedBuckets)(HASHTYPE ht); + +/** + * How many (unique) keys have been added to the hash table + * @param ht pointer to hash table + * @result number of unique keys + */ +// RPM_GNUC_INTERNAL +unsigned int HASHPREFIX(NumKeys)(HASHTYPE ht); + +#ifdef HTDATATYPE +/** + * How many data entries have been added to the hash table + * @param ht pointer to hash table + * @result number of data entries + */ +RPM_GNUC_INTERNAL +unsigned int HASHPREFIX(NumData)(HASHTYPE ht); +#endif + +/** * Print statistics about the hash to stderr * This is for debugging only * @param ht pointer to hash table -- 2.7.4