Skip to content

Comments

Add thread-safe ConcurrentHashMap implementation with coverage tests#7287

Draft
PritiAryal wants to merge 1 commit intoTheAlgorithms:masterfrom
PritiAryal:feature/add-concurrenthashmap-implementation
Draft

Add thread-safe ConcurrentHashMap implementation with coverage tests#7287
PritiAryal wants to merge 1 commit intoTheAlgorithms:masterfrom
PritiAryal:feature/add-concurrenthashmap-implementation

Conversation

@PritiAryal
Copy link

  • Implemented ConcurrentHashMap using separate chaining with linked lists for collision handling.
  • Ensured thread safety with bucket-level locking using ReentrantLock.
  • Added methods: put, get, remove, and containsKey.
  • Supported null keys and values.
  • Added unit tests in ConcurrentHashMapTest:
    • Verified basic operations, null key handling, and edge cases.
    • Simulated concurrent access with multiple threads.

- Implemented `ConcurrentHashMap` using separate chaining with linked lists for collision handling.
- Ensured thread safety with bucket-level locking using `ReentrantLock`.
- Added methods: `put`, `get`, `remove`, and `containsKey`.
- Supported `null` keys and values.
- Added unit tests in `ConcurrentHashMapTest`:
  - Verified basic operations, null key handling, and edge cases.
  - Simulated concurrent access with multiple threads.
@codecov-commenter
Copy link

Codecov Report

❌ Patch coverage is 83.87097% with 10 lines in your changes missing coverage. Please review.
✅ Project coverage is 79.37%. Comparing base (12935c2) to head (47d7f4d).

Files with missing lines Patch % Lines
...astructures/hashmap/hashing/ConcurrentHashMap.java 83.87% 7 Missing and 3 partials ⚠️
Additional details and impacted files
@@             Coverage Diff              @@
##             master    #7287      +/-   ##
============================================
- Coverage     79.38%   79.37%   -0.01%     
- Complexity     7020     7026       +6     
============================================
  Files           785      786       +1     
  Lines         23019    23081      +62     
  Branches       4523     4534      +11     
============================================
+ Hits          18273    18320      +47     
- Misses         4019     4027       +8     
- Partials        727      734       +7     

☔ View full report in Codecov by Sentry.
📢 Have feedback on the report? Share it here.

🚀 New features to boost your workflow:
  • ❄️ Test Analytics: Detect flaky tests, report on failures, and find test suite problems.

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

None yet

Projects

None yet

Development

Successfully merging this pull request may close these issues.

2 participants