1 <!DOCTYPE HTML PUBLIC "-//W3C//DTD HTML 4.01 Transitional//EN" "http://www.w3.org/TR/html4/loose.dtd"> 2 <!--NewPage--> 3 <HTML> 4 <HEAD> 5 <!-- Generated by javadoc (build 1.6.0-google-internal) on Mon Jan 04 20:47:59 PST 2010 --> 6 <TITLE> 7 Multiset (Guava Libraries 2010.01.04) 8 </TITLE> 9 10 <META NAME="date" CONTENT="2010-01-04"> 11 12 <LINK REL ="stylesheet" TYPE="text/css" HREF="../../../../stylesheet.css" TITLE="Style"> 13 14 <SCRIPT type="text/javascript"> 15 function windowTitle() 16 { 17 if (location.href.indexOf('is-external=true') == -1) { 18 parent.document.title="Multiset (Guava Libraries 2010.01.04)"; 19 } 20 } 21 </SCRIPT> 22 <NOSCRIPT> 23 </NOSCRIPT> 24 25 </HEAD> 26 27 <BODY BGCOLOR="white" onload="windowTitle();"> 28 <HR> 29 30 31 <!-- ========= START OF TOP NAVBAR ======= --> 32 <A NAME="navbar_top"><!-- --></A> 33 <A HREF="#skip-navbar_top" title="Skip navigation links"></A> 34 <TABLE BORDER="0" WIDTH="100%" CELLPADDING="1" CELLSPACING="0" SUMMARY=""> 35 <TR> 36 <TD COLSPAN=2 BGCOLOR="#EEEEFF" CLASS="NavBarCell1"> 37 <A NAME="navbar_top_firstrow"><!-- --></A> 38 <TABLE BORDER="0" CELLPADDING="0" CELLSPACING="3" SUMMARY=""> 39 <TR ALIGN="center" VALIGN="top"> 40 <TD BGCOLOR="#EEEEFF" CLASS="NavBarCell1"> <A HREF="../../../../overview-summary.html"><FONT CLASS="NavBarFont1"><B>Overview</B></FONT></A> </TD> 41 <TD BGCOLOR="#EEEEFF" CLASS="NavBarCell1"> <A HREF="package-summary.html"><FONT CLASS="NavBarFont1"><B>Package</B></FONT></A> </TD> 42 <TD BGCOLOR="#FFFFFF" CLASS="NavBarCell1Rev"> <FONT CLASS="NavBarFont1Rev"><B>Class</B></FONT> </TD> 43 <TD BGCOLOR="#EEEEFF" CLASS="NavBarCell1"> <A HREF="class-use/Multiset.html"><FONT CLASS="NavBarFont1"><B>Use</B></FONT></A> </TD> 44 <TD BGCOLOR="#EEEEFF" CLASS="NavBarCell1"> <A HREF="package-tree.html"><FONT CLASS="NavBarFont1"><B>Tree</B></FONT></A> </TD> 45 <TD BGCOLOR="#EEEEFF" CLASS="NavBarCell1"> <A HREF="../../../../deprecated-list.html"><FONT CLASS="NavBarFont1"><B>Deprecated</B></FONT></A> </TD> 46 <TD BGCOLOR="#EEEEFF" CLASS="NavBarCell1"> <A HREF="../../../../index-all.html"><FONT CLASS="NavBarFont1"><B>Index</B></FONT></A> </TD> 47 <TD BGCOLOR="#EEEEFF" CLASS="NavBarCell1"> <A HREF="../../../../help-doc.html"><FONT CLASS="NavBarFont1"><B>Help</B></FONT></A> </TD> 48 </TR> 49 </TABLE> 50 </TD> 51 <TD ALIGN="right" VALIGN="top" ROWSPAN=3><EM> 52 </EM> 53 </TD> 54 </TR> 55 56 <TR> 57 <TD BGCOLOR="white" CLASS="NavBarCell2"><FONT SIZE="-2"> 58 <A HREF="../../../../com/google/common/collect/Multimaps.html" title="class in com.google.common.collect"><B>PREV CLASS</B></A> 59 <A HREF="../../../../com/google/common/collect/Multiset.Entry.html" title="interface in com.google.common.collect"><B>NEXT CLASS</B></A></FONT></TD> 60 <TD BGCOLOR="white" CLASS="NavBarCell2"><FONT SIZE="-2"> 61 <A HREF="../../../../index.html?com/google/common/collect/Multiset.html" target="_top"><B>FRAMES</B></A> 62 <A HREF="Multiset.html" target="_top"><B>NO FRAMES</B></A> 63 <SCRIPT type="text/javascript"> 64 <!-- 65 if(window==top) { 66 document.writeln('<A HREF="../../../../allclasses-noframe.html"><B>All Classes</B></A>'); 67 } 68 //--> 69 </SCRIPT> 70 <NOSCRIPT> 71 <A HREF="../../../../allclasses-noframe.html"><B>All Classes</B></A> 72 </NOSCRIPT> 73 74 75 </FONT></TD> 76 </TR> 77 <TR> 78 <TD VALIGN="top" CLASS="NavBarCell3"><FONT SIZE="-2"> 79 SUMMARY: <A HREF="#nested_class_summary">NESTED</A> | FIELD | CONSTR | <A HREF="#method_summary">METHOD</A></FONT></TD> 80 <TD VALIGN="top" CLASS="NavBarCell3"><FONT SIZE="-2"> 81 DETAIL: FIELD | CONSTR | <A HREF="#method_detail">METHOD</A></FONT></TD> 82 </TR> 83 </TABLE> 84 <A NAME="skip-navbar_top"></A> 85 <!-- ========= END OF TOP NAVBAR ========= --> 86 87 <HR> 88 <!-- ======== START OF CLASS DATA ======== --> 89 <H2> 90 <FONT SIZE="-1"> 91 com.google.common.collect</FONT> 92 <BR> 93 Interface Multiset<E></H2> 94 <DL> 95 <DT><B>All Superinterfaces:</B> <DD><A HREF="http://java.sun.com/javase/6/docs/api/java/util/Collection.html?is-external=true" title="class or interface in java.util">Collection</A><E>, <A HREF="http://java.sun.com/javase/6/docs/api/java/lang/Iterable.html?is-external=true" title="class or interface in java.lang">Iterable</A><E></DD> 96 </DL> 97 <DL> 98 <DT><B>All Known Implementing Classes:</B> <DD><A HREF="../../../../com/google/common/collect/ConcurrentHashMultiset.html" title="class in com.google.common.collect">ConcurrentHashMultiset</A>, <A HREF="../../../../com/google/common/collect/EnumMultiset.html" title="class in com.google.common.collect">EnumMultiset</A>, <A HREF="../../../../com/google/common/collect/ForwardingMultiset.html" title="class in com.google.common.collect">ForwardingMultiset</A>, <A HREF="../../../../com/google/common/collect/HashMultiset.html" title="class in com.google.common.collect">HashMultiset</A>, <A HREF="../../../../com/google/common/collect/ImmutableMultiset.html" title="class in com.google.common.collect">ImmutableMultiset</A>, <A HREF="../../../../com/google/common/collect/LinkedHashMultiset.html" title="class in com.google.common.collect">LinkedHashMultiset</A>, <A HREF="../../../../com/google/common/collect/TreeMultiset.html" title="class in com.google.common.collect">TreeMultiset</A></DD> 99 </DL> 100 <HR> 101 <DL> 102 <DT><PRE>public interface <B>Multiset<E></B><DT>extends <A HREF="http://java.sun.com/javase/6/docs/api/java/util/Collection.html?is-external=true" title="class or interface in java.util">Collection</A><E></DL> 103 </PRE> 104 105 <P> 106 A collection that supports order-independent equality, like <A HREF="http://java.sun.com/javase/6/docs/api/java/util/Set.html?is-external=true" title="class or interface in java.util"><CODE>Set</CODE></A>, but 107 may have duplicate elements. A multiset is also sometimes called a 108 <i>bag</i>. 109 110 <p>Elements of a multiset that are equal to one another (see "Note on 111 element equivalence", below) are referred to as <i>occurrences</i> of the 112 same single element. The total number of occurrences of an element in a 113 multiset is called the <i>count</i> of that element (the terms "frequency" 114 and "multiplicity" are equivalent, but not used in this API). Since the count 115 of an element is represented as an <code>int</code>, a multiset may never contain 116 more than <A HREF="http://java.sun.com/javase/6/docs/api/java/lang/Integer.html?is-external=true#MAX_VALUE" title="class or interface in java.lang"><CODE>Integer.MAX_VALUE</CODE></A> occurrences of any one element. 117 118 <p><code>Multiset</code> refines the specifications of several methods from 119 <code>Collection</code>. It also defines an additional query operation, <A HREF="../../../../com/google/common/collect/Multiset.html#count(java.lang.Object)"><CODE>count(java.lang.Object)</CODE></A>, which returns the count of an element. There are five new 120 bulk-modification operations, for example <A HREF="../../../../com/google/common/collect/Multiset.html#add(E, int)"><CODE>add(Object, int)</CODE></A>, to add 121 or remove multiple occurrences of an element at once, or to set the count of 122 an element to a specific value. These modification operations are optional, 123 but implementations which support the standard collection operations <A HREF="../../../../com/google/common/collect/Multiset.html#add(E)"><CODE>add(Object)</CODE></A> or <A HREF="../../../../com/google/common/collect/Multiset.html#remove(java.lang.Object)"><CODE>remove(Object)</CODE></A> are encouraged to implement the 124 related methods as well. Finally, two collection views are provided: <A HREF="../../../../com/google/common/collect/Multiset.html#elementSet()"><CODE>elementSet()</CODE></A> contains the distinct elements of the multiset "with duplicates 125 collapsed", and <A HREF="../../../../com/google/common/collect/Multiset.html#entrySet()"><CODE>entrySet()</CODE></A> is similar but contains <A HREF="../../../../com/google/common/collect/Multiset.Entry.html" title="interface in com.google.common.collect"><CODE>Multiset.Entry</CODE></A> instances, each providing both a distinct element and the 126 count of that element. 127 128 <p>In addition to these required methods, implementations of <code>Multiset</code> are expected to provide two <code>static</code> creation methods: 129 <code>create()</code>, returning an empty multiset, and <code>create(Iterable<? extends E>)</code>, returning a multiset containing the 130 given initial elements. This is simply a refinement of <code>Collection</code>'s 131 constructor recommendations, reflecting the new developments of Java 5. 132 133 <p>As with other collection types, the modification operations are optional, 134 and should throw <A HREF="http://java.sun.com/javase/6/docs/api/java/lang/UnsupportedOperationException.html?is-external=true" title="class or interface in java.lang"><CODE>UnsupportedOperationException</CODE></A> when they are not 135 implemented. Most implementations should support either all add operations 136 or none of them, all removal operations or none of them, and if and only if 137 all of these are supported, the <code>setCount</code> methods as well. 138 139 <p>A multiset uses <A HREF="http://java.sun.com/javase/6/docs/api/java/lang/Object.html?is-external=true#equals(java.lang.Object)" title="class or interface in java.lang"><CODE>Object.equals(java.lang.Object)</CODE></A> to determine whether two instances 140 should be considered "the same," <i>unless specified otherwise</i> by the 141 implementation. 142 <P> 143 144 <P> 145 <DL> 146 <DT><B>Since:</B></DT> 147 <DD>2010.01.04 <b>stable</b> (imported from Google Collections Library)</DD> 148 <DT><B>Author:</B></DT> 149 <DD>Kevin Bourrillion</DD> 150 </DL> 151 <HR> 152 153 <P> 154 <!-- ======== NESTED CLASS SUMMARY ======== --> 155 156 <A NAME="nested_class_summary"><!-- --></A> 157 <TABLE BORDER="1" WIDTH="100%" CELLPADDING="3" CELLSPACING="0" SUMMARY=""> 158 <TR BGCOLOR="#CCCCFF" CLASS="TableHeadingColor"> 159 <TH ALIGN="left" COLSPAN="2"><FONT SIZE="+2"> 160 <B>Nested Class Summary</B></FONT></TH> 161 </TR> 162 <TR BGCOLOR="white" CLASS="TableRowColor"> 163 <TD ALIGN="right" VALIGN="top" WIDTH="1%"><FONT SIZE="-1"> 164 <CODE>static interface</CODE></FONT></TD> 165 <TD><CODE><B><A HREF="../../../../com/google/common/collect/Multiset.Entry.html" title="interface in com.google.common.collect">Multiset.Entry</A><<A HREF="../../../../com/google/common/collect/Multiset.Entry.html" title="type parameter in Multiset.Entry">E</A>></B></CODE> 166 167 <BR> 168 An unmodifiable element-count pair for a multiset.</TD> 169 </TR> 170 </TABLE> 171 172 <!-- ========== METHOD SUMMARY =========== --> 173 174 <A NAME="method_summary"><!-- --></A> 175 <TABLE BORDER="1" WIDTH="100%" CELLPADDING="3" CELLSPACING="0" SUMMARY=""> 176 <TR BGCOLOR="#CCCCFF" CLASS="TableHeadingColor"> 177 <TH ALIGN="left" COLSPAN="2"><FONT SIZE="+2"> 178 <B>Method Summary</B></FONT></TH> 179 </TR> 180 <TR BGCOLOR="white" CLASS="TableRowColor"> 181 <TD ALIGN="right" VALIGN="top" WIDTH="1%"><FONT SIZE="-1"> 182 <CODE> boolean</CODE></FONT></TD> 183 <TD><CODE><B><A HREF="../../../../com/google/common/collect/Multiset.html#add(E)">add</A></B>(<A HREF="../../../../com/google/common/collect/Multiset.html" title="type parameter in Multiset">E</A> element)</CODE> 184 185 <BR> 186 Adds a single occurrence of the specified element to this multiset.</TD> 187 </TR> 188 <TR BGCOLOR="white" CLASS="TableRowColor"> 189 <TD ALIGN="right" VALIGN="top" WIDTH="1%"><FONT SIZE="-1"> 190 <CODE> int</CODE></FONT></TD> 191 <TD><CODE><B><A HREF="../../../../com/google/common/collect/Multiset.html#add(E, int)">add</A></B>(<A HREF="../../../../com/google/common/collect/Multiset.html" title="type parameter in Multiset">E</A> element, 192 int occurrences)</CODE> 193 194 <BR> 195 Adds a number of occurrences of an element to this multiset.</TD> 196 </TR> 197 <TR BGCOLOR="white" CLASS="TableRowColor"> 198 <TD ALIGN="right" VALIGN="top" WIDTH="1%"><FONT SIZE="-1"> 199 <CODE> boolean</CODE></FONT></TD> 200 <TD><CODE><B><A HREF="../../../../com/google/common/collect/Multiset.html#contains(java.lang.Object)">contains</A></B>(<A HREF="http://java.sun.com/javase/6/docs/api/java/lang/Object.html?is-external=true" title="class or interface in java.lang">Object</A> element)</CODE> 201 202 <BR> 203 Determines whether this multiset contains the specified element.</TD> 204 </TR> 205 <TR BGCOLOR="white" CLASS="TableRowColor"> 206 <TD ALIGN="right" VALIGN="top" WIDTH="1%"><FONT SIZE="-1"> 207 <CODE> boolean</CODE></FONT></TD> 208 <TD><CODE><B><A HREF="../../../../com/google/common/collect/Multiset.html#containsAll(java.util.Collection)">containsAll</A></B>(<A HREF="http://java.sun.com/javase/6/docs/api/java/util/Collection.html?is-external=true" title="class or interface in java.util">Collection</A><?> elements)</CODE> 209 210 <BR> 211 Returns <code>true</code> if this multiset contains at least one occurrence of 212 each element in the specified collection.</TD> 213 </TR> 214 <TR BGCOLOR="white" CLASS="TableRowColor"> 215 <TD ALIGN="right" VALIGN="top" WIDTH="1%"><FONT SIZE="-1"> 216 <CODE> int</CODE></FONT></TD> 217 <TD><CODE><B><A HREF="../../../../com/google/common/collect/Multiset.html#count(java.lang.Object)">count</A></B>(<A HREF="http://java.sun.com/javase/6/docs/api/java/lang/Object.html?is-external=true" title="class or interface in java.lang">Object</A> element)</CODE> 218 219 <BR> 220 Returns the number of occurrences of an element in this multiset (the 221 <i>count</i> of the element).</TD> 222 </TR> 223 <TR BGCOLOR="white" CLASS="TableRowColor"> 224 <TD ALIGN="right" VALIGN="top" WIDTH="1%"><FONT SIZE="-1"> 225 <CODE> <A HREF="http://java.sun.com/javase/6/docs/api/java/util/Set.html?is-external=true" title="class or interface in java.util">Set</A><<A HREF="../../../../com/google/common/collect/Multiset.html" title="type parameter in Multiset">E</A>></CODE></FONT></TD> 226 <TD><CODE><B><A HREF="../../../../com/google/common/collect/Multiset.html#elementSet()">elementSet</A></B>()</CODE> 227 228 <BR> 229 Returns the set of distinct elements contained in this multiset.</TD> 230 </TR> 231 <TR BGCOLOR="white" CLASS="TableRowColor"> 232 <TD ALIGN="right" VALIGN="top" WIDTH="1%"><FONT SIZE="-1"> 233 <CODE> <A HREF="http://java.sun.com/javase/6/docs/api/java/util/Set.html?is-external=true" title="class or interface in java.util">Set</A><<A HREF="../../../../com/google/common/collect/Multiset.Entry.html" title="interface in com.google.common.collect">Multiset.Entry</A><<A HREF="../../../../com/google/common/collect/Multiset.html" title="type parameter in Multiset">E</A>>></CODE></FONT></TD> 234 <TD><CODE><B><A HREF="../../../../com/google/common/collect/Multiset.html#entrySet()">entrySet</A></B>()</CODE> 235 236 <BR> 237 Returns a view of the contents of this multiset, grouped into <code>Multiset.Entry</code> instances, each providing an element of the multiset and 238 the count of that element.</TD> 239 </TR> 240 <TR BGCOLOR="white" CLASS="TableRowColor"> 241 <TD ALIGN="right" VALIGN="top" WIDTH="1%"><FONT SIZE="-1"> 242 <CODE> boolean</CODE></FONT></TD> 243 <TD><CODE><B><A HREF="../../../../com/google/common/collect/Multiset.html#equals(java.lang.Object)">equals</A></B>(<A HREF="http://java.sun.com/javase/6/docs/api/java/lang/Object.html?is-external=true" title="class or interface in java.lang">Object</A> object)</CODE> 244 245 <BR> 246 Compares the specified object with this multiset for equality.</TD> 247 </TR> 248 <TR BGCOLOR="white" CLASS="TableRowColor"> 249 <TD ALIGN="right" VALIGN="top" WIDTH="1%"><FONT SIZE="-1"> 250 <CODE> int</CODE></FONT></TD> 251 <TD><CODE><B><A HREF="../../../../com/google/common/collect/Multiset.html#hashCode()">hashCode</A></B>()</CODE> 252 253 <BR> 254 Returns the hash code for this multiset.</TD> 255 </TR> 256 <TR BGCOLOR="white" CLASS="TableRowColor"> 257 <TD ALIGN="right" VALIGN="top" WIDTH="1%"><FONT SIZE="-1"> 258 <CODE> <A HREF="http://java.sun.com/javase/6/docs/api/java/util/Iterator.html?is-external=true" title="class or interface in java.util">Iterator</A><<A HREF="../../../../com/google/common/collect/Multiset.html" title="type parameter in Multiset">E</A>></CODE></FONT></TD> 259 <TD><CODE><B><A HREF="../../../../com/google/common/collect/Multiset.html#iterator()">iterator</A></B>()</CODE> 260 261 <BR> 262 </TD> 263 </TR> 264 <TR BGCOLOR="white" CLASS="TableRowColor"> 265 <TD ALIGN="right" VALIGN="top" WIDTH="1%"><FONT SIZE="-1"> 266 <CODE> boolean</CODE></FONT></TD> 267 <TD><CODE><B><A HREF="../../../../com/google/common/collect/Multiset.html#remove(java.lang.Object)">remove</A></B>(<A HREF="http://java.sun.com/javase/6/docs/api/java/lang/Object.html?is-external=true" title="class or interface in java.lang">Object</A> element)</CODE> 268 269 <BR> 270 Removes a <i>single</i> occurrence of the specified element from this 271 multiset, if present.</TD> 272 </TR> 273 <TR BGCOLOR="white" CLASS="TableRowColor"> 274 <TD ALIGN="right" VALIGN="top" WIDTH="1%"><FONT SIZE="-1"> 275 <CODE> int</CODE></FONT></TD> 276 <TD><CODE><B><A HREF="../../../../com/google/common/collect/Multiset.html#remove(java.lang.Object, int)">remove</A></B>(<A HREF="http://java.sun.com/javase/6/docs/api/java/lang/Object.html?is-external=true" title="class or interface in java.lang">Object</A> element, 277 int occurrences)</CODE> 278 279 <BR> 280 Removes a number of occurrences of the specified element from this 281 multiset.</TD> 282 </TR> 283 <TR BGCOLOR="white" CLASS="TableRowColor"> 284 <TD ALIGN="right" VALIGN="top" WIDTH="1%"><FONT SIZE="-1"> 285 <CODE> boolean</CODE></FONT></TD> 286 <TD><CODE><B><A HREF="../../../../com/google/common/collect/Multiset.html#removeAll(java.util.Collection)">removeAll</A></B>(<A HREF="http://java.sun.com/javase/6/docs/api/java/util/Collection.html?is-external=true" title="class or interface in java.util">Collection</A><?> c)</CODE> 287 288 <BR> 289 </TD> 290 </TR> 291 <TR BGCOLOR="white" CLASS="TableRowColor"> 292 <TD ALIGN="right" VALIGN="top" WIDTH="1%"><FONT SIZE="-1"> 293 <CODE> boolean</CODE></FONT></TD> 294 <TD><CODE><B><A HREF="../../../../com/google/common/collect/Multiset.html#retainAll(java.util.Collection)">retainAll</A></B>(<A HREF="http://java.sun.com/javase/6/docs/api/java/util/Collection.html?is-external=true" title="class or interface in java.util">Collection</A><?> c)</CODE> 295 296 <BR> 297 </TD> 298 </TR> 299 <TR BGCOLOR="white" CLASS="TableRowColor"> 300 <TD ALIGN="right" VALIGN="top" WIDTH="1%"><FONT SIZE="-1"> 301 <CODE> int</CODE></FONT></TD> 302 <TD><CODE><B><A HREF="../../../../com/google/common/collect/Multiset.html#setCount(E, int)">setCount</A></B>(<A HREF="../../../../com/google/common/collect/Multiset.html" title="type parameter in Multiset">E</A> element, 303 int count)</CODE> 304 305 <BR> 306 Adds or removes the necessary occurrences of an element such that the 307 element attains the desired count.</TD> 308 </TR> 309 <TR BGCOLOR="white" CLASS="TableRowColor"> 310 <TD ALIGN="right" VALIGN="top" WIDTH="1%"><FONT SIZE="-1"> 311 <CODE> boolean</CODE></FONT></TD> 312 <TD><CODE><B><A HREF="../../../../com/google/common/collect/Multiset.html#setCount(E, int, int)">setCount</A></B>(<A HREF="../../../../com/google/common/collect/Multiset.html" title="type parameter in Multiset">E</A> element, 313 int oldCount, 314 int newCount)</CODE> 315 316 <BR> 317 Conditionally sets the count of an element to a new value, as described in 318 <A HREF="../../../../com/google/common/collect/Multiset.html#setCount(E, int)"><CODE>setCount(Object, int)</CODE></A>, provided that the element has the expected 319 current count.</TD> 320 </TR> 321 <TR BGCOLOR="white" CLASS="TableRowColor"> 322 <TD ALIGN="right" VALIGN="top" WIDTH="1%"><FONT SIZE="-1"> 323 <CODE> <A HREF="http://java.sun.com/javase/6/docs/api/java/lang/String.html?is-external=true" title="class or interface in java.lang">String</A></CODE></FONT></TD> 324 <TD><CODE><B><A HREF="../../../../com/google/common/collect/Multiset.html#toString()">toString</A></B>()</CODE> 325 326 <BR> 327 </TD> 328 </TR> 329 </TABLE> 330 <A NAME="methods_inherited_from_class_java.util.Collection"><!-- --></A> 331 <TABLE BORDER="1" WIDTH="100%" CELLPADDING="3" CELLSPACING="0" SUMMARY=""> 332 <TR BGCOLOR="#EEEEFF" CLASS="TableSubHeadingColor"> 333 <TH ALIGN="left"><B>Methods inherited from interface java.util.<A HREF="http://java.sun.com/javase/6/docs/api/java/util/Collection.html?is-external=true" title="class or interface in java.util">Collection</A></B></TH> 334 </TR> 335 <TR BGCOLOR="white" CLASS="TableRowColor"> 336 <TD><CODE><A HREF="http://java.sun.com/javase/6/docs/api/java/util/Collection.html?is-external=true#addAll(java.util.Collection)" title="class or interface in java.util">addAll</A>, <A HREF="http://java.sun.com/javase/6/docs/api/java/util/Collection.html?is-external=true#clear()" title="class or interface in java.util">clear</A>, <A HREF="http://java.sun.com/javase/6/docs/api/java/util/Collection.html?is-external=true#isEmpty()" title="class or interface in java.util">isEmpty</A>, <A HREF="http://java.sun.com/javase/6/docs/api/java/util/Collection.html?is-external=true#size()" title="class or interface in java.util">size</A>, <A HREF="http://java.sun.com/javase/6/docs/api/java/util/Collection.html?is-external=true#toArray()" title="class or interface in java.util">toArray</A>, <A HREF="http://java.sun.com/javase/6/docs/api/java/util/Collection.html?is-external=true#toArray(T[])" title="class or interface in java.util">toArray</A></CODE></TD> 337 </TR> 338 </TABLE> 339 340 <P> 341 342 <!-- ============ METHOD DETAIL ========== --> 343 344 <A NAME="method_detail"><!-- --></A> 345 <TABLE BORDER="1" WIDTH="100%" CELLPADDING="3" CELLSPACING="0" SUMMARY=""> 346 <TR BGCOLOR="#CCCCFF" CLASS="TableHeadingColor"> 347 <TH ALIGN="left" COLSPAN="1"><FONT SIZE="+2"> 348 <B>Method Detail</B></FONT></TH> 349 </TR> 350 </TABLE> 351 352 <A NAME="count(java.lang.Object)"><!-- --></A><H3> 353 count</H3> 354 <PRE> 355 int <B>count</B>(<FONT SIZE="-1"><A HREF="http://jsr-305.googlecode.com/svn/trunk/javadoc/javax/annotation/Nullable.html?is-external=true" title="class or interface in javax.annotation">@Nullable</A></FONT> 356 <A HREF="http://java.sun.com/javase/6/docs/api/java/lang/Object.html?is-external=true" title="class or interface in java.lang">Object</A> element)</PRE> 357 <DL> 358 <DD>Returns the number of occurrences of an element in this multiset (the 359 <i>count</i> of the element). Note that for an <A HREF="http://java.sun.com/javase/6/docs/api/java/lang/Object.html?is-external=true#equals(java.lang.Object)" title="class or interface in java.lang"><CODE>Object.equals(java.lang.Object)</CODE></A>-based 360 multiset, this gives the same result as <A HREF="http://java.sun.com/javase/6/docs/api/java/util/Collections.html?is-external=true#frequency(java.util.Collection, java.lang.Object)" title="class or interface in java.util"><CODE>Collections.frequency(java.util.Collection<?>, java.lang.Object)</CODE></A> 361 (which would presumably perform more poorly). 362 363 <p><b>Note:</b> the utility method <A HREF="../../../../com/google/common/collect/Iterables.html#frequency(java.lang.Iterable, java.lang.Object)"><CODE>Iterables.frequency(java.lang.Iterable<?>, java.lang.Object)</CODE></A> generalizes 364 this operation; it correctly delegates to this method when dealing with a 365 multiset, but it can also accept any other iterable type. 366 <P> 367 <DD><DL> 368 </DL> 369 </DD> 370 <DD><DL> 371 <DT><B>Parameters:</B><DD><CODE>element</CODE> - the element to count occurrences of 372 <DT><B>Returns:</B><DD>the number of occurrences of the element in this multiset; possibly 373 zero but never negative</DL> 374 </DD> 375 </DL> 376 <HR> 377 378 <A NAME="add(java.lang.Object,int)"><!-- --></A><A NAME="add(E, int)"><!-- --></A><H3> 379 add</H3> 380 <PRE> 381 int <B>add</B>(<FONT SIZE="-1"><A HREF="http://jsr-305.googlecode.com/svn/trunk/javadoc/javax/annotation/Nullable.html?is-external=true" title="class or interface in javax.annotation">@Nullable</A></FONT> 382 <A HREF="../../../../com/google/common/collect/Multiset.html" title="type parameter in Multiset">E</A> element, 383 int occurrences)</PRE> 384 <DL> 385 <DD>Adds a number of occurrences of an element to this multiset. Note that if 386 <code>occurrences == 1</code>, this method has the identical effect to <A HREF="../../../../com/google/common/collect/Multiset.html#add(E)"><CODE>add(Object)</CODE></A>. This method is functionally equivalent (except in the case 387 of overflow) to the call <code>addAll(Collections.nCopies(element, 388 occurrences))</code>, which would presumably perform much more poorly. 389 <P> 390 <DD><DL> 391 </DL> 392 </DD> 393 <DD><DL> 394 <DT><B>Parameters:</B><DD><CODE>element</CODE> - the element to add occurrences of; may be <code>null</code> only 395 if explicitly allowed by the implementation<DD><CODE>occurrences</CODE> - the number of occurrences of the element to add. May be 396 zero, in which case no change will be made. 397 <DT><B>Returns:</B><DD>the count of the element before the operation; possibly zero 398 <DT><B>Throws:</B> 399 <DD><CODE><A HREF="http://java.sun.com/javase/6/docs/api/java/lang/IllegalArgumentException.html?is-external=true" title="class or interface in java.lang">IllegalArgumentException</A></CODE> - if <code>occurrences</code> is negative, or if 400 this operation would result in more than <A HREF="http://java.sun.com/javase/6/docs/api/java/lang/Integer.html?is-external=true#MAX_VALUE" title="class or interface in java.lang"><CODE>Integer.MAX_VALUE</CODE></A> 401 occurrences of the element 402 <DD><CODE><A HREF="http://java.sun.com/javase/6/docs/api/java/lang/NullPointerException.html?is-external=true" title="class or interface in java.lang">NullPointerException</A></CODE> - if <code>element</code> is null and this 403 implementation does not permit null elements. Note that if <code>occurrences</code> is zero, the implementation may opt to return normally.</DL> 404 </DD> 405 </DL> 406 <HR> 407 408 <A NAME="remove(java.lang.Object, int)"><!-- --></A><H3> 409 remove</H3> 410 <PRE> 411 int <B>remove</B>(<FONT SIZE="-1"><A HREF="http://jsr-305.googlecode.com/svn/trunk/javadoc/javax/annotation/Nullable.html?is-external=true" title="class or interface in javax.annotation">@Nullable</A></FONT> 412 <A HREF="http://java.sun.com/javase/6/docs/api/java/lang/Object.html?is-external=true" title="class or interface in java.lang">Object</A> element, 413 int occurrences)</PRE> 414 <DL> 415 <DD>Removes a number of occurrences of the specified element from this 416 multiset. If the multiset contains fewer than this number of occurrences to 417 begin with, all occurrences will be removed. Note that if 418 <code>occurrences == 1</code>, this is functionally equivalent to the call 419 <code>remove(element)</code>. 420 <P> 421 <DD><DL> 422 </DL> 423 </DD> 424 <DD><DL> 425 <DT><B>Parameters:</B><DD><CODE>element</CODE> - the element to conditionally remove occurrences of<DD><CODE>occurrences</CODE> - the number of occurrences of the element to remove. May 426 be zero, in which case no change will be made. 427 <DT><B>Returns:</B><DD>the count of the element before the operation; possibly zero 428 <DT><B>Throws:</B> 429 <DD><CODE><A HREF="http://java.sun.com/javase/6/docs/api/java/lang/IllegalArgumentException.html?is-external=true" title="class or interface in java.lang">IllegalArgumentException</A></CODE> - if <code>occurrences</code> is negative</DL> 430 </DD> 431 </DL> 432 <HR> 433 434 <A NAME="setCount(java.lang.Object,int)"><!-- --></A><A NAME="setCount(E, int)"><!-- --></A><H3> 435 setCount</H3> 436 <PRE> 437 int <B>setCount</B>(<A HREF="../../../../com/google/common/collect/Multiset.html" title="type parameter in Multiset">E</A> element, 438 int count)</PRE> 439 <DL> 440 <DD>Adds or removes the necessary occurrences of an element such that the 441 element attains the desired count. 442 <P> 443 <DD><DL> 444 </DL> 445 </DD> 446 <DD><DL> 447 <DT><B>Parameters:</B><DD><CODE>element</CODE> - the element to add or remove occurrences of; may be null 448 only if explicitly allowed by the implementation<DD><CODE>count</CODE> - the desired count of the element in this multiset 449 <DT><B>Returns:</B><DD>the count of the element before the operation; possibly zero 450 <DT><B>Throws:</B> 451 <DD><CODE><A HREF="http://java.sun.com/javase/6/docs/api/java/lang/IllegalArgumentException.html?is-external=true" title="class or interface in java.lang">IllegalArgumentException</A></CODE> - if <code>count</code> is negative 452 <DD><CODE><A HREF="http://java.sun.com/javase/6/docs/api/java/lang/NullPointerException.html?is-external=true" title="class or interface in java.lang">NullPointerException</A></CODE> - if <code>element</code> is null and this 453 implementation does not permit null elements. Note that if <code>count</code> is zero, the implementor may optionally return zero instead.</DL> 454 </DD> 455 </DL> 456 <HR> 457 458 <A NAME="setCount(java.lang.Object,int,int)"><!-- --></A><A NAME="setCount(E, int, int)"><!-- --></A><H3> 459 setCount</H3> 460 <PRE> 461 boolean <B>setCount</B>(<A HREF="../../../../com/google/common/collect/Multiset.html" title="type parameter in Multiset">E</A> element, 462 int oldCount, 463 int newCount)</PRE> 464 <DL> 465 <DD>Conditionally sets the count of an element to a new value, as described in 466 <A HREF="../../../../com/google/common/collect/Multiset.html#setCount(E, int)"><CODE>setCount(Object, int)</CODE></A>, provided that the element has the expected 467 current count. If the current count is not <code>oldCount</code>, no change is 468 made. 469 <P> 470 <DD><DL> 471 </DL> 472 </DD> 473 <DD><DL> 474 <DT><B>Parameters:</B><DD><CODE>element</CODE> - the element to conditionally set the count of; may be null 475 only if explicitly allowed by the implementation<DD><CODE>oldCount</CODE> - the expected present count of the element in this multiset<DD><CODE>newCount</CODE> - the desired count of the element in this multiset 476 <DT><B>Returns:</B><DD><code>true</code> if the condition for modification was met. This 477 implies that the multiset was indeed modified, unless 478 <code>oldCount == newCount</code>. 479 <DT><B>Throws:</B> 480 <DD><CODE><A HREF="http://java.sun.com/javase/6/docs/api/java/lang/IllegalArgumentException.html?is-external=true" title="class or interface in java.lang">IllegalArgumentException</A></CODE> - if <code>oldCount</code> or <code>newCount</code> is 481 negative 482 <DD><CODE><A HREF="http://java.sun.com/javase/6/docs/api/java/lang/NullPointerException.html?is-external=true" title="class or interface in java.lang">NullPointerException</A></CODE> - if <code>element</code> is null and the 483 implementation does not permit null elements. Note that if <code>oldCount</code> and <code>newCount</code> are both zero, the implementor may 484 optionally return <code>true</code> instead.</DL> 485 </DD> 486 </DL> 487 <HR> 488 489 <A NAME="elementSet()"><!-- --></A><H3> 490 elementSet</H3> 491 <PRE> 492 <A HREF="http://java.sun.com/javase/6/docs/api/java/util/Set.html?is-external=true" title="class or interface in java.util">Set</A><<A HREF="../../../../com/google/common/collect/Multiset.html" title="type parameter in Multiset">E</A>> <B>elementSet</B>()</PRE> 493 <DL> 494 <DD>Returns the set of distinct elements contained in this multiset. The 495 element set is backed by the same data as the multiset, so any change to 496 either is immediately reflected in the other. The order of the elements in 497 the element set is unspecified. 498 499 <p>If the element set supports any removal operations, these necessarily 500 cause <b>all</b> occurrences of the removed element(s) to be removed from 501 the multiset. Implementations are not expected to support the add 502 operations, although this is possible. 503 504 <p>A common use for the element set is to find the number of distinct 505 elements in the multiset: <code>elementSet().size()</code>. 506 <P> 507 <DD><DL> 508 </DL> 509 </DD> 510 <DD><DL> 511 512 <DT><B>Returns:</B><DD>a view of the set of distinct elements in this multiset</DL> 513 </DD> 514 </DL> 515 <HR> 516 517 <A NAME="entrySet()"><!-- --></A><H3> 518 entrySet</H3> 519 <PRE> 520 <A HREF="http://java.sun.com/javase/6/docs/api/java/util/Set.html?is-external=true" title="class or interface in java.util">Set</A><<A HREF="../../../../com/google/common/collect/Multiset.Entry.html" title="interface in com.google.common.collect">Multiset.Entry</A><<A HREF="../../../../com/google/common/collect/Multiset.html" title="type parameter in Multiset">E</A>>> <B>entrySet</B>()</PRE> 521 <DL> 522 <DD>Returns a view of the contents of this multiset, grouped into <code>Multiset.Entry</code> instances, each providing an element of the multiset and 523 the count of that element. This set contains exactly one entry for each 524 distinct element in the multiset (thus it always has the same size as the 525 <A HREF="../../../../com/google/common/collect/Multiset.html#elementSet()"><CODE>elementSet()</CODE></A>). The order of the elements in the element set is 526 unspecified. 527 528 <p>The entry set is backed by the same data as the multiset, so any change 529 to either is immediately reflected in the other. However, multiset changes 530 may or may not be reflected in any <code>Entry</code> instances already 531 retrieved from the entry set (this is implementation-dependent). 532 Furthermore, implementations are not required to support modifications to 533 the entry set at all, and the <code>Entry</code> instances themselves don't 534 even have methods for modification. See the specific implementation class 535 for more details on how its entry set handles modifications. 536 <P> 537 <DD><DL> 538 </DL> 539 </DD> 540 <DD><DL> 541 542 <DT><B>Returns:</B><DD>a set of entries representing the data of this multiset</DL> 543 </DD> 544 </DL> 545 <HR> 546 547 <A NAME="equals(java.lang.Object)"><!-- --></A><H3> 548 equals</H3> 549 <PRE> 550 boolean <B>equals</B>(<FONT SIZE="-1"><A HREF="http://jsr-305.googlecode.com/svn/trunk/javadoc/javax/annotation/Nullable.html?is-external=true" title="class or interface in javax.annotation">@Nullable</A></FONT> 551 <A HREF="http://java.sun.com/javase/6/docs/api/java/lang/Object.html?is-external=true" title="class or interface in java.lang">Object</A> object)</PRE> 552 <DL> 553 <DD>Compares the specified object with this multiset for equality. Returns 554 <code>true</code> if the given object is also a multiset and contains equal 555 elements with equal counts, regardless of order. 556 <P> 557 <DD><DL> 558 <DT><B>Specified by:</B><DD><CODE><A HREF="http://java.sun.com/javase/6/docs/api/java/util/Collection.html?is-external=true#equals(java.lang.Object)" title="class or interface in java.util">equals</A></CODE> in interface <CODE><A HREF="http://java.sun.com/javase/6/docs/api/java/util/Collection.html?is-external=true" title="class or interface in java.util">Collection</A><<A HREF="../../../../com/google/common/collect/Multiset.html" title="type parameter in Multiset">E</A>></CODE><DT><B>Overrides:</B><DD><CODE><A HREF="http://java.sun.com/javase/6/docs/api/java/lang/Object.html?is-external=true#equals(java.lang.Object)" title="class or interface in java.lang">equals</A></CODE> in class <CODE><A HREF="http://java.sun.com/javase/6/docs/api/java/lang/Object.html?is-external=true" title="class or interface in java.lang">Object</A></CODE></DL> 559 </DD> 560 <DD><DL> 561 </DL> 562 </DD> 563 </DL> 564 <HR> 565 566 <A NAME="hashCode()"><!-- --></A><H3> 567 hashCode</H3> 568 <PRE> 569 int <B>hashCode</B>()</PRE> 570 <DL> 571 <DD>Returns the hash code for this multiset. This is defined as the sum of 572 573 <pre> (element == null ? 0 : element.hashCode()) ^ count(element)</pre> 574 575 over all distinct elements in the multiset. It follows that a multiset and 576 its entry set always have the same hash code. 577 <P> 578 <DD><DL> 579 <DT><B>Specified by:</B><DD><CODE><A HREF="http://java.sun.com/javase/6/docs/api/java/util/Collection.html?is-external=true#hashCode()" title="class or interface in java.util">hashCode</A></CODE> in interface <CODE><A HREF="http://java.sun.com/javase/6/docs/api/java/util/Collection.html?is-external=true" title="class or interface in java.util">Collection</A><<A HREF="../../../../com/google/common/collect/Multiset.html" title="type parameter in Multiset">E</A>></CODE><DT><B>Overrides:</B><DD><CODE><A HREF="http://java.sun.com/javase/6/docs/api/java/lang/Object.html?is-external=true#hashCode()" title="class or interface in java.lang">hashCode</A></CODE> in class <CODE><A HREF="http://java.sun.com/javase/6/docs/api/java/lang/Object.html?is-external=true" title="class or interface in java.lang">Object</A></CODE></DL> 580 </DD> 581 <DD><DL> 582 </DL> 583 </DD> 584 </DL> 585 <HR> 586 587 <A NAME="toString()"><!-- --></A><H3> 588 toString</H3> 589 <PRE> 590 <A HREF="http://java.sun.com/javase/6/docs/api/java/lang/String.html?is-external=true" title="class or interface in java.lang">String</A> <B>toString</B>()</PRE> 591 <DL> 592 <DD> 593 594 <p>It is recommended, though not mandatory, that this method return the 595 result of invoking <A HREF="../../../../com/google/common/collect/Multiset.html#toString()"><CODE>toString()</CODE></A> on the <A HREF="../../../../com/google/common/collect/Multiset.html#entrySet()"><CODE>entrySet()</CODE></A>, yielding a 596 result such as 597 <pre> 598 [a x 3, c, d x 2, e] 599 </pre> 600 <P> 601 <DD><DL> 602 <DT><B>Overrides:</B><DD><CODE><A HREF="http://java.sun.com/javase/6/docs/api/java/lang/Object.html?is-external=true#toString()" title="class or interface in java.lang">toString</A></CODE> in class <CODE><A HREF="http://java.sun.com/javase/6/docs/api/java/lang/Object.html?is-external=true" title="class or interface in java.lang">Object</A></CODE></DL> 603 </DD> 604 <DD><DL> 605 </DL> 606 </DD> 607 </DL> 608 <HR> 609 610 <A NAME="iterator()"><!-- --></A><H3> 611 iterator</H3> 612 <PRE> 613 <A HREF="http://java.sun.com/javase/6/docs/api/java/util/Iterator.html?is-external=true" title="class or interface in java.util">Iterator</A><<A HREF="../../../../com/google/common/collect/Multiset.html" title="type parameter in Multiset">E</A>> <B>iterator</B>()</PRE> 614 <DL> 615 <DD> 616 617 <p>Elements that occur multiple times in the multiset will appear 618 multiple times in this iterator, though not necessarily sequentially. 619 <P> 620 <DD><DL> 621 <DT><B>Specified by:</B><DD><CODE><A HREF="http://java.sun.com/javase/6/docs/api/java/util/Collection.html?is-external=true#iterator()" title="class or interface in java.util">iterator</A></CODE> in interface <CODE><A HREF="http://java.sun.com/javase/6/docs/api/java/util/Collection.html?is-external=true" title="class or interface in java.util">Collection</A><<A HREF="../../../../com/google/common/collect/Multiset.html" title="type parameter in Multiset">E</A>></CODE><DT><B>Specified by:</B><DD><CODE><A HREF="http://java.sun.com/javase/6/docs/api/java/lang/Iterable.html?is-external=true#iterator()" title="class or interface in java.lang">iterator</A></CODE> in interface <CODE><A HREF="http://java.sun.com/javase/6/docs/api/java/lang/Iterable.html?is-external=true" title="class or interface in java.lang">Iterable</A><<A HREF="../../../../com/google/common/collect/Multiset.html" title="type parameter in Multiset">E</A>></CODE></DL> 622 </DD> 623 <DD><DL> 624 </DL> 625 </DD> 626 </DL> 627 <HR> 628 629 <A NAME="contains(java.lang.Object)"><!-- --></A><H3> 630 contains</H3> 631 <PRE> 632 boolean <B>contains</B>(<FONT SIZE="-1"><A HREF="http://jsr-305.googlecode.com/svn/trunk/javadoc/javax/annotation/Nullable.html?is-external=true" title="class or interface in javax.annotation">@Nullable</A></FONT> 633 <A HREF="http://java.sun.com/javase/6/docs/api/java/lang/Object.html?is-external=true" title="class or interface in java.lang">Object</A> element)</PRE> 634 <DL> 635 <DD>Determines whether this multiset contains the specified element. 636 637 <p>This method refines <A HREF="http://java.sun.com/javase/6/docs/api/java/util/Collection.html?is-external=true#contains(java.lang.Object)" title="class or interface in java.util"><CODE>Collection.contains(java.lang.Object)</CODE></A> to further specify that 638 it <b>may not</b> throw an exception in response to <code>element</code> being 639 null or of the wrong type. 640 <P> 641 <DD><DL> 642 <DT><B>Specified by:</B><DD><CODE><A HREF="http://java.sun.com/javase/6/docs/api/java/util/Collection.html?is-external=true#contains(java.lang.Object)" title="class or interface in java.util">contains</A></CODE> in interface <CODE><A HREF="http://java.sun.com/javase/6/docs/api/java/util/Collection.html?is-external=true" title="class or interface in java.util">Collection</A><<A HREF="../../../../com/google/common/collect/Multiset.html" title="type parameter in Multiset">E</A>></CODE></DL> 643 </DD> 644 <DD><DL> 645 <DT><B>Parameters:</B><DD><CODE>element</CODE> - the element to check for 646 <DT><B>Returns:</B><DD><code>true</code> if this multiset contains at least one occurrence of 647 the element</DL> 648 </DD> 649 </DL> 650 <HR> 651 652 <A NAME="containsAll(java.util.Collection)"><!-- --></A><H3> 653 containsAll</H3> 654 <PRE> 655 boolean <B>containsAll</B>(<A HREF="http://java.sun.com/javase/6/docs/api/java/util/Collection.html?is-external=true" title="class or interface in java.util">Collection</A><?> elements)</PRE> 656 <DL> 657 <DD>Returns <code>true</code> if this multiset contains at least one occurrence of 658 each element in the specified collection. 659 660 <p>This method refines <A HREF="http://java.sun.com/javase/6/docs/api/java/util/Collection.html?is-external=true#containsAll(java.util.Collection)" title="class or interface in java.util"><CODE>Collection.containsAll(java.util.Collection<?>)</CODE></A> to further specify 661 that it <b>may not</b> throw an exception in response to any of <code>elements</code> being null or of the wrong type. 662 663 <p><b>Note:</b> this method does not take into account the occurrence 664 count of an element in the two collections; it may still return <code>true</code> even if <code>elements</code> contains several occurrences of an element 665 and this multiset contains only one. This is no different than any other 666 collection type like <A HREF="http://java.sun.com/javase/6/docs/api/java/util/List.html?is-external=true" title="class or interface in java.util"><CODE>List</CODE></A>, but it may be unexpected to the user of 667 a multiset. 668 <P> 669 <DD><DL> 670 <DT><B>Specified by:</B><DD><CODE><A HREF="http://java.sun.com/javase/6/docs/api/java/util/Collection.html?is-external=true#containsAll(java.util.Collection)" title="class or interface in java.util">containsAll</A></CODE> in interface <CODE><A HREF="http://java.sun.com/javase/6/docs/api/java/util/Collection.html?is-external=true" title="class or interface in java.util">Collection</A><<A HREF="../../../../com/google/common/collect/Multiset.html" title="type parameter in Multiset">E</A>></CODE></DL> 671 </DD> 672 <DD><DL> 673 <DT><B>Parameters:</B><DD><CODE>elements</CODE> - the collection of elements to be checked for containment in 674 this multiset 675 <DT><B>Returns:</B><DD><code>true</code> if this multiset contains at least one occurrence of 676 each element contained in <code>elements</code> 677 <DT><B>Throws:</B> 678 <DD><CODE><A HREF="http://java.sun.com/javase/6/docs/api/java/lang/NullPointerException.html?is-external=true" title="class or interface in java.lang">NullPointerException</A></CODE> - if <code>elements</code> is null</DL> 679 </DD> 680 </DL> 681 <HR> 682 683 <A NAME="add(java.lang.Object)"><!-- --></A><A NAME="add(E)"><!-- --></A><H3> 684 add</H3> 685 <PRE> 686 boolean <B>add</B>(<A HREF="../../../../com/google/common/collect/Multiset.html" title="type parameter in Multiset">E</A> element)</PRE> 687 <DL> 688 <DD>Adds a single occurrence of the specified element to this multiset. 689 690 <p>This method refines <A HREF="http://java.sun.com/javase/6/docs/api/java/util/Collection.html?is-external=true#add(E)" title="class or interface in java.util"><CODE>Collection.add(E)</CODE></A>, which only <i>ensures</i> 691 the presence of the element, to further specify that a successful call must 692 always increment the count of the element, and the overall size of the 693 collection, by one. 694 <P> 695 <DD><DL> 696 <DT><B>Specified by:</B><DD><CODE><A HREF="http://java.sun.com/javase/6/docs/api/java/util/Collection.html?is-external=true#add(E)" title="class or interface in java.util">add</A></CODE> in interface <CODE><A HREF="http://java.sun.com/javase/6/docs/api/java/util/Collection.html?is-external=true" title="class or interface in java.util">Collection</A><<A HREF="../../../../com/google/common/collect/Multiset.html" title="type parameter in Multiset">E</A>></CODE></DL> 697 </DD> 698 <DD><DL> 699 <DT><B>Parameters:</B><DD><CODE>element</CODE> - the element to add one occurrence of; may be null only if 700 explicitly allowed by the implementation 701 <DT><B>Returns:</B><DD><code>true</code> always, since this call is required to modify the 702 multiset, unlike other <A HREF="http://java.sun.com/javase/6/docs/api/java/util/Collection.html?is-external=true" title="class or interface in java.util"><CODE>Collection</CODE></A> types 703 <DT><B>Throws:</B> 704 <DD><CODE><A HREF="http://java.sun.com/javase/6/docs/api/java/lang/NullPointerException.html?is-external=true" title="class or interface in java.lang">NullPointerException</A></CODE> - if <code>element</code> is null and this 705 implementation does not permit null elements 706 <DD><CODE><A HREF="http://java.sun.com/javase/6/docs/api/java/lang/IllegalArgumentException.html?is-external=true" title="class or interface in java.lang">IllegalArgumentException</A></CODE> - if <A HREF="http://java.sun.com/javase/6/docs/api/java/lang/Integer.html?is-external=true#MAX_VALUE" title="class or interface in java.lang"><CODE>Integer.MAX_VALUE</CODE></A> occurrences 707 of <code>element</code> are already contained in this multiset</DL> 708 </DD> 709 </DL> 710 <HR> 711 712 <A NAME="remove(java.lang.Object)"><!-- --></A><H3> 713 remove</H3> 714 <PRE> 715 boolean <B>remove</B>(<FONT SIZE="-1"><A HREF="http://jsr-305.googlecode.com/svn/trunk/javadoc/javax/annotation/Nullable.html?is-external=true" title="class or interface in javax.annotation">@Nullable</A></FONT> 716 <A HREF="http://java.sun.com/javase/6/docs/api/java/lang/Object.html?is-external=true" title="class or interface in java.lang">Object</A> element)</PRE> 717 <DL> 718 <DD>Removes a <i>single</i> occurrence of the specified element from this 719 multiset, if present. 720 721 <p>This method refines <A HREF="http://java.sun.com/javase/6/docs/api/java/util/Collection.html?is-external=true#remove(java.lang.Object)" title="class or interface in java.util"><CODE>Collection.remove(java.lang.Object)</CODE></A> to further specify that it 722 <b>may not</b> throw an exception in response to <code>element</code> being null 723 or of the wrong type. 724 <P> 725 <DD><DL> 726 <DT><B>Specified by:</B><DD><CODE><A HREF="http://java.sun.com/javase/6/docs/api/java/util/Collection.html?is-external=true#remove(java.lang.Object)" title="class or interface in java.util">remove</A></CODE> in interface <CODE><A HREF="http://java.sun.com/javase/6/docs/api/java/util/Collection.html?is-external=true" title="class or interface in java.util">Collection</A><<A HREF="../../../../com/google/common/collect/Multiset.html" title="type parameter in Multiset">E</A>></CODE></DL> 727 </DD> 728 <DD><DL> 729 <DT><B>Parameters:</B><DD><CODE>element</CODE> - the element to remove one occurrence of 730 <DT><B>Returns:</B><DD><code>true</code> if an occurrence was found and removed</DL> 731 </DD> 732 </DL> 733 <HR> 734 735 <A NAME="removeAll(java.util.Collection)"><!-- --></A><H3> 736 removeAll</H3> 737 <PRE> 738 boolean <B>removeAll</B>(<A HREF="http://java.sun.com/javase/6/docs/api/java/util/Collection.html?is-external=true" title="class or interface in java.util">Collection</A><?> c)</PRE> 739 <DL> 740 <DD> 741 742 <p>This method refines <A HREF="http://java.sun.com/javase/6/docs/api/java/util/Collection.html?is-external=true#removeAll(java.util.Collection)" title="class or interface in java.util"><CODE>Collection.removeAll(java.util.Collection<?>)</CODE></A> to further specify that 743 it <b>may not</b> throw an exception in response to any of <code>elements</code> 744 being null or of the wrong type. 745 <P> 746 <DD><DL> 747 <DT><B>Specified by:</B><DD><CODE><A HREF="http://java.sun.com/javase/6/docs/api/java/util/Collection.html?is-external=true#removeAll(java.util.Collection)" title="class or interface in java.util">removeAll</A></CODE> in interface <CODE><A HREF="http://java.sun.com/javase/6/docs/api/java/util/Collection.html?is-external=true" title="class or interface in java.util">Collection</A><<A HREF="../../../../com/google/common/collect/Multiset.html" title="type parameter in Multiset">E</A>></CODE></DL> 748 </DD> 749 <DD><DL> 750 </DL> 751 </DD> 752 </DL> 753 <HR> 754 755 <A NAME="retainAll(java.util.Collection)"><!-- --></A><H3> 756 retainAll</H3> 757 <PRE> 758 boolean <B>retainAll</B>(<A HREF="http://java.sun.com/javase/6/docs/api/java/util/Collection.html?is-external=true" title="class or interface in java.util">Collection</A><?> c)</PRE> 759 <DL> 760 <DD> 761 762 <p>This method refines <A HREF="http://java.sun.com/javase/6/docs/api/java/util/Collection.html?is-external=true#retainAll(java.util.Collection)" title="class or interface in java.util"><CODE>Collection.retainAll(java.util.Collection<?>)</CODE></A> to further specify that 763 it <b>may not</b> throw an exception in response to any of <code>elements</code> 764 being null or of the wrong type. 765 <P> 766 <DD><DL> 767 <DT><B>Specified by:</B><DD><CODE><A HREF="http://java.sun.com/javase/6/docs/api/java/util/Collection.html?is-external=true#retainAll(java.util.Collection)" title="class or interface in java.util">retainAll</A></CODE> in interface <CODE><A HREF="http://java.sun.com/javase/6/docs/api/java/util/Collection.html?is-external=true" title="class or interface in java.util">Collection</A><<A HREF="../../../../com/google/common/collect/Multiset.html" title="type parameter in Multiset">E</A>></CODE></DL> 768 </DD> 769 <DD><DL> 770 </DL> 771 </DD> 772 </DL> 773 <!-- ========= END OF CLASS DATA ========= --> 774 <HR> 775 776 777 <!-- ======= START OF BOTTOM NAVBAR ====== --> 778 <A NAME="navbar_bottom"><!-- --></A> 779 <A HREF="#skip-navbar_bottom" title="Skip navigation links"></A> 780 <TABLE BORDER="0" WIDTH="100%" CELLPADDING="1" CELLSPACING="0" SUMMARY=""> 781 <TR> 782 <TD COLSPAN=2 BGCOLOR="#EEEEFF" CLASS="NavBarCell1"> 783 <A NAME="navbar_bottom_firstrow"><!-- --></A> 784 <TABLE BORDER="0" CELLPADDING="0" CELLSPACING="3" SUMMARY=""> 785 <TR ALIGN="center" VALIGN="top"> 786 <TD BGCOLOR="#EEEEFF" CLASS="NavBarCell1"> <A HREF="../../../../overview-summary.html"><FONT CLASS="NavBarFont1"><B>Overview</B></FONT></A> </TD> 787 <TD BGCOLOR="#EEEEFF" CLASS="NavBarCell1"> <A HREF="package-summary.html"><FONT CLASS="NavBarFont1"><B>Package</B></FONT></A> </TD> 788 <TD BGCOLOR="#FFFFFF" CLASS="NavBarCell1Rev"> <FONT CLASS="NavBarFont1Rev"><B>Class</B></FONT> </TD> 789 <TD BGCOLOR="#EEEEFF" CLASS="NavBarCell1"> <A HREF="class-use/Multiset.html"><FONT CLASS="NavBarFont1"><B>Use</B></FONT></A> </TD> 790 <TD BGCOLOR="#EEEEFF" CLASS="NavBarCell1"> <A HREF="package-tree.html"><FONT CLASS="NavBarFont1"><B>Tree</B></FONT></A> </TD> 791 <TD BGCOLOR="#EEEEFF" CLASS="NavBarCell1"> <A HREF="../../../../deprecated-list.html"><FONT CLASS="NavBarFont1"><B>Deprecated</B></FONT></A> </TD> 792 <TD BGCOLOR="#EEEEFF" CLASS="NavBarCell1"> <A HREF="../../../../index-all.html"><FONT CLASS="NavBarFont1"><B>Index</B></FONT></A> </TD> 793 <TD BGCOLOR="#EEEEFF" CLASS="NavBarCell1"> <A HREF="../../../../help-doc.html"><FONT CLASS="NavBarFont1"><B>Help</B></FONT></A> </TD> 794 </TR> 795 </TABLE> 796 </TD> 797 <TD ALIGN="right" VALIGN="top" ROWSPAN=3><EM> 798 </EM> 799 </TD> 800 </TR> 801 802 <TR> 803 <TD BGCOLOR="white" CLASS="NavBarCell2"><FONT SIZE="-2"> 804 <A HREF="../../../../com/google/common/collect/Multimaps.html" title="class in com.google.common.collect"><B>PREV CLASS</B></A> 805 <A HREF="../../../../com/google/common/collect/Multiset.Entry.html" title="interface in com.google.common.collect"><B>NEXT CLASS</B></A></FONT></TD> 806 <TD BGCOLOR="white" CLASS="NavBarCell2"><FONT SIZE="-2"> 807 <A HREF="../../../../index.html?com/google/common/collect/Multiset.html" target="_top"><B>FRAMES</B></A> 808 <A HREF="Multiset.html" target="_top"><B>NO FRAMES</B></A> 809 <SCRIPT type="text/javascript"> 810 <!-- 811 if(window==top) { 812 document.writeln('<A HREF="../../../../allclasses-noframe.html"><B>All Classes</B></A>'); 813 } 814 //--> 815 </SCRIPT> 816 <NOSCRIPT> 817 <A HREF="../../../../allclasses-noframe.html"><B>All Classes</B></A> 818 </NOSCRIPT> 819 820 821 </FONT></TD> 822 </TR> 823 <TR> 824 <TD VALIGN="top" CLASS="NavBarCell3"><FONT SIZE="-2"> 825 SUMMARY: <A HREF="#nested_class_summary">NESTED</A> | FIELD | CONSTR | <A HREF="#method_summary">METHOD</A></FONT></TD> 826 <TD VALIGN="top" CLASS="NavBarCell3"><FONT SIZE="-2"> 827 DETAIL: FIELD | CONSTR | <A HREF="#method_detail">METHOD</A></FONT></TD> 828 </TR> 829 </TABLE> 830 <A NAME="skip-navbar_bottom"></A> 831 <!-- ======== END OF BOTTOM NAVBAR ======= --> 832 833 <HR> 834 835 </BODY> 836 </HTML> 837