public class ConcurrentHashSet<E> extends AbstractSet<E> implements Set<E>, Serializable
虽然也可以通过Collections.newSetFromMap(new ConcurrentHashMap()),
但声明一个单独的类型,阅读代码时能更清晰的知道set的并发友好性,代码来自JDK的SetFromMap,去除JDK8接口.
copy from vipshop VJTools
| 构造器和说明 |
|---|
ConcurrentHashSet() |
| 限定符和类型 | 方法和说明 |
|---|---|
boolean |
add(E e) |
void |
clear() |
boolean |
contains(Object o) |
boolean |
containsAll(Collection<?> c) |
boolean |
equals(Object o) |
int |
hashCode() |
boolean |
isEmpty() |
Iterator<E> |
iterator() |
boolean |
remove(Object o) |
boolean |
removeAll(Collection<?> c) |
boolean |
retainAll(Collection<?> c) |
int |
size() |
Object[] |
toArray() |
<T> T[] |
toArray(T[] a) |
String |
toString() |
addAlladdAll, spliteratorparallelStream, removeIf, streampublic void clear()
clear 在接口中 Collection<E>clear 在接口中 Set<E>clear 在类中 AbstractCollection<E>public int size()
size 在接口中 Collection<E>size 在接口中 Set<E>size 在类中 AbstractCollection<E>public boolean isEmpty()
isEmpty 在接口中 Collection<E>isEmpty 在接口中 Set<E>isEmpty 在类中 AbstractCollection<E>public boolean contains(Object o)
contains 在接口中 Collection<E>contains 在接口中 Set<E>contains 在类中 AbstractCollection<E>public boolean remove(Object o)
remove 在接口中 Collection<E>remove 在接口中 Set<E>remove 在类中 AbstractCollection<E>public boolean add(E e)
add 在接口中 Collection<E>add 在接口中 Set<E>add 在类中 AbstractCollection<E>public Object[] toArray()
toArray 在接口中 Collection<E>toArray 在接口中 Set<E>toArray 在类中 AbstractCollection<E>public <T> T[] toArray(T[] a)
toArray 在接口中 Collection<E>toArray 在接口中 Set<E>toArray 在类中 AbstractCollection<E>public String toString()
toString 在类中 AbstractCollection<E>public int hashCode()
hashCode 在接口中 Collection<E>hashCode 在接口中 Set<E>hashCode 在类中 AbstractSet<E>public boolean equals(Object o)
equals 在接口中 Collection<E>equals 在接口中 Set<E>equals 在类中 AbstractSet<E>public boolean containsAll(Collection<?> c)
containsAll 在接口中 Collection<E>containsAll 在接口中 Set<E>containsAll 在类中 AbstractCollection<E>public boolean removeAll(Collection<?> c)
removeAll 在接口中 Collection<E>removeAll 在接口中 Set<E>removeAll 在类中 AbstractSet<E>public boolean retainAll(Collection<?> c)
retainAll 在接口中 Collection<E>retainAll 在接口中 Set<E>retainAll 在类中 AbstractCollection<E>Copyright © 2019. All rights reserved.