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
public abstract class InflatableCollection extends AbstractCollection
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
Nested Classes Modifier and Type Class Description protected static interfaceInflatableCollection.InflatedCollectionA marker interface which is used to identify internally inflated Collections. 
- 
Field Summary
Fields Modifier and Type Field Description protected Objectm_oValueHolds NO_VALUE, a single value, or an InflatedCollection of values.protected static ObjectNO_VALUEA marker value indicating that the single value has not been initialized.protected static AtomicReferenceFieldUpdater<InflatableCollection,Object>VALUE_UPDATERAtomic updater for collection values. 
- 
Constructor Summary
Constructors Constructor Description InflatableCollection() 
- 
Method Summary
All Methods Instance Methods Abstract Methods Concrete Methods Modifier and Type Method Description booleanadd(Object o)voidclear()booleancontains(Object o)booleanequals(Object o)inthashCode()protected abstract InflatableCollection.InflatedCollectioninstantiateCollection()Factory method used to create a new Collection.Iteratoriterator()booleanremove(Object o)booleanremoveAll(Collection c)booleanretainAll(Collection c)intsize()Object[]toArray()Object[]toArray(Object[] ao)- 
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 Detail
- 
NO_VALUE
protected static final Object NO_VALUE
A marker value indicating that the single value has not been initialized. 
- 
VALUE_UPDATER
protected static final AtomicReferenceFieldUpdater<InflatableCollection,Object> VALUE_UPDATER
Atomic updater for collection values. Static atomic field updater rather thanAtomicReferenceis shared to reduce memory footprint of each InflatableCollection instance. (COH-9262) 
- 
m_oValue
protected volatile Object m_oValue
Holds NO_VALUE, a single value, or an InflatedCollection of values. 
 - 
 
- 
Method Detail
- 
equals
public boolean equals(Object o)
- Specified by:
 equalsin interfaceCollection- Overrides:
 equalsin classObject
 
- 
hashCode
public int hashCode()
- Specified by:
 hashCodein interfaceCollection- Overrides:
 hashCodein classObject
 
- 
add
public boolean add(Object o)
- Specified by:
 addin interfaceCollection- Overrides:
 addin classAbstractCollection
 
- 
remove
public boolean remove(Object o)
- Specified by:
 removein interfaceCollection- Overrides:
 removein classAbstractCollection
 
- 
removeAll
public boolean removeAll(Collection c)
- Specified by:
 removeAllin interfaceCollection- Overrides:
 removeAllin classAbstractCollection
 
- 
retainAll
public boolean retainAll(Collection c)
- Specified by:
 retainAllin interfaceCollection- Overrides:
 retainAllin classAbstractCollection
 
- 
clear
public void clear()
- Specified by:
 clearin interfaceCollection- Overrides:
 clearin classAbstractCollection
 
- 
contains
public boolean contains(Object o)
- Specified by:
 containsin interfaceCollection- Overrides:
 containsin classAbstractCollection
 
- 
iterator
public Iterator iterator()
- Specified by:
 iteratorin interfaceCollection- Specified by:
 iteratorin interfaceIterable- Specified by:
 iteratorin classAbstractCollection
 
- 
size
public int size()
- Specified by:
 sizein interfaceCollection- Specified by:
 sizein classAbstractCollection
 
- 
toArray
public Object[] toArray()
- Specified by:
 toArrayin interfaceCollection- Overrides:
 toArrayin classAbstractCollection
 
- 
toArray
public Object[] toArray(Object[] ao)
- Specified by:
 toArrayin interfaceCollection- Overrides:
 toArrayin classAbstractCollection
 
- 
instantiateCollection
protected abstract InflatableCollection.InflatedCollection 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
 
 
 - 
 
 -