Package com.google.common.collect
Class ForwardingMap.StandardValues
- java.lang.Object
-
- java.util.AbstractCollection<V>
-
- com.google.common.collect.ForwardingMap.StandardValues
-
- All Implemented Interfaces:
Iterable<V>
,Collection<V>
- Enclosing class:
- ForwardingMap<K,V>
@Beta protected class ForwardingMap.StandardValues extends AbstractCollection<V>
A sensible implementation ofMap.values()
in terms of the following methods:ForwardingMap.clear()
,ForwardingMap.containsValue(java.lang.Object)
,ForwardingMap.isEmpty()
,ForwardingMap.size()
, and theSet.iterator()
method ofForwardingMap.entrySet()
. In many cases, you may wish to overrideForwardingMap.values()
to forward to this implementation or a subclass thereof.- Since:
- 10.0
-
-
Constructor Summary
Constructors Constructor Description StandardValues()
Constructor for use by subclasses.
-
Method Summary
All Methods Instance Methods Concrete Methods Modifier and Type Method Description void
clear()
Removes all of the elements from this collection (optional operation).boolean
contains(Object o)
Returnstrue
if this collection contains the specified element.boolean
isEmpty()
Returnstrue
if this collection contains no elements.Iterator<V>
iterator()
Returns an iterator over the elements contained in this collection.boolean
remove(Object o)
Removes a single instance of the specified element from this collection, if it is present (optional operation).boolean
removeAll(Collection<?> c)
Removes all of this collection's elements that are also contained in the specified collection (optional operation).boolean
retainAll(Collection<?> c)
Retains only the elements in this collection that are contained in the specified collection (optional operation).int
size()
Returns the number of elements in this collection.-
Methods inherited from class java.util.AbstractCollection
add, addAll, containsAll, toArray, toArray, toString
-
Methods inherited from class java.lang.Object
clone, equals, finalize, getClass, hashCode, notify, notifyAll, wait, wait, wait
-
Methods inherited from interface java.util.Collection
equals, hashCode, parallelStream, removeIf, spliterator, stream, toArray
-
-
-
-
Constructor Detail
-
StandardValues
public StandardValues()
Constructor for use by subclasses.
-
-
Method Detail
-
iterator
public Iterator<V> iterator()
Description copied from class:java.util.AbstractCollection
Returns an iterator over the elements contained in this collection.- Specified by:
iterator
in interfaceCollection<K>
- Specified by:
iterator
in interfaceIterable<K>
- Specified by:
iterator
in classAbstractCollection<V>
- Returns:
- an iterator over the elements contained in this collection
-
remove
public boolean remove(Object o)
Description copied from class:java.util.AbstractCollection
Removes a single instance of the specified element from this collection, if it is present (optional operation). More formally, removes an elemente
such thatObjects.equals(o, e)
, if this collection contains one or more such elements. Returnstrue
if this collection contained the specified element (or equivalently, if this collection changed as a result of the call).- Specified by:
remove
in interfaceCollection<K>
- Overrides:
remove
in classAbstractCollection<V>
- Parameters:
o
- element to be removed from this collection, if present- Returns:
true
if an element was removed as a result of this call
-
removeAll
public boolean removeAll(Collection<?> c)
Description copied from class:java.util.AbstractCollection
Removes all of this collection's elements that are also contained in the specified collection (optional operation). After this call returns, this collection will contain no elements in common with the specified collection.- Specified by:
removeAll
in interfaceCollection<K>
- Overrides:
removeAll
in classAbstractCollection<V>
- Parameters:
c
- collection containing elements to be removed from this collection- Returns:
true
if this collection changed as a result of the call- See Also:
AbstractCollection.remove(Object)
,AbstractCollection.contains(Object)
-
retainAll
public boolean retainAll(Collection<?> c)
Description copied from class:java.util.AbstractCollection
Retains only the elements in this collection that are contained in the specified collection (optional operation). In other words, removes from this collection all of its elements that are not contained in the specified collection.- Specified by:
retainAll
in interfaceCollection<K>
- Overrides:
retainAll
in classAbstractCollection<V>
- Parameters:
c
- collection containing elements to be retained in this collection- Returns:
true
if this collection changed as a result of the call- See Also:
AbstractCollection.remove(Object)
,AbstractCollection.contains(Object)
-
size
public int size()
Description copied from interface:java.util.Collection
Returns the number of elements in this collection. If this collection contains more thanInteger.MAX_VALUE
elements, returnsInteger.MAX_VALUE
.- Specified by:
size
in interfaceCollection<K>
- Specified by:
size
in classAbstractCollection<V>
- Returns:
- the number of elements in this collection
-
isEmpty
public boolean isEmpty()
Description copied from class:java.util.AbstractCollection
Returnstrue
if this collection contains no elements.- Specified by:
isEmpty
in interfaceCollection<K>
- Overrides:
isEmpty
in classAbstractCollection<V>
- Returns:
true
if this collection contains no elements
-
contains
public boolean contains(@NullableDecl Object o)
Description copied from class:java.util.AbstractCollection
Returnstrue
if this collection contains the specified element. More formally, returnstrue
if and only if this collection contains at least one elemente
such thatObjects.equals(o, e)
.- Specified by:
contains
in interfaceCollection<K>
- Overrides:
contains
in classAbstractCollection<V>
- Parameters:
o
- element whose presence in this collection is to be tested- Returns:
true
if this collection contains the specified element
-
clear
public void clear()
Description copied from class:java.util.AbstractCollection
Removes all of the elements from this collection (optional operation). The collection will be empty after this method returns.- Specified by:
clear
in interfaceCollection<K>
- Overrides:
clear
in classAbstractCollection<V>
-
-