📄 treeset.html
字号:
<TD><CODE><B><A HREF="../../java/util/TreeSet.html#last()">last</A></B>()</CODE><BR> Returns the last (highest) element currently in this sorted set.</TD></TR><TR BGCOLOR="white" CLASS="TableRowColor"><TD ALIGN="right" VALIGN="top" WIDTH="1%"><FONT SIZE="-1"><CODE> boolean</CODE></FONT></TD><TD><CODE><B><A HREF="../../java/util/TreeSet.html#remove(java.lang.Object)">remove</A></B>(<A HREF="../../java/lang/Object.html">Object</A> o)</CODE><BR> Removes the given element from this set if it is present.</TD></TR><TR BGCOLOR="white" CLASS="TableRowColor"><TD ALIGN="right" VALIGN="top" WIDTH="1%"><FONT SIZE="-1"><CODE> int</CODE></FONT></TD><TD><CODE><B><A HREF="../../java/util/TreeSet.html#size()">size</A></B>()</CODE><BR> Returns the number of elements in this set (its cardinality).</TD></TR><TR BGCOLOR="white" CLASS="TableRowColor"><TD ALIGN="right" VALIGN="top" WIDTH="1%"><FONT SIZE="-1"><CODE> <A HREF="../../java/util/SortedSet.html">SortedSet</A></CODE></FONT></TD><TD><CODE><B><A HREF="../../java/util/TreeSet.html#subSet(java.lang.Object, java.lang.Object)">subSet</A></B>(<A HREF="../../java/lang/Object.html">Object</A> fromElement, <A HREF="../../java/lang/Object.html">Object</A> toElement)</CODE><BR> Returns a view of the portion of this set whose elements range from <tt>fromElement</tt>, inclusive, to <tt>toElement</tt>, exclusive.</TD></TR><TR BGCOLOR="white" CLASS="TableRowColor"><TD ALIGN="right" VALIGN="top" WIDTH="1%"><FONT SIZE="-1"><CODE> <A HREF="../../java/util/SortedSet.html">SortedSet</A></CODE></FONT></TD><TD><CODE><B><A HREF="../../java/util/TreeSet.html#tailSet(java.lang.Object)">tailSet</A></B>(<A HREF="../../java/lang/Object.html">Object</A> fromElement)</CODE><BR> Returns a view of the portion of this set whose elements are greater than or equal to <tt>fromElement</tt>.</TD></TR></TABLE> <A NAME="methods_inherited_from_class_java.util.AbstractSet"><!-- --></A><TABLE BORDER="1" CELLPADDING="3" CELLSPACING="0" WIDTH="100%"><TR BGCOLOR="#EEEEFF" CLASS="TableSubHeadingColor"><TD><B>Methods inherited from class java.util.<A HREF="../../java/util/AbstractSet.html">AbstractSet</A></B></TD></TR><TR BGCOLOR="white" CLASS="TableRowColor"><TD><CODE><A HREF="../../java/util/AbstractSet.html#equals(java.lang.Object)">equals</A>, <A HREF="../../java/util/AbstractSet.html#hashCode()">hashCode</A>, <A HREF="../../java/util/AbstractSet.html#removeAll(java.util.Collection)">removeAll</A></CODE></TD></TR></TABLE> <A NAME="methods_inherited_from_class_java.util.AbstractCollection"><!-- --></A><TABLE BORDER="1" CELLPADDING="3" CELLSPACING="0" WIDTH="100%"><TR BGCOLOR="#EEEEFF" CLASS="TableSubHeadingColor"><TD><B>Methods inherited from class java.util.<A HREF="../../java/util/AbstractCollection.html">AbstractCollection</A></B></TD></TR><TR BGCOLOR="white" CLASS="TableRowColor"><TD><CODE><A HREF="../../java/util/AbstractCollection.html#containsAll(java.util.Collection)">containsAll</A>, <A HREF="../../java/util/AbstractCollection.html#retainAll(java.util.Collection)">retainAll</A>, <A HREF="../../java/util/AbstractCollection.html#toArray()">toArray</A>, <A HREF="../../java/util/AbstractCollection.html#toArray(java.lang.Object[])">toArray</A>, <A HREF="../../java/util/AbstractCollection.html#toString()">toString</A></CODE></TD></TR></TABLE> <A NAME="methods_inherited_from_class_java.lang.Object"><!-- --></A><TABLE BORDER="1" CELLPADDING="3" CELLSPACING="0" WIDTH="100%"><TR BGCOLOR="#EEEEFF" CLASS="TableSubHeadingColor"><TD><B>Methods inherited from class java.lang.<A HREF="../../java/lang/Object.html">Object</A></B></TD></TR><TR BGCOLOR="white" CLASS="TableRowColor"><TD><CODE><A HREF="../../java/lang/Object.html#finalize()">finalize</A>, <A HREF="../../java/lang/Object.html#getClass()">getClass</A>, <A HREF="../../java/lang/Object.html#notify()">notify</A>, <A HREF="../../java/lang/Object.html#notifyAll()">notifyAll</A>, <A HREF="../../java/lang/Object.html#wait()">wait</A>, <A HREF="../../java/lang/Object.html#wait(long)">wait</A>, <A HREF="../../java/lang/Object.html#wait(long, int)">wait</A></CODE></TD></TR></TABLE> <A NAME="methods_inherited_from_class_java.util.Set"><!-- --></A><TABLE BORDER="1" CELLPADDING="3" CELLSPACING="0" WIDTH="100%"><TR BGCOLOR="#EEEEFF" CLASS="TableSubHeadingColor"><TD><B>Methods inherited from interface java.util.<A HREF="../../java/util/Set.html">Set</A></B></TD></TR><TR BGCOLOR="white" CLASS="TableRowColor"><TD><CODE><A HREF="../../java/util/Set.html#containsAll(java.util.Collection)">containsAll</A>, <A HREF="../../java/util/Set.html#equals(java.lang.Object)">equals</A>, <A HREF="../../java/util/Set.html#hashCode()">hashCode</A>, <A HREF="../../java/util/Set.html#removeAll(java.util.Collection)">removeAll</A>, <A HREF="../../java/util/Set.html#retainAll(java.util.Collection)">retainAll</A>, <A HREF="../../java/util/Set.html#toArray()">toArray</A>, <A HREF="../../java/util/Set.html#toArray(java.lang.Object[])">toArray</A></CODE></TD></TR></TABLE> <P><!-- ============ FIELD DETAIL =========== --><!-- ========= CONSTRUCTOR DETAIL ======== --><A NAME="constructor_detail"><!-- --></A><TABLE BORDER="1" CELLPADDING="3" CELLSPACING="0" WIDTH="100%"><TR BGCOLOR="#CCCCFF" CLASS="TableHeadingColor"><TD COLSPAN=1><FONT SIZE="+2"><B>Constructor Detail</B></FONT></TD></TR></TABLE><A NAME="TreeSet()"><!-- --></A><H3>TreeSet</H3><PRE>public <B>TreeSet</B>()</PRE><DL><DD>Constructs a new, empty set, sorted according to the elements' natural order. All elements inserted into the set must implement the <tt>Comparable</tt> interface. Furthermore, all such elements must be <i>mutually comparable</i>: <tt>e1.compareTo(e2)</tt> must not throw a <tt>ClassCastException</tt> for any elements <tt>e1</tt> and <tt>e2</tt> in the set. If the user attempts to add an element to the set that violates this constraint (for example, the user attempts to add a string element to a set whose elements are integers), the <tt>add(Object)</tt> call will throw a <tt>ClassCastException</tt>.<DD><DL><DT><B>See Also: </B><DD><A HREF="../../java/lang/Comparable.html"><CODE>Comparable</CODE></A></DL></DD></DL><HR><A NAME="TreeSet(java.util.Comparator)"><!-- --></A><H3>TreeSet</H3><PRE>public <B>TreeSet</B>(<A HREF="../../java/util/Comparator.html">Comparator</A> c)</PRE><DL><DD>Constructs a new, empty set, sorted according to the given comparator. All elements inserted into the set must be <i>mutually comparable</i> by the given comparator: <tt>comparator.compare(e1, e2)</tt> must not throw a <tt>ClassCastException</tt> for any elements <tt>e1</tt> and <tt>e2</tt> in the set. If the user attempts to add an element to the set that violates this constraint, the <tt>add(Object)</tt> call will throw a <tt>ClassCastException</tt>.<DD><DL><DT><B>Parameters:</B><DD><CODE>c</CODE> - the comparator that will be used to sort this set. A <tt>null</tt> value indicates that the elements' <i>natural ordering</i> should be used.</DL></DD></DL><HR><A NAME="TreeSet(java.util.Collection)"><!-- --></A><H3>TreeSet</H3><PRE>public <B>TreeSet</B>(<A HREF="../../java/util/Collection.html">Collection</A> c)</PRE><DL><DD>Constructs a new set containing the elements in the specified collection, sorted according to the elements' <i>natural order</i>. All keys inserted into the set must implement the <tt>Comparable</tt> interface. Furthermore, all such keys must be <i>mutually comparable</i>: <tt>k1.compareTo(k2)</tt> must not throw a <tt>ClassCastException</tt> for any elements <tt>k1</tt> and <tt>k2</tt> in the set.<DD><DL><DT><B>Parameters:</B><DD><CODE>c</CODE> - The elements that will comprise the new set.<DT><B>Throws:</B><DD><CODE><A HREF="../../java/lang/ClassCastException.html">ClassCastException</A></CODE> - if the keys in the given collection are not comparable, or are not mutually comparable.</DL></DD></DL><HR><A NAME="TreeSet(java.util.SortedSet)"><!-- --></A><H3>TreeSet</H3><PRE>public <B>TreeSet</B>(<A HREF="../../java/util/SortedSet.html">SortedSet</A> s)</PRE><DL><DD>Constructs a new set containing the same elements as the given sorted set, sorted according to the same ordering.<DD><DL><DT><B>Parameters:</B><DD><CODE>s</CODE> - sorted set whose elements will comprise the new set.</DL></DD></DL><!-- ============ METHOD DETAIL ========== --><A NAME="method_detail"><!-- --></A><TABLE BORDER="1" CELLPADDING="3" CELLSPACING="0" WIDTH="100%"><TR BGCOLOR="#CCCCFF" CLASS="TableHeadingColor"><TD COLSPAN=1><FONT SIZE="+2"><B>Method Detail</B></FONT></TD></TR></TABLE><A NAME="iterator()"><!-- --></A><H3>iterator</H3><PRE>public <A HREF="../../java/util/Iterator.html">Iterator</A> <B>iterator</B>()</PRE><DL><DD>Returns an iterator over the elements in this set. The elements are returned in ascending order.<DD><DL><DT><B>Specified by: </B><DD><CODE><A HREF="../../java/util/Set.html#iterator()">iterator</A></CODE> in interface <CODE><A HREF="../../java/util/Set.html">Set</A></CODE><DT><B>Overrides:</B><DD><CODE><A HREF="../../java/util/AbstractCollection.html#iterator()">iterator</A></CODE> in class <CODE><A HREF="../../java/util/AbstractCollection.html">AbstractCollection</A></CODE></DL></DD><DD><DL><DT><B>Returns:</B><DD>an iterator over the elements in this set.</DL></DD></DL><HR><A NAME="size()"><!-- --></A><H3>size</H3><PRE>public int <B>size</B>()</PRE><DL><DD>Returns the number of elements in this set (its cardinality).<DD><DL><DT><B>Specified by: </B><DD><CODE><A HREF="../../java/util/Set.html#size()">size</A></CODE> in interface <CODE><A HREF="../../java/util/Set.html">Set</A></CODE><DT><B>Overrides:</B><DD><CODE><A HREF="../../java/util/AbstractCollection.html#size()">size</A></CODE> in class <CODE><A HREF="../../java/util/AbstractCollection.html">AbstractCollection</A></CODE></DL></DD><DD><DL><DT><B>Returns:</B><DD>the number of elements in this set (its cardinality).</DL></DD></DL><HR><A NAME="isEmpty()"><!-- --></A><H3>isEmpty</H3><PRE>public boolean <B>isEmpty</B>()</PRE><DL><DD>Returns <tt>true</tt> if this set contains no elements.<DD><DL><DT><B>Specified by: </B><DD><CODE><A HREF="../../java/util/Set.html#isEmpty()">isEmpty</A></CODE> in interface <CODE><A HREF="../../java/util/Set.html">Set</A></CODE><DT><B>Overrides:</B><DD><CODE><A HREF="../../java/util/AbstractCollection.html#isEmpty()">isEmpty</A></CODE> in class <CODE><A HREF="../../java/util/AbstractCollection.html">AbstractCollection</A></CODE></DL></DD><DD><DL><DT><B>Returns:</B><DD><tt>true</tt> if this set contains no elements.</DL></DD></DL><HR><A NAME="contains(java.lang.Object)"><!-- --></A><H3>contains</H3><PRE>public boolean <B>contains</B>(<A HREF="../../java/lang/Object.html">Object</A> o)</PRE><DL><DD>Returns <tt>true</tt> if this set contains the specified element.<DD><DL><DT><B>Specified by: </B><DD><CODE><A HREF="../../java/util/Set.html#contains(java.lang.Object)">contains</A></CODE> in interface <CODE><A HREF="../../java/util/Set.html">Set</A></CODE><DT><B>Overrides:</B><DD><CODE><A HREF="../../java/util/AbstractCollection.html#contains(java.lang.Object)">contains</A></CODE> in class <CODE><A HREF="../../java/util/AbstractCollection.html">AbstractCollection</A></CODE></DL></DD><DD><DL><DT><B>Parameters:</B><DD><CODE>o</CODE> - the object to be checked for containment in this set.<DT><B>Returns:</B><DD><tt>true</tt> if this set contains the specified element.<DT><B>Throws:</B><DD><CODE><A HREF="../../java/lang/ClassCastException.html">ClassCastException</A></CODE> - if the specified object cannot be compared with the elements currently in the set.</DL></DD></DL><HR><A NAME="add(java.lang.Object)"><!-- --></A><H3>add</H3><PRE>public boolean <B>add</B>(<A HREF="../../java/lang/Object.html">Object</A> o)</PRE><DL><DD>Adds the specified element to this set if it is not already present.<DD><DL><DT><B>Specified by: </B><DD><CODE><A HREF="../../java/util/Set.html#add(java.lang.Object)">add</A></CODE> in interface <CODE><A HREF="../../java/util/Set.html">Set</A></CODE><DT><B>Overrides:</B><DD><CODE><A HREF="../../java/util/AbstractCollection.html#add(java.lang.Object)">add</A></CODE> in class <CODE><A HREF="../../java/util/AbstractCollection.html">AbstractCollection</A></CODE></DL></DD><DD><DL><DT><B>Parameters:</B><DD><CODE>o</CODE> - element to be added to this set.<DT><B>Returns:</B><DD><tt>true</tt> if the set did not already contain the specified element.<DT><B>Throws:</B><DD><CODE><A HREF="../../java/lang/ClassCastException.html">ClassCastException</A></CODE> - if the specified object cannot be compared with the elements currently in the set.</DL></DD></DL><HR><A NAME="remove(java.lang.Object)"><!-- --></A><H3>remove</H3><PRE>public boolean <B>remove</B>(<A HREF="../../java/lang/Object.html">Object</A> o)</PRE><DL><DD>Removes the given element from this set if it is present.<DD><DL><DT><B>Specified by: </B><DD><CODE><A HREF="../../java/util/Set.html#remove(java.lang.Object)">remove</A></CODE> in interface <CODE><A HREF="../../java/util/Set.html">Set</A></CODE><DT><B>Overrides:</B><DD><CODE><A HREF="../../java/util/AbstractCollection.html#remove(java.lang.Object)">remove</A></CODE> in class <CODE><A HREF="../../java/util/AbstractCollection.html">AbstractCollection</A></CODE></DL></DD><DD><DL><DT><B>Parameters:</B><DD><CODE>o</CODE> - object to be removed from this set, if present.<DT><B>Returns:</B><DD><tt>true</tt> if the set contained the specified element.<DT><B>Throws:</B><DD><CODE><A HREF="../../java/lang/ClassCastException.html">ClassCastException</A></CODE> - if the specified object cannot be compared with the elements currently in the set.</DL></DD></DL><HR><A NAME="clear()"><!-- --></A><H3>clear</H3><PRE>public void <B>clear</B>()</PRE><DL>
⌨️ 快捷键说明
复制代码
Ctrl + C
搜索代码
Ctrl + F
全屏模式
F11
切换主题
Ctrl + Shift + D
显示快捷键
?
增大字号
Ctrl + =
减小字号
Ctrl + -