< prev index next >

src/java.base/share/classes/java/util/Set.java

Print this page
rev 54827 : 6394757: AbstractSet.removeAll semantics are surprisingly dependent on relative sizes
Reviewed-by: XXX

*** 1,7 **** /* ! * Copyright (c) 1997, 2018, Oracle and/or its affiliates. All rights reserved. * DO NOT ALTER OR REMOVE COPYRIGHT NOTICES OR THIS FILE HEADER. * * This code is free software; you can redistribute it and/or modify it * under the terms of the GNU General Public License version 2 only, as * published by the Free Software Foundation. Oracle designates this --- 1,7 ---- /* ! * Copyright (c) 1997, 2019, Oracle and/or its affiliates. All rights reserved. * DO NOT ALTER OR REMOVE COPYRIGHT NOTICES OR THIS FILE HEADER. * * This code is free software; you can redistribute it and/or modify it * under the terms of the GNU General Public License version 2 only, as * published by the Free Software Foundation. Oracle designates this
*** 278,290 **** // Bulk Operations /** ! * Returns {@code true} if this set contains all of the elements of the ! * specified collection. If the specified collection is also a set, this ! * method returns {@code true} if it is a <i>subset</i> of this set. * * @param c collection to be checked for containment in this set * @return {@code true} if this set contains all of the elements of the * specified collection * @throws ClassCastException if the types of one or more elements --- 278,294 ---- // Bulk Operations /** ! * Returns {@code true} if this set contains all of the elements ! * in the specified collection. This operation uses the membership ! * semantics of this set. If the specified collection is also a set, ! * this method returns {@code true} if it is a <i>subset</i> of this set. ! * ! * @implNote ! * {@inheritDoc} * * @param c collection to be checked for containment in this set * @return {@code true} if this set contains all of the elements of the * specified collection * @throws ClassCastException if the types of one or more elements
*** 326,339 **** --- 330,347 ---- /** * Retains only the elements in this set that are contained in the * specified collection (optional operation). In other words, removes * from this set all of its elements that are not contained in the + * specified collection. This operation uses the membership semantics of the * specified collection. If the specified collection is also a set, this * operation effectively modifies this set so that its value is the * <i>intersection</i> of the two sets. * + * @implNote + * {@inheritDoc} + * * @param c collection containing elements to be retained in this set * @return {@code true} if this set changed as a result of the call * @throws UnsupportedOperationException if the {@code retainAll} operation * is not supported by this set * @throws ClassCastException if the class of an element of this set
*** 347,360 **** */ boolean retainAll(Collection<?> c); /** * Removes from this set all of its elements that are contained in the ! * specified collection (optional operation). If the specified ! * collection is also a set, this operation effectively modifies this ! * set so that its value is the <i>asymmetric set difference</i> of ! * the two sets. * * @param c collection containing elements to be removed from this set * @return {@code true} if this set changed as a result of the call * @throws UnsupportedOperationException if the {@code removeAll} operation * is not supported by this set --- 355,373 ---- */ boolean retainAll(Collection<?> c); /** * Removes from this set all of its elements that are contained in the ! * specified collection (optional operation). After this call returns, ! * this set will contain no elements in common with the specified ! * collection. This operation uses the membership semantics of the specified ! * collection. If the specified collection is also a set, this operation ! * effectively modifies this set so that its value is the <i>asymmetric ! * set difference</i> of the two sets. ! * ! * @implNote ! * {@inheritDoc} * * @param c collection containing elements to be removed from this set * @return {@code true} if this set changed as a result of the call * @throws UnsupportedOperationException if the {@code removeAll} operation * is not supported by this set
*** 384,397 **** /** * Compares the specified object with this set for equality. Returns * {@code true} if the specified object is also a set, the two sets * have the same size, and every member of the specified set is ! * contained in this set (or equivalently, every member of this set is ! * contained in the specified set). This definition ensures that the ! * equals method works properly across different implementations of the ! * set interface. * * @param o object to be compared for equality with this set * @return {@code true} if the specified object is equal to this set */ boolean equals(Object o); --- 397,415 ---- /** * Compares the specified object with this set for equality. Returns * {@code true} if the specified object is also a set, the two sets * have the same size, and every member of the specified set is ! * contained in this set. This operation uses the membership semantics ! * of this set. This definition ensures that the {@code equals} method ! * works properly across different implementations of the ! * {@code Set} interface. ! * ! * @implNote ! * Most implementations will call this set's {@code contains} ! * method repeatedly. This may result in performance problems if the ! * {@code contains} method has linear or worse performance. * * @param o object to be compared for equality with this set * @return {@code true} if the specified object is equal to this set */ boolean equals(Object o);
< prev index next >