In this post we will discuss about Is there concurrent version for TreeMap and TreeSet in Java Collections Framework?
- Java Collection Framework have ConcurrentSkipListMap and ConcurrentSkipListSet which are concurrent replacement for TreeMap and TreeSet. These classes implement SortedMap and SortedSet interface respectively.
- if our application demands fair concurrency then instead of wrapping TreeMap and TreeSet inside synchronized collection, we can prefer these concurrent utilities.
- These also implement NavigableMap and NavigableSet interface with methods like lowerKey, floorKey, ceilingKey, higherKey, headMap and tailMap.
Average time complexity is log(n) for the containsKey, get, put and remove operations of the ConcurrentSkipListMap
You may also like:
That’s all about Is there concurrent version for TreeMap and TreeSet in Java Collections Framework?
If you have any feedback or suggestion please feel free to drop in blow comment box.