HashSet, LinkedHashSet, and EnumSet have a constant cost of add (), remove () and contain () O (1) time due to the internal implementation of HashMap.
For the tree structure TreeMap and ConcurrentSkipListMap, the time of the put (), get (), remove (), containsKey () operations is O (log (n)).
therefore TreeSet has O (log (n)) time complexity.
khawar
source share