Everyone knows HashSet stores elements in buckets based on the size of the hashtable and the elements' hash code values.
But how does CopyOnWriteArraySet store elements? I thought it makes a snapshot of those buckets and copies them. Looks like it doesn't. Does it store them in 'normal' array 1 by 1 and checks equals()?
Does it even use hashing principle?
CopyOnWriteArraySetis aSet-wrapper forCopyOnWriteArrayList, which stores its elements in an array, so it does not use hashing. That's why it doesn't have the O(1) lookup benefit of a HashSet.The docs say it is only suitable for small sets.