K
- 唯一键类型V
- 值对象public class UniqueKeySet<K,V> extends AbstractSet<V> implements Serializable
uniqueGenerator
生成节点对象对应的键作为Map的key,确定唯一Object.equals(Object)
确定唯一
Set<UniqueTestBean> set = new UniqueKeySet<>(UniqueTestBean::getId);
Constructor and Description |
---|
UniqueKeySet(boolean isLinked,
Function<V,K> uniqueGenerator)
构造
|
UniqueKeySet(boolean isLinked,
Function<V,K> uniqueGenerator,
Collection<? extends V> c)
构造
|
UniqueKeySet(Function<V,K> uniqueGenerator)
构造
|
UniqueKeySet(Function<V,K> uniqueGenerator,
Collection<? extends V> c)
构造
|
UniqueKeySet(int initialCapacity,
float loadFactor,
Function<V,K> uniqueGenerator)
构造
|
UniqueKeySet(MapBuilder<K,V> builder,
Function<V,K> uniqueGenerator)
构造
|
Modifier and Type | Method and Description |
---|---|
boolean |
add(V v) |
boolean |
addAllIfAbsent(Collection<? extends V> c)
加入集合中所有的值,如果值已经存在,则忽略之
|
boolean |
addIfAbsent(V v)
加入值,如果值已经存在,则忽略之
|
void |
clear() |
UniqueKeySet<K,V> |
clone() |
boolean |
contains(Object o) |
boolean |
isEmpty() |
Iterator<V> |
iterator() |
boolean |
remove(Object o) |
int |
size() |
equals, hashCode, removeAll
addAll, containsAll, retainAll, toArray, toArray, toString
finalize, getClass, notify, notifyAll, wait, wait, wait
addAll, containsAll, retainAll, spliterator, toArray, toArray
parallelStream, removeIf, stream
public UniqueKeySet(Function<V,K> uniqueGenerator)
uniqueGenerator
- 唯一键生成规则函数,用于生成对象对应的唯一键public UniqueKeySet(Function<V,K> uniqueGenerator, Collection<? extends V> c)
uniqueGenerator
- 唯一键生成规则函数,用于生成对象对应的唯一键c
- 初始化加入的集合public UniqueKeySet(boolean isLinked, Function<V,K> uniqueGenerator)
isLinked
- 是否保持加入顺序uniqueGenerator
- 唯一键生成规则函数,用于生成对象对应的唯一键public UniqueKeySet(boolean isLinked, Function<V,K> uniqueGenerator, Collection<? extends V> c)
isLinked
- 是否保持加入顺序uniqueGenerator
- 唯一键生成规则函数,用于生成对象对应的唯一键c
- 初始化加入的集合public UniqueKeySet(int initialCapacity, float loadFactor, Function<V,K> uniqueGenerator)
initialCapacity
- 初始容量loadFactor
- 增长因子uniqueGenerator
- 唯一键生成规则函数,用于生成对象对应的唯一键public int size()
size
in interface Collection<V>
size
in interface Set<V>
size
in class AbstractCollection<V>
public boolean isEmpty()
isEmpty
in interface Collection<V>
isEmpty
in interface Set<V>
isEmpty
in class AbstractCollection<V>
public boolean contains(Object o)
contains
in interface Collection<V>
contains
in interface Set<V>
contains
in class AbstractCollection<V>
public boolean add(V v)
add
in interface Collection<V>
add
in interface Set<V>
add
in class AbstractCollection<V>
public boolean addIfAbsent(V v)
v
- 值public boolean addAllIfAbsent(Collection<? extends V> c)
c
- 集合public boolean remove(Object o)
remove
in interface Collection<V>
remove
in interface Set<V>
remove
in class AbstractCollection<V>
public void clear()
clear
in interface Collection<V>
clear
in interface Set<V>
clear
in class AbstractCollection<V>
public UniqueKeySet<K,V> clone()
Copyright © 2024. All rights reserved.