T - the type of elements maintained by this setpublic final class InflatableSet<T> extends AbstractSet<T> implements Set<T>, Serializable, Cloneable
Set implementation for cases where items are known to not
contain duplicates.
It requires creation via InflatableSet.Builder
The builder doesn't call equals/hash methods on initial data insertion, hence it avoids
performance penalty in the case these methods are expensive. It also means it does
not detect duplicates - it's the responsibility of the caller to make sure no duplicated
entries are inserted.
Once InflatableSet is constructed via InflatableSet.Builder.build() then it acts as a regular set. It has
been designed to mimic HashSet. On new entry insertion or lookup via
contains(Object) it inflates itself: The backing list is copied into
internal HashSet. This obviously costs time and space. We are making a bet the
Set won't be modified in most cases.
It's intended to be used in cases where the contract mandates us to return Set,
but we know our data does not contain duplicates. It performs best in cases
biased towards sequential iteration.| Modifier and Type | Class and Description |
|---|---|
static class |
InflatableSet.Builder<T>
Builder for
InflatableSet
This is the only way to create a new instance of InflatableSet |
| Modifier and Type | Method and Description |
|---|---|
boolean |
add(T t) |
void |
clear() |
protected Object |
clone()
Returns a shallow copy of this InflatableSet instance: the keys and
values themselves are not cloned.
|
boolean |
contains(Object o) |
boolean |
isEmpty() |
Iterator<T> |
iterator() |
static <T> InflatableSet.Builder<T> |
newBuilder(int initialCapacity) |
boolean |
remove(Object o) |
int |
size() |
equals, hashCode, removeAlladdAll, containsAll, retainAll, toArray, toArray, toStringpublic static <T> InflatableSet.Builder<T> newBuilder(int initialCapacity)
public int size()
size in interface Collection<T>size in interface Set<T>size in class AbstractCollection<T>public boolean isEmpty()
isEmpty in interface Collection<T>isEmpty in interface Set<T>isEmpty in class AbstractCollection<T>public boolean contains(Object o)
contains in interface Collection<T>contains in interface Set<T>contains in class AbstractCollection<T>public boolean add(T t)
add in interface Collection<T>add in interface Set<T>add in class AbstractCollection<T>public boolean remove(Object o)
remove in interface Collection<T>remove in interface Set<T>remove in class AbstractCollection<T>public void clear()
clear in interface Collection<T>clear in interface Set<T>clear in class AbstractCollection<T>Copyright © 2016 Hazelcast, Inc.. All Rights Reserved.