[COLLECTIONS-472] Improved performance of AbstractMapBag#containsAll. Thanks to Adrian Nistor.
git-svn-id: https://svn.apache.org/repos/asf/commons/proper/collections/trunk@1491258 13f79535-47bb-0310-9956-ffa450edef68
This commit is contained in:
parent
8f5e319af8
commit
edd64cfd82
|
@ -182,6 +182,8 @@ Changed classes / methods
|
||||||
Fixed Bugs
|
Fixed Bugs
|
||||||
----------
|
----------
|
||||||
|
|
||||||
|
o [COLLECTIONS-472] Improved performance of "AbstractMapBag#containsAll(Collection)" by returning immediately
|
||||||
|
after a difference has been found. Thanks to Adrian Nistor.
|
||||||
o [COLLECTIONS-461] Added additional clarification to javadoc of interface "Put" wrt return type of
|
o [COLLECTIONS-461] Added additional clarification to javadoc of interface "Put" wrt return type of
|
||||||
"put(Object, Object)" method. Thanks to Matt Benson, sebb.
|
"put(Object, Object)" method. Thanks to Matt Benson, sebb.
|
||||||
o [COLLECTIONS-447] Tree traversal with a TreeListIterator will not be affected anymore by the removal of an element directly after
|
o [COLLECTIONS-447] Tree traversal with a TreeListIterator will not be affected anymore by the removal of an element directly after
|
||||||
|
|
|
@ -22,6 +22,10 @@
|
||||||
<body>
|
<body>
|
||||||
|
|
||||||
<release version="4.0" date="TBA" description="Next release">
|
<release version="4.0" date="TBA" description="Next release">
|
||||||
|
<action issue="COLLECTIONS-472" dev="tn" type="fix" due-to="Adrian Nistor">
|
||||||
|
Improved performance of "AbstractMapBag#containsAll(Collection)" by returning immediately
|
||||||
|
after a difference has been found.
|
||||||
|
</action>
|
||||||
<action issue="COLLECTIONS-466" dev="tn" type="update">
|
<action issue="COLLECTIONS-466" dev="tn" type="update">
|
||||||
Replaced "Collection" with "Iterable" for method arguments where applicable.
|
Replaced "Collection" with "Iterable" for method arguments where applicable.
|
||||||
</action>
|
</action>
|
||||||
|
|
|
@ -147,14 +147,14 @@ public abstract class AbstractMapBag<E> implements Bag<E> {
|
||||||
* @return <code>true</code> if the Bag contains all the collection
|
* @return <code>true</code> if the Bag contains all the collection
|
||||||
*/
|
*/
|
||||||
boolean containsAll(final Bag<?> other) {
|
boolean containsAll(final Bag<?> other) {
|
||||||
boolean result = true;
|
|
||||||
final Iterator<?> it = other.uniqueSet().iterator();
|
final Iterator<?> it = other.uniqueSet().iterator();
|
||||||
while (it.hasNext()) {
|
while (it.hasNext()) {
|
||||||
final Object current = it.next();
|
final Object current = it.next();
|
||||||
final boolean contains = getCount(current) >= other.getCount(current);
|
if (getCount(current) < other.getCount(current)) {
|
||||||
result = result && contains;
|
return false;
|
||||||
|
}
|
||||||
}
|
}
|
||||||
return result;
|
return true;
|
||||||
}
|
}
|
||||||
|
|
||||||
//-----------------------------------------------------------------------
|
//-----------------------------------------------------------------------
|
||||||
|
|
Loading…
Reference in New Issue