Commit 2d188e6
committed
feat: add ConcurrentSkipListMapDemo with basic example
What
- Introduced `ConcurrentSkipListMapDemo` class.
- Demonstrated use of `ConcurrentSkipListMap` via its `NavigableMap` interface.
- Inserted a few entries and printed them in natural sorted order.
Why
- Complements `ConcurrentHashMapDemo` by showing a concurrent map that preserves ordering.
- Highlights a scalable, thread-safe alternative to `TreeMap` when ordering is needed.
- Provides a simple reference for concurrency + ordering in collections.
How
- Created a `ConcurrentSkipListMap<Integer, String>`.
- Populated it with keys `2,1,3`.
- Printed the map to show that entries are maintained in ascending key order.
Logic
- `ConcurrentSkipListMap` internally uses a skip list to maintain sorted keys.
- Iteration order is sorted by natural ordering or provided comparator.
- Thread-safe without needing explicit synchronization.
Real-world applications
- Suitable for concurrent caches or lookup tables requiring both fast access and sorted keys.
- Useful for range queries (e.g., `headMap`, `tailMap`) in multithreaded contexts.
Signed-off-by: https://github.com/Someshdiwan <[email protected]>1 parent 646c075 commit 2d188e6
File tree
2 files changed
+33
-25
lines changed- Section 25 Collections Frameworks/Map Interface/Concurrent HashMap/Concurrent Skip List Map/src
- Section25CollectionFramework/src/ConcurrentMap/ConcurrentSkipListMapDemo
2 files changed
+33
-25
lines changedLines changed: 33 additions & 0 deletions
| Original file line number | Diff line number | Diff line change | |
|---|---|---|---|
| |||
| 1 | + | |
| 2 | + | |
| 3 | + | |
| 4 | + | |
| 5 | + | |
| 6 | + | |
| 7 | + | |
| 8 | + | |
| 9 | + | |
| 10 | + | |
| 11 | + | |
| 12 | + | |
| 13 | + | |
| 14 | + | |
| 15 | + | |
| 16 | + | |
| 17 | + | |
| 18 | + | |
| 19 | + | |
| 20 | + | |
| 21 | + | |
| 22 | + | |
| 23 | + | |
| 24 | + | |
| 25 | + | |
| 26 | + | |
| 27 | + | |
| 28 | + | |
| 29 | + | |
| 30 | + | |
| 31 | + | |
| 32 | + | |
| 33 | + | |
Lines changed: 0 additions & 25 deletions
This file was deleted.
0 commit comments