name | add | contains | next | comment |
---|---|---|---|---|
HashSet | o(1) | o(1) | o(h/n) | based on hashmap, using key to store object |
LinkedHashSet | o(1) | o(1) | o(1) | based on linkedhashmap, using key to store object. double-linked entry to get constant-time complexity when call next on iteration |
BitSet | o(1) | o(1) | o(1) | using bit vector internally to represent enum elements; a variable of long represents all enum elements if enum’s length < 64. otherwise use long[] to represent enum |
TreeSet | o(log(n)) | o(log(n)) | o(log(n)) | TreeMap underlying |
CopyOnWriteArraySet | o(n) | o(n) | o(1) | CopyOnWriteArrayList underlying |
ConcurrentSkipListSet | o(log(n)) | o(log(n)) | o(1) | concurrentSkipListMap underlying |
Java Set
最新推荐文章于 2024-09-21 10:38:43 发布