Logo Questions Linux Laravel Mysql Ubuntu Git Menu
 

C map data structure [closed]

Tags:

c

hashmap

I want to implement a key value pair data structure in C. Any idea?

like image 527
Udara S.S Liyanage Avatar asked Apr 14 '11 03:04

Udara S.S Liyanage


People also ask

Is map available in C?

The C Programming Language by Kernighan and Ritchie has an example of making an associate map in c, and what I'll detail below is based on what I remember from that. Basically you'll need a struct Map that contains struct Key and struct Value.

Which data structure is used in map?

Now coming to the point that which data structure is used by map. The internal implementation of map is self-balancing Binary Tree. There are generally two methods for implementing a self-balancing binary tree: Red-Black Tree and.

How does map data structure work?

The map data type is referred to as an associative array because, like an array, it is a collection of values rather than a single value, as an Int or a String is. Furthermore, each distinct key is associated with a value, resulting in an associative array.

Which data structure is used by map which tree?

map is often implemented using red-black trees, while unordered_map is often implemented using hash tables.


1 Answers

This is a simple hash table implementation in ANSI C. It supports the rudimentary functions generally expected of a hash table:

  • Inserting and retrieving key-value associations
  • Querying the existence of a key
  • Returning the total number of key-value associations
  • Enumerating over all key-value associations

Hope this helps!

like image 136
Carlos Daniel Gadea Omelchenko Avatar answered Oct 03 '22 10:10

Carlos Daniel Gadea Omelchenko