Package com.tangosol.util
Class InflatableCollection
java.lang.Object
java.util.AbstractCollection
com.tangosol.util.InflatableCollection
- All Implemented Interfaces:
Iterable
,Collection
- Direct Known Subclasses:
InflatableList
,InflatableSet
A Collection implementation which optimizes memory consumption for
collections that often contain just a single value. This implementation also
reduces contention for read operations (e.g. contains, iterator, etc.)
- Since:
- Coherence 3.6
- Author:
- ch 2009.11.22
-
Nested Class Summary
Modifier and TypeClassDescriptionprotected static interface
A marker interface which is used to identify internally inflated Collections. -
Field Summary
Modifier and TypeFieldDescriptionprotected Object
Holds NO_VALUE, a single value, or an InflatedCollection of values.protected static final Object
A marker value indicating that the single value has not been initialized.protected static final AtomicReferenceFieldUpdater
<InflatableCollection, Object> Atomic updater for collection values. -
Constructor Summary
-
Method Summary
Methods inherited from class java.util.AbstractCollection
addAll, containsAll, isEmpty, toString
Methods inherited from class java.lang.Object
clone, finalize, getClass, notify, notifyAll, wait, wait, wait
Methods inherited from interface java.util.Collection
parallelStream, removeIf, spliterator, stream, toArray
-
Field Details
-
NO_VALUE
A marker value indicating that the single value has not been initialized. -
VALUE_UPDATER
Atomic updater for collection values. Static atomic field updater rather thanAtomicReference
is shared to reduce memory footprint of each InflatableCollection instance. (COH-9262) -
m_oValue
Holds NO_VALUE, a single value, or an InflatedCollection of values.
-
-
Constructor Details
-
InflatableCollection
public InflatableCollection()
-
-
Method Details
-
equals
- Specified by:
equals
in interfaceCollection
- Overrides:
equals
in classObject
-
hashCode
public int hashCode()- Specified by:
hashCode
in interfaceCollection
- Overrides:
hashCode
in classObject
-
add
- Specified by:
add
in interfaceCollection
- Overrides:
add
in classAbstractCollection
-
remove
- Specified by:
remove
in interfaceCollection
- Overrides:
remove
in classAbstractCollection
-
removeAll
- Specified by:
removeAll
in interfaceCollection
- Overrides:
removeAll
in classAbstractCollection
-
retainAll
- Specified by:
retainAll
in interfaceCollection
- Overrides:
retainAll
in classAbstractCollection
-
clear
public void clear()- Specified by:
clear
in interfaceCollection
- Overrides:
clear
in classAbstractCollection
-
contains
- Specified by:
contains
in interfaceCollection
- Overrides:
contains
in classAbstractCollection
-
iterator
- Specified by:
iterator
in interfaceCollection
- Specified by:
iterator
in interfaceIterable
- Specified by:
iterator
in classAbstractCollection
-
size
public int size()- Specified by:
size
in interfaceCollection
- Specified by:
size
in classAbstractCollection
-
toArray
- Specified by:
toArray
in interfaceCollection
- Overrides:
toArray
in classAbstractCollection
-
toArray
- Specified by:
toArray
in interfaceCollection
- Overrides:
toArray
in classAbstractCollection
-
instantiateCollection
Factory method used to create a new Collection. The returned Collection must provide a "safe" iterator.- Returns:
- a "real" implementation to use if this collection is expanded
-