📄 set.java
字号:
* supported by this set. * @throws ClassCastException if the class of the specified element * prevents it from being added to this set. * @throws NullPointerException if the specified element is null and this * set does not support null elements. * @throws IllegalArgumentException if some aspect of the specified element * prevents it from being added to this set. */ boolean add(Object o); /** * Removes the specified element from this set if it is present (optional * operation). More formally, removes an element <code>e</code> such that * <code>(o==null ? e==null : o.equals(e))</code>, if the set contains * such an element. Returns <tt>true</tt> if the set contained the * specified element (or equivalently, if the set changed as a result of * the call). (The set will not contain the specified element once the * call returns.) * * @param o object to be removed from this set, if present. * @return true if the set contained the specified element. * @throws ClassCastException if the type of the specified element * is incompatible with this set (optional). * @throws NullPointerException if the specified element is null and this * set does not support null elements (optional). * @throws UnsupportedOperationException if the <tt>remove</tt> method is * not supported by this set. */ boolean remove(Object o); // Bulk Operations /** * Returns <tt>true</tt> if this set contains all of the elements of the * specified collection. If the specified collection is also a set, this * method returns <tt>true</tt> if it is a <i>subset</i> of this set. * * @param c collection to be checked for containment in this set. * @return <tt>true</tt> if this set contains all of the elements of the * specified collection. * @throws ClassCastException if the types of one or more elements * in the specified collection are incompatible with this * set (optional). * @throws NullPointerException if the specified collection contains one * or more null elements and this set does not support null * elements (optional). * @throws NullPointerException if the specified collection is * <tt>null</tt>. * @see #contains(Object) */ boolean containsAll(Collection c); /** * Adds all of the elements in the specified collection to this set if * they're not already present (optional operation). If the specified * collection is also a set, the <tt>addAll</tt> operation effectively * modifies this set so that its value is the <i>union</i> of the two * sets. The behavior of this operation is unspecified if the specified * collection is modified while the operation is in progress. * * @param c collection whose elements are to be added to this set. * @return <tt>true</tt> if this set changed as a result of the call. * * @throws UnsupportedOperationException if the <tt>addAll</tt> method is * not supported by this set. * @throws ClassCastException if the class of some element of the * specified collection prevents it from being added to this * set. * @throws NullPointerException if the specified collection contains one * or more null elements and this set does not support null * elements, or if the specified collection is <tt>null</tt>. * @throws IllegalArgumentException if some aspect of some element of the * specified collection prevents it from being added to this * set. * @see #add(Object) */ boolean addAll(Collection c); /** * 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. 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. * * @param c collection that defines which elements this set will retain. * @return <tt>true</tt> if this collection changed as a result of the * call. * @throws UnsupportedOperationException if the <tt>retainAll</tt> method * is not supported by this Collection. * @throws ClassCastException if the types of one or more elements in this * set are incompatible with the specified collection * (optional). * @throws NullPointerException if this set contains a null element and * the specified collection does not support null elements * (optional). * @throws NullPointerException if the specified collection is * <tt>null</tt>. * @see #remove(Object) */ 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 that defines which elements will be removed from * this set. * @return <tt>true</tt> if this set changed as a result of the call. * * @throws UnsupportedOperationException if the <tt>removeAll</tt> * method is not supported by this Collection. * @throws ClassCastException if the types of one or more elements in this * set are incompatible with the specified collection * (optional). * @throws NullPointerException if this set contains a null element and * the specified collection does not support null elements * (optional). * @throws NullPointerException if the specified collection is * <tt>null</tt>. * @see #remove(Object) */ boolean removeAll(Collection c); /** * Removes all of the elements from this set (optional operation). * This set will be empty after this call returns (unless it throws an * exception). * * @throws UnsupportedOperationException if the <tt>clear</tt> method * is not supported by this set. */ void clear(); // Comparison and hashing /** * Compares the specified object with this set for equality. Returns * <tt>true</tt> 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 <tt>true</tt> if the specified Object is equal to this set. */ boolean equals(Object o); /** * * Returns the hash code value for this set. The hash code of a set is * defined to be the sum of the hash codes of the elements in the set, * where the hashcode of a <tt>null</tt> element is defined to be zero. * This ensures that <code>s1.equals(s2)</code> implies that * <code>s1.hashCode()==s2.hashCode()</code> for any two sets * <code>s1</code> and <code>s2</code>, as required by the general * contract of the <tt>Object.hashCode</tt> method. * * @return the hash code value for this set. * @see Object#hashCode() * @see Object#equals(Object) * @see Set#equals(Object) */ int hashCode();}
⌨️ 快捷键说明
复制代码
Ctrl + C
搜索代码
Ctrl + F
全屏模式
F11
切换主题
Ctrl + Shift + D
显示快捷键
?
增大字号
Ctrl + =
减小字号
Ctrl + -