Answered step by step
Verified Expert Solution
Link Copied!

Question

1 Approved Answer

#include / / for printf, ONLY IN strmap _ dump #include / / for strcmp #include / / for malloc / calloc #define MAX _

#include // for printf, ONLY IN strmap_dump
#include // for strcmp
#include // for malloc/calloc
#define MAX_BUCKETS 10000
#define MIN_BUCKETS 10
typedef struct strmap_e {
char *sme_key;
void *sme_value;
struct strmap_e *sme_next;
} smel_t;
typedef struct sm {
smel_t **strmap_buckets; // array of pointers to elements
unsigned int strmap_size; // # elements in the table
unsigned int strmap_nbuckets; // size of the array
} strmap_t;
/* Create a new hashtab, initialized to empty. */
strmap_t *strmap_create(int numbuckets);
/* Insert an element with the given key and value.
* Return the previous value associated with that key, or null if none.
*/
void *strmap_put(strmap_t *m, char *key, void *value);
/* return the value associated with the given key, or null if none */
void *strmap_get(strmap_t *m, char *key);
/* remove the element with the given key and return its value.
Return null if the hashtab contains no element with the given key */
void *strmap_remove(strmap_t *m, char *key);
/* return the # of elements in the hashtab */
int strmap_getsize(strmap_t *m);
/* return the # of buckets in the hashtab */
int strmap_getnbuckets(strmap_t *m);
/* print out the contents of each bucket */
void strmap_dump(strmap_t *m);

Step by Step Solution

There are 3 Steps involved in it

Step: 1

blur-text-image

Get Instant Access to Expert-Tailored Solutions

See step-by-step solutions with expert insights and AI powered tools for academic success

Step: 2

blur-text-image

Step: 3

blur-text-image

Ace Your Homework with AI

Get the answers you need in no time with our AI-driven, step-by-step assistance

Get Started

Recommended Textbook for

Transactions On Large Scale Data And Knowledge Centered Systems Xxiv Special Issue On Database And Expert Systems Applications Lncs 9510

Authors: Abdelkader Hameurlain ,Josef Kung ,Roland Wagner ,Hendrik Decker ,Lenka Lhotska ,Sebastian Link

1st Edition

366249213X, 978-3662492130

More Books

Students also viewed these Databases questions

Question

Establish identity. + cos 0 + sin 0 sec e + tan e 1 + cos 0 sin 0

Answered: 1 week ago