https://github.com/chaganti-reddy/maps_c
Hashmaps implementation in C language
https://github.com/chaganti-reddy/maps_c
c data-structures hashmap-c
Last synced: 11 months ago
JSON representation
Hashmaps implementation in C language
- Host: GitHub
- URL: https://github.com/chaganti-reddy/maps_c
- Owner: Chaganti-Reddy
- License: mit
- Created: 2025-04-28T18:01:18.000Z (11 months ago)
- Default Branch: main
- Last Pushed: 2025-04-28T18:11:20.000Z (11 months ago)
- Last Synced: 2025-04-28T19:25:20.100Z (11 months ago)
- Topics: c, data-structures, hashmap-c
- Language: C
- Homepage:
- Size: 5.86 KB
- Stars: 0
- Watchers: 1
- Forks: 0
- Open Issues: 0
-
Metadata Files:
- Readme: README.md
- License: LICENSE
Awesome Lists containing this project
README
# maps_C
**A Basic Hashmap (Key-Value Store) Implementation in C**
---
## ๐ Overview
`maps_C` is a simple and lightweight **hash map** (key-value store) built using C.
It supports **insertion**, **retrieval**, **deletion**, **updating**, and **printing** of key-value pairs with dynamic memory management. Collision handling is managed through **chaining** using **linked lists**.
Perfect for:
- Practicing C programming and pointers
- Learning how basic data structures work internally
- Exploring hashing, collisions, and memory handling
---
## โ๏ธ Features
- ๐ Insert a key-value pair
- ๐ Retrieve a value by key
- ๐งน Delete a key
- โ๏ธ Update a keyโs value
- ๐ Print the entire hashmap
- ๐ Get the number of entries
- ๐งน Proper memory cleanup
---
## ๐๏ธ Project Structure
```bash
maps_C/
โโโ LICENSE # License file (MIT)
โโโ main.c # Program with interactive menu to use the hashmap
โโโ map.c # Implementation of hashmap functions
โโโ map.h # Header file (definitions and function declarations)
โโโ Makefile # For easy compilation
โโโ maps # Compiled executable
โโโ README.md # Project documentation (this file)
โโโ map.o # Object file for map.c
โโโ main.o # Object file for main.c
```
---
## ๐ Getting Started
### Prerequisites
- GCC or any C compiler
- Basic familiarity with terminal commands
### Building and Running
```bash
# Clone the repository
git clone https://github.com/Chaganti-Reddy/maps_C.git
cd maps_C
# Compile using Makefile
make
# Run the executable
./maps
```
Alternatively, compile manually:
```bash
gcc main.c map.c -o maps
./maps
```
---
## ๐ Example Usage (Menu Options)
On running the program, you can:
```
1. Insert โ Add a key-value pair
2. Get โ Retrieve the value for a given key
3. Delete โ Remove a key and its value
4. Print โ Display all key-value pairs
5. Length โ Show the number of stored pairs
6. Update โ Modify the value of an existing key
7. Exit โ Free memory and exit
```
---
## ๐ง Core Concepts Demonstrated
- Hashing with modulus operator
- Collision resolution with **chaining** (linked lists)
- Dynamic memory allocation with `malloc`, `calloc`, and `free`
- Modular programming in C (`.h` and `.c` separation)
- Basic CLI-based interface
---
## ๐ Limitations
- Fixed array size (`SIZE = 100`), no dynamic resizing
- Only supports integer keys and integer values
- Not thread-safe (designed for single-threaded environments)
---
## ๐ License
This project is licensed under the [MIT License](LICENSE).
---
## ๐ค Contributing
Feel free to open issues or submit pull requests!
Improvements, optimizations, and feature additions are very welcome.