1 <!DOCTYPE HTML PUBLIC
"-//W3C//DTD HTML 4.01 Transitional//EN" "http://www.w3.org/TR/html4/loose.dtd">
5 <!-- Generated by javadoc (build 1.5.0_07) on Fri Apr 11 15:39:16 BST 2008 -->
6 <META http-equiv=
"Content-Type" content=
"text/html; charset=ISO-8859-1">
8 Bag (Commons Collections
3.2.1 API)
11 <META NAME=
"keywords" CONTENT=
"org.apache.commons.collections.Bag interface">
13 <LINK REL =
"stylesheet" TYPE=
"text/css" HREF=
"../../../../stylesheet.css" TITLE=
"Style">
15 <SCRIPT type=
"text/javascript">
16 function windowTitle()
18 parent.document.
title=
"Bag (Commons Collections 3.2.1 API)";
26 <BODY BGCOLOR=
"white" onload=
"windowTitle();">
29 <!-- ========= START OF TOP NAVBAR ======= -->
30 <A NAME=
"navbar_top"><!-- --></A>
31 <A HREF=
"#skip-navbar_top" title=
"Skip navigation links"></A>
32 <TABLE BORDER=
"0" WIDTH=
"100%" CELLPADDING=
"1" CELLSPACING=
"0" SUMMARY=
"">
34 <TD COLSPAN=
2 BGCOLOR=
"#EEEEFF" CLASS=
"NavBarCell1">
35 <A NAME=
"navbar_top_firstrow"><!-- --></A>
36 <TABLE BORDER=
"0" CELLPADDING=
"0" CELLSPACING=
"3" SUMMARY=
"">
37 <TR ALIGN=
"center" VALIGN=
"top">
38 <TD BGCOLOR=
"#EEEEFF" CLASS=
"NavBarCell1"> <A HREF=
"../../../../overview-summary.html"><FONT CLASS=
"NavBarFont1"><B>Overview
</B></FONT></A> </TD>
39 <TD BGCOLOR=
"#EEEEFF" CLASS=
"NavBarCell1"> <A HREF=
"package-summary.html"><FONT CLASS=
"NavBarFont1"><B>Package
</B></FONT></A> </TD>
40 <TD BGCOLOR=
"#FFFFFF" CLASS=
"NavBarCell1Rev"> <FONT CLASS=
"NavBarFont1Rev"><B>Class
</B></FONT> </TD>
41 <TD BGCOLOR=
"#EEEEFF" CLASS=
"NavBarCell1"> <A HREF=
"class-use/Bag.html"><FONT CLASS=
"NavBarFont1"><B>Use
</B></FONT></A> </TD>
42 <TD BGCOLOR=
"#EEEEFF" CLASS=
"NavBarCell1"> <A HREF=
"package-tree.html"><FONT CLASS=
"NavBarFont1"><B>Tree
</B></FONT></A> </TD>
43 <TD BGCOLOR=
"#EEEEFF" CLASS=
"NavBarCell1"> <A HREF=
"../../../../deprecated-list.html"><FONT CLASS=
"NavBarFont1"><B>Deprecated
</B></FONT></A> </TD>
44 <TD BGCOLOR=
"#EEEEFF" CLASS=
"NavBarCell1"> <A HREF=
"../../../../index-all.html"><FONT CLASS=
"NavBarFont1"><B>Index
</B></FONT></A> </TD>
45 <TD BGCOLOR=
"#EEEEFF" CLASS=
"NavBarCell1"> <A HREF=
"../../../../help-doc.html"><FONT CLASS=
"NavBarFont1"><B>Help
</B></FONT></A> </TD>
49 <TD ALIGN=
"right" VALIGN=
"top" ROWSPAN=
3><EM>
55 <TD BGCOLOR=
"white" CLASS=
"NavBarCell2"><FONT SIZE=
"-2">
56 <A HREF=
"../../../../org/apache/commons/collections/ArrayStack.html" title=
"class in org.apache.commons.collections"><B>PREV CLASS
</B></A>
57 <A HREF=
"../../../../org/apache/commons/collections/BagUtils.html" title=
"class in org.apache.commons.collections"><B>NEXT CLASS
</B></A></FONT></TD>
58 <TD BGCOLOR=
"white" CLASS=
"NavBarCell2"><FONT SIZE=
"-2">
59 <A HREF=
"../../../../index.html?org/apache/commons/collections/Bag.html" target=
"_top"><B>FRAMES
</B></A>
60 <A HREF=
"Bag.html" target=
"_top"><B>NO FRAMES
</B></A>
61 <SCRIPT type=
"text/javascript">
64 document.writeln('<A HREF="../../../../allclasses-noframe.html"><B>All Classes</B></A>');
69 <A HREF=
"../../../../allclasses-noframe.html"><B>All Classes
</B></A>
76 <TD VALIGN=
"top" CLASS=
"NavBarCell3"><FONT SIZE=
"-2">
77 SUMMARY:
NESTED
|
FIELD
|
CONSTR
|
<A HREF=
"#method_summary">METHOD
</A></FONT></TD>
78 <TD VALIGN=
"top" CLASS=
"NavBarCell3"><FONT SIZE=
"-2">
79 DETAIL:
FIELD
|
CONSTR
|
<A HREF=
"#method_detail">METHOD
</A></FONT></TD>
82 <A NAME=
"skip-navbar_top"></A>
83 <!-- ========= END OF TOP NAVBAR ========= -->
86 <!-- ======== START OF CLASS DATA ======== -->
89 org.apache.commons.collections
</FONT>
93 <DT><B>All Superinterfaces:
</B> <DD>java.util.Collection, java.lang.Iterable
</DD>
96 <DT><B>All Known Subinterfaces:
</B> <DD><A HREF=
"../../../../org/apache/commons/collections/SortedBag.html" title=
"interface in org.apache.commons.collections">SortedBag
</A></DD>
99 <DT><B>All Known Implementing Classes:
</B> <DD><A HREF=
"../../../../org/apache/commons/collections/bag/AbstractBagDecorator.html" title=
"class in org.apache.commons.collections.bag">AbstractBagDecorator
</A>,
<A HREF=
"../../../../org/apache/commons/collections/bag/AbstractMapBag.html" title=
"class in org.apache.commons.collections.bag">AbstractMapBag
</A>,
<A HREF=
"../../../../org/apache/commons/collections/bag/AbstractSortedBagDecorator.html" title=
"class in org.apache.commons.collections.bag">AbstractSortedBagDecorator
</A>,
<A HREF=
"../../../../org/apache/commons/collections/DefaultMapBag.html" title=
"class in org.apache.commons.collections">DefaultMapBag
</A>,
<A HREF=
"../../../../org/apache/commons/collections/HashBag.html" title=
"class in org.apache.commons.collections">HashBag
</A>,
<A HREF=
"../../../../org/apache/commons/collections/bag/HashBag.html" title=
"class in org.apache.commons.collections.bag">HashBag
</A>,
<A HREF=
"../../../../org/apache/commons/collections/bag/PredicatedBag.html" title=
"class in org.apache.commons.collections.bag">PredicatedBag
</A>,
<A HREF=
"../../../../org/apache/commons/collections/bag/PredicatedSortedBag.html" title=
"class in org.apache.commons.collections.bag">PredicatedSortedBag
</A>,
<A HREF=
"../../../../org/apache/commons/collections/bag/SynchronizedBag.html" title=
"class in org.apache.commons.collections.bag">SynchronizedBag
</A>,
<A HREF=
"../../../../org/apache/commons/collections/bag/SynchronizedSortedBag.html" title=
"class in org.apache.commons.collections.bag">SynchronizedSortedBag
</A>,
<A HREF=
"../../../../org/apache/commons/collections/bag/TransformedBag.html" title=
"class in org.apache.commons.collections.bag">TransformedBag
</A>,
<A HREF=
"../../../../org/apache/commons/collections/bag/TransformedSortedBag.html" title=
"class in org.apache.commons.collections.bag">TransformedSortedBag
</A>,
<A HREF=
"../../../../org/apache/commons/collections/TreeBag.html" title=
"class in org.apache.commons.collections">TreeBag
</A>,
<A HREF=
"../../../../org/apache/commons/collections/bag/TreeBag.html" title=
"class in org.apache.commons.collections.bag">TreeBag
</A>,
<A HREF=
"../../../../org/apache/commons/collections/bag/UnmodifiableBag.html" title=
"class in org.apache.commons.collections.bag">UnmodifiableBag
</A>,
<A HREF=
"../../../../org/apache/commons/collections/bag/UnmodifiableSortedBag.html" title=
"class in org.apache.commons.collections.bag">UnmodifiableSortedBag
</A></DD>
103 <DT><PRE>public interface
<B>Bag
</B><DT>extends java.util.Collection
</DL>
107 Defines a collection that counts the number of times an object appears in
110 Suppose you have a Bag that contains
<code>{a, a, b, c}
</code>.
111 Calling
<A HREF=
"../../../../org/apache/commons/collections/Bag.html#getCount(java.lang.Object)"><CODE>getCount(Object)
</CODE></A> on
<code>a
</code> would return
2, while
112 calling
<A HREF=
"../../../../org/apache/commons/collections/Bag.html#uniqueSet()"><CODE>uniqueSet()
</CODE></A> would return
<code>{a, b, c}
</code>.
114 <i>NOTE: This interface violates the
<CODE>Collection
</CODE> contract.
</i>
115 The behavior specified in many of these methods is
<i>not
</i> the same
116 as the behavior specified by
<code>Collection
</code>.
117 The noncompliant methods are clearly marked with
"(Violation)".
118 Exercise caution when using a bag as a
<code>Collection
</code>.
120 This violation resulted from the original specification of this interface.
121 In an ideal world, the interface would be changed to fix the problems, however
122 it has been decided to maintain backwards compatibility instead.
127 <DT><B>Since:
</B></DT>
128 <DD>Commons Collections
2.0</DD>
129 <DT><B>Version:
</B></DT>
130 <DD>$Revision:
646777 $ $Date:
2008-
04-
10 13:
33:
15 +
0100 (Thu,
10 Apr
2008) $
</DD>
131 <DT><B>Author:
</B></DT>
132 <DD>Chuck Burdick, Stephen Colebourne
</DD>
138 <!-- ========== METHOD SUMMARY =========== -->
140 <A NAME=
"method_summary"><!-- --></A>
141 <TABLE BORDER=
"1" WIDTH=
"100%" CELLPADDING=
"3" CELLSPACING=
"0" SUMMARY=
"">
142 <TR BGCOLOR=
"#CCCCFF" CLASS=
"TableHeadingColor">
143 <TH ALIGN=
"left" COLSPAN=
"2"><FONT SIZE=
"+2">
144 <B>Method Summary
</B></FONT></TH>
146 <TR BGCOLOR=
"white" CLASS=
"TableRowColor">
147 <TD ALIGN=
"right" VALIGN=
"top" WIDTH=
"1%"><FONT SIZE=
"-1">
148 <CODE> boolean
</CODE></FONT></TD>
149 <TD><CODE><B><A HREF=
"../../../../org/apache/commons/collections/Bag.html#add(java.lang.Object)">add
</A></B>(java.lang.Object
object)
</CODE>
152 <i>(Violation)
</i>
153 Adds one copy the specified object to the Bag.
</TD>
155 <TR BGCOLOR=
"white" CLASS=
"TableRowColor">
156 <TD ALIGN=
"right" VALIGN=
"top" WIDTH=
"1%"><FONT SIZE=
"-1">
157 <CODE> boolean
</CODE></FONT></TD>
158 <TD><CODE><B><A HREF=
"../../../../org/apache/commons/collections/Bag.html#add(java.lang.Object, int)">add
</A></B>(java.lang.Object
object,
159 int
nCopies)
</CODE>
162 Adds
<code>nCopies
</code> copies of the specified object to the Bag.
</TD>
164 <TR BGCOLOR=
"white" CLASS=
"TableRowColor">
165 <TD ALIGN=
"right" VALIGN=
"top" WIDTH=
"1%"><FONT SIZE=
"-1">
166 <CODE> boolean
</CODE></FONT></TD>
167 <TD><CODE><B><A HREF=
"../../../../org/apache/commons/collections/Bag.html#containsAll(java.util.Collection)">containsAll
</A></B>(java.util.Collection
coll)
</CODE>
170 <i>(Violation)
</i>
171 Returns
<code>true
</code> if the bag contains all elements in
172 the given collection, respecting cardinality.
</TD>
174 <TR BGCOLOR=
"white" CLASS=
"TableRowColor">
175 <TD ALIGN=
"right" VALIGN=
"top" WIDTH=
"1%"><FONT SIZE=
"-1">
176 <CODE> int
</CODE></FONT></TD>
177 <TD><CODE><B><A HREF=
"../../../../org/apache/commons/collections/Bag.html#getCount(java.lang.Object)">getCount
</A></B>(java.lang.Object
object)
</CODE>
180 Returns the number of occurrences (cardinality) of the given
181 object currently in the bag.
</TD>
183 <TR BGCOLOR=
"white" CLASS=
"TableRowColor">
184 <TD ALIGN=
"right" VALIGN=
"top" WIDTH=
"1%"><FONT SIZE=
"-1">
185 <CODE> java.util.Iterator
</CODE></FONT></TD>
186 <TD><CODE><B><A HREF=
"../../../../org/apache/commons/collections/Bag.html#iterator()">iterator
</A></B>()
</CODE>
189 Returns an
<CODE>Iterator
</CODE> over the entire set of members,
190 including copies due to cardinality.
</TD>
192 <TR BGCOLOR=
"white" CLASS=
"TableRowColor">
193 <TD ALIGN=
"right" VALIGN=
"top" WIDTH=
"1%"><FONT SIZE=
"-1">
194 <CODE> boolean
</CODE></FONT></TD>
195 <TD><CODE><B><A HREF=
"../../../../org/apache/commons/collections/Bag.html#remove(java.lang.Object)">remove
</A></B>(java.lang.Object
object)
</CODE>
198 <i>(Violation)
</i>
199 Removes all occurrences of the given object from the bag.
</TD>
201 <TR BGCOLOR=
"white" CLASS=
"TableRowColor">
202 <TD ALIGN=
"right" VALIGN=
"top" WIDTH=
"1%"><FONT SIZE=
"-1">
203 <CODE> boolean
</CODE></FONT></TD>
204 <TD><CODE><B><A HREF=
"../../../../org/apache/commons/collections/Bag.html#remove(java.lang.Object, int)">remove
</A></B>(java.lang.Object
object,
205 int
nCopies)
</CODE>
208 Removes
<code>nCopies
</code> copies of the specified object from the Bag.
</TD>
210 <TR BGCOLOR=
"white" CLASS=
"TableRowColor">
211 <TD ALIGN=
"right" VALIGN=
"top" WIDTH=
"1%"><FONT SIZE=
"-1">
212 <CODE> boolean
</CODE></FONT></TD>
213 <TD><CODE><B><A HREF=
"../../../../org/apache/commons/collections/Bag.html#removeAll(java.util.Collection)">removeAll
</A></B>(java.util.Collection
coll)
</CODE>
216 <i>(Violation)
</i>
217 Remove all elements represented in the given collection,
218 respecting cardinality.
</TD>
220 <TR BGCOLOR=
"white" CLASS=
"TableRowColor">
221 <TD ALIGN=
"right" VALIGN=
"top" WIDTH=
"1%"><FONT SIZE=
"-1">
222 <CODE> boolean
</CODE></FONT></TD>
223 <TD><CODE><B><A HREF=
"../../../../org/apache/commons/collections/Bag.html#retainAll(java.util.Collection)">retainAll
</A></B>(java.util.Collection
coll)
</CODE>
226 <i>(Violation)
</i>
227 Remove any members of the bag that are not in the given
228 collection, respecting cardinality.
</TD>
230 <TR BGCOLOR=
"white" CLASS=
"TableRowColor">
231 <TD ALIGN=
"right" VALIGN=
"top" WIDTH=
"1%"><FONT SIZE=
"-1">
232 <CODE> int
</CODE></FONT></TD>
233 <TD><CODE><B><A HREF=
"../../../../org/apache/commons/collections/Bag.html#size()">size
</A></B>()
</CODE>
236 Returns the total number of items in the bag across all types.
</TD>
238 <TR BGCOLOR=
"white" CLASS=
"TableRowColor">
239 <TD ALIGN=
"right" VALIGN=
"top" WIDTH=
"1%"><FONT SIZE=
"-1">
240 <CODE> java.util.Set
</CODE></FONT></TD>
241 <TD><CODE><B><A HREF=
"../../../../org/apache/commons/collections/Bag.html#uniqueSet()">uniqueSet
</A></B>()
</CODE>
244 Returns a
<CODE>Set
</CODE> of unique elements in the Bag.
</TD>
247 <A NAME=
"methods_inherited_from_class_java.util.Collection"><!-- --></A>
248 <TABLE BORDER=
"1" WIDTH=
"100%" CELLPADDING=
"3" CELLSPACING=
"0" SUMMARY=
"">
249 <TR BGCOLOR=
"#EEEEFF" CLASS=
"TableSubHeadingColor">
250 <TH ALIGN=
"left"><B>Methods inherited from interface java.util.Collection
</B></TH>
252 <TR BGCOLOR=
"white" CLASS=
"TableRowColor">
253 <TD><CODE>addAll, clear, contains, equals, hashCode, isEmpty, toArray, toArray
</CODE></TD>
259 <!-- ============ METHOD DETAIL ========== -->
261 <A NAME=
"method_detail"><!-- --></A>
262 <TABLE BORDER=
"1" WIDTH=
"100%" CELLPADDING=
"3" CELLSPACING=
"0" SUMMARY=
"">
263 <TR BGCOLOR=
"#CCCCFF" CLASS=
"TableHeadingColor">
264 <TH ALIGN=
"left" COLSPAN=
"1"><FONT SIZE=
"+2">
265 <B>Method Detail
</B></FONT></TH>
269 <A NAME=
"getCount(java.lang.Object)"><!-- --></A><H3>
272 int
<B>getCount
</B>(java.lang.Object
object)
</PRE>
274 <DD>Returns the number of occurrences (cardinality) of the given
275 object currently in the bag. If the object does not exist in the
282 <DT><B>Parameters:
</B><DD><CODE>object
</CODE> - the object to search for
283 <DT><B>Returns:
</B><DD>the number of occurrences of the object, zero if not found
</DL>
288 <A NAME=
"add(java.lang.Object)"><!-- --></A><H3>
291 boolean
<B>add
</B>(java.lang.Object
object)
</PRE>
293 <DD><i>(Violation)
</i>
294 Adds one copy the specified object to the Bag.
296 If the object is already in the
<A HREF=
"../../../../org/apache/commons/collections/Bag.html#uniqueSet()"><CODE>uniqueSet()
</CODE></A> then increment its
297 count as reported by
<A HREF=
"../../../../org/apache/commons/collections/Bag.html#getCount(java.lang.Object)"><CODE>getCount(Object)
</CODE></A>. Otherwise add it to the
298 <A HREF=
"../../../../org/apache/commons/collections/Bag.html#uniqueSet()"><CODE>uniqueSet()
</CODE></A> and report its count as
1.
300 Since this method always increases the size of the bag,
301 according to the
<CODE>Collection.add(Object)
</CODE> contract, it
302 should always return
<code>true
</code>. Since it sometimes returns
303 <code>false
</code>, this method violates the contract.
306 <DT><B>Specified by:
</B><DD><CODE>add
</CODE> in interface
<CODE>java.util.Collection
</CODE></DL>
309 <DT><B>Parameters:
</B><DD><CODE>object
</CODE> - the object to add
310 <DT><B>Returns:
</B><DD><code>true
</code> if the object was not already in the
<code>uniqueSet
</code></DL>
315 <A NAME=
"add(java.lang.Object, int)"><!-- --></A><H3>
318 boolean
<B>add
</B>(java.lang.Object
object,
319 int
nCopies)
</PRE>
321 <DD>Adds
<code>nCopies
</code> copies of the specified object to the Bag.
323 If the object is already in the
<A HREF=
"../../../../org/apache/commons/collections/Bag.html#uniqueSet()"><CODE>uniqueSet()
</CODE></A> then increment its
324 count as reported by
<A HREF=
"../../../../org/apache/commons/collections/Bag.html#getCount(java.lang.Object)"><CODE>getCount(Object)
</CODE></A>. Otherwise add it to the
325 <A HREF=
"../../../../org/apache/commons/collections/Bag.html#uniqueSet()"><CODE>uniqueSet()
</CODE></A> and report its count as
<code>nCopies
</code>.
331 <DT><B>Parameters:
</B><DD><CODE>object
</CODE> - the object to add
<DD><CODE>nCopies
</CODE> - the number of copies to add
332 <DT><B>Returns:
</B><DD><code>true
</code> if the object was not already in the
<code>uniqueSet
</code></DL>
337 <A NAME=
"remove(java.lang.Object)"><!-- --></A><H3>
340 boolean
<B>remove
</B>(java.lang.Object
object)
</PRE>
342 <DD><i>(Violation)
</i>
343 Removes all occurrences of the given object from the bag.
345 This will also remove the object from the
<A HREF=
"../../../../org/apache/commons/collections/Bag.html#uniqueSet()"><CODE>uniqueSet()
</CODE></A>.
347 According to the
<CODE>Collection.remove(Object)
</CODE> method,
348 this method should only remove the
<i>first
</i> occurrence of the
349 given object, not
<i>all
</i> occurrences.
352 <DT><B>Specified by:
</B><DD><CODE>remove
</CODE> in interface
<CODE>java.util.Collection
</CODE></DL>
356 <DT><B>Returns:
</B><DD><code>true
</code> if this call changed the collection
</DL>
361 <A NAME=
"remove(java.lang.Object, int)"><!-- --></A><H3>
364 boolean
<B>remove
</B>(java.lang.Object
object,
365 int
nCopies)
</PRE>
367 <DD>Removes
<code>nCopies
</code> copies of the specified object from the Bag.
369 If the number of copies to remove is greater than the actual number of
370 copies in the Bag, no error is thrown.
376 <DT><B>Parameters:
</B><DD><CODE>object
</CODE> - the object to remove
<DD><CODE>nCopies
</CODE> - the number of copies to remove
377 <DT><B>Returns:
</B><DD><code>true
</code> if this call changed the collection
</DL>
382 <A NAME=
"uniqueSet()"><!-- --></A><H3>
385 java.util.Set
<B>uniqueSet
</B>()
</PRE>
387 <DD>Returns a
<CODE>Set
</CODE> of unique elements in the Bag.
389 Uniqueness constraints are the same as those in
<CODE>Set
</CODE>.
396 <DT><B>Returns:
</B><DD>the Set of unique Bag elements
</DL>
401 <A NAME=
"size()"><!-- --></A><H3>
404 int
<B>size
</B>()
</PRE>
406 <DD>Returns the total number of items in the bag across all types.
409 <DT><B>Specified by:
</B><DD><CODE>size
</CODE> in interface
<CODE>java.util.Collection
</CODE></DL>
413 <DT><B>Returns:
</B><DD>the total size of the Bag
</DL>
418 <A NAME=
"containsAll(java.util.Collection)"><!-- --></A><H3>
421 boolean
<B>containsAll
</B>(java.util.Collection
coll)
</PRE>
423 <DD><i>(Violation)
</i>
424 Returns
<code>true
</code> if the bag contains all elements in
425 the given collection, respecting cardinality. That is, if the
426 given collection
<code>coll
</code> contains
<code>n
</code> copies
427 of a given object, calling
<A HREF=
"../../../../org/apache/commons/collections/Bag.html#getCount(java.lang.Object)"><CODE>getCount(Object)
</CODE></A> on that object must
428 be
<code>>= n
</code> for all
<code>n
</code> in
<code>coll
</code>.
430 The
<CODE>Collection.containsAll(Collection)
</CODE> method specifies
431 that cardinality should
<i>not
</i> be respected; this method should
432 return true if the bag contains at least one of every object contained
433 in the given collection.
436 <DT><B>Specified by:
</B><DD><CODE>containsAll
</CODE> in interface
<CODE>java.util.Collection
</CODE></DL>
439 <DT><B>Parameters:
</B><DD><CODE>coll
</CODE> - the collection to check against
440 <DT><B>Returns:
</B><DD><code>true
</code> if the Bag contains all the collection
</DL>
445 <A NAME=
"removeAll(java.util.Collection)"><!-- --></A><H3>
448 boolean
<B>removeAll
</B>(java.util.Collection
coll)
</PRE>
450 <DD><i>(Violation)
</i>
451 Remove all elements represented in the given collection,
452 respecting cardinality. That is, if the given collection
453 <code>coll
</code> contains
<code>n
</code> copies of a given object,
454 the bag will have
<code>n
</code> fewer copies, assuming the bag
455 had at least
<code>n
</code> copies to begin with.
457 <P>The
<CODE>Collection.removeAll(Collection)
</CODE> method specifies
458 that cardinality should
<i>not
</i> be respected; this method should
459 remove
<i>all
</i> occurrences of every object contained in the
463 <DT><B>Specified by:
</B><DD><CODE>removeAll
</CODE> in interface
<CODE>java.util.Collection
</CODE></DL>
466 <DT><B>Parameters:
</B><DD><CODE>coll
</CODE> - the collection to remove
467 <DT><B>Returns:
</B><DD><code>true
</code> if this call changed the collection
</DL>
472 <A NAME=
"retainAll(java.util.Collection)"><!-- --></A><H3>
475 boolean
<B>retainAll
</B>(java.util.Collection
coll)
</PRE>
477 <DD><i>(Violation)
</i>
478 Remove any members of the bag that are not in the given
479 collection, respecting cardinality. That is, if the given
480 collection
<code>coll
</code> contains
<code>n
</code> copies of a
481 given object and the bag has
<code>m
> n
</code> copies, then
482 delete
<code>m - n
</code> copies from the bag. In addition, if
483 <code>e
</code> is an object in the bag but
484 <code>!coll.contains(e)
</code>, then remove
<code>e
</code> and any
487 <P>The
<CODE>Collection.retainAll(Collection)
</CODE> method specifies
488 that cardinality should
<i>not
</i> be respected; this method should
489 keep
<i>all
</i> occurrences of every object contained in the
493 <DT><B>Specified by:
</B><DD><CODE>retainAll
</CODE> in interface
<CODE>java.util.Collection
</CODE></DL>
496 <DT><B>Parameters:
</B><DD><CODE>coll
</CODE> - the collection to retain
497 <DT><B>Returns:
</B><DD><code>true
</code> if this call changed the collection
</DL>
502 <A NAME=
"iterator()"><!-- --></A><H3>
505 java.util.Iterator
<B>iterator
</B>()
</PRE>
507 <DD>Returns an
<CODE>Iterator
</CODE> over the entire set of members,
508 including copies due to cardinality. This iterator is fail-fast
509 and will not tolerate concurrent modifications.
512 <DT><B>Specified by:
</B><DD><CODE>iterator
</CODE> in interface
<CODE>java.util.Collection
</CODE><DT><B>Specified by:
</B><DD><CODE>iterator
</CODE> in interface
<CODE>java.lang.Iterable
</CODE></DL>
516 <DT><B>Returns:
</B><DD>iterator over all elements in the Bag
</DL>
519 <!-- ========= END OF CLASS DATA ========= -->
523 <!-- ======= START OF BOTTOM NAVBAR ====== -->
524 <A NAME=
"navbar_bottom"><!-- --></A>
525 <A HREF=
"#skip-navbar_bottom" title=
"Skip navigation links"></A>
526 <TABLE BORDER=
"0" WIDTH=
"100%" CELLPADDING=
"1" CELLSPACING=
"0" SUMMARY=
"">
528 <TD COLSPAN=
2 BGCOLOR=
"#EEEEFF" CLASS=
"NavBarCell1">
529 <A NAME=
"navbar_bottom_firstrow"><!-- --></A>
530 <TABLE BORDER=
"0" CELLPADDING=
"0" CELLSPACING=
"3" SUMMARY=
"">
531 <TR ALIGN=
"center" VALIGN=
"top">
532 <TD BGCOLOR=
"#EEEEFF" CLASS=
"NavBarCell1"> <A HREF=
"../../../../overview-summary.html"><FONT CLASS=
"NavBarFont1"><B>Overview
</B></FONT></A> </TD>
533 <TD BGCOLOR=
"#EEEEFF" CLASS=
"NavBarCell1"> <A HREF=
"package-summary.html"><FONT CLASS=
"NavBarFont1"><B>Package
</B></FONT></A> </TD>
534 <TD BGCOLOR=
"#FFFFFF" CLASS=
"NavBarCell1Rev"> <FONT CLASS=
"NavBarFont1Rev"><B>Class
</B></FONT> </TD>
535 <TD BGCOLOR=
"#EEEEFF" CLASS=
"NavBarCell1"> <A HREF=
"class-use/Bag.html"><FONT CLASS=
"NavBarFont1"><B>Use
</B></FONT></A> </TD>
536 <TD BGCOLOR=
"#EEEEFF" CLASS=
"NavBarCell1"> <A HREF=
"package-tree.html"><FONT CLASS=
"NavBarFont1"><B>Tree
</B></FONT></A> </TD>
537 <TD BGCOLOR=
"#EEEEFF" CLASS=
"NavBarCell1"> <A HREF=
"../../../../deprecated-list.html"><FONT CLASS=
"NavBarFont1"><B>Deprecated
</B></FONT></A> </TD>
538 <TD BGCOLOR=
"#EEEEFF" CLASS=
"NavBarCell1"> <A HREF=
"../../../../index-all.html"><FONT CLASS=
"NavBarFont1"><B>Index
</B></FONT></A> </TD>
539 <TD BGCOLOR=
"#EEEEFF" CLASS=
"NavBarCell1"> <A HREF=
"../../../../help-doc.html"><FONT CLASS=
"NavBarFont1"><B>Help
</B></FONT></A> </TD>
543 <TD ALIGN=
"right" VALIGN=
"top" ROWSPAN=
3><EM>
549 <TD BGCOLOR=
"white" CLASS=
"NavBarCell2"><FONT SIZE=
"-2">
550 <A HREF=
"../../../../org/apache/commons/collections/ArrayStack.html" title=
"class in org.apache.commons.collections"><B>PREV CLASS
</B></A>
551 <A HREF=
"../../../../org/apache/commons/collections/BagUtils.html" title=
"class in org.apache.commons.collections"><B>NEXT CLASS
</B></A></FONT></TD>
552 <TD BGCOLOR=
"white" CLASS=
"NavBarCell2"><FONT SIZE=
"-2">
553 <A HREF=
"../../../../index.html?org/apache/commons/collections/Bag.html" target=
"_top"><B>FRAMES
</B></A>
554 <A HREF=
"Bag.html" target=
"_top"><B>NO FRAMES
</B></A>
555 <SCRIPT type=
"text/javascript">
558 document.writeln('<A HREF="../../../../allclasses-noframe.html"><B>All Classes</B></A>');
563 <A HREF=
"../../../../allclasses-noframe.html"><B>All Classes
</B></A>
570 <TD VALIGN=
"top" CLASS=
"NavBarCell3"><FONT SIZE=
"-2">
571 SUMMARY:
NESTED
|
FIELD
|
CONSTR
|
<A HREF=
"#method_summary">METHOD
</A></FONT></TD>
572 <TD VALIGN=
"top" CLASS=
"NavBarCell3"><FONT SIZE=
"-2">
573 DETAIL:
FIELD
|
CONSTR
|
<A HREF=
"#method_detail">METHOD
</A></FONT></TD>
576 <A NAME=
"skip-navbar_bottom"></A>
577 <!-- ======== END OF BOTTOM NAVBAR ======= -->
580 Copyright ©
2001-
2008 <a href=
"http://www.apache.org/">The Apache Software Foundation
</a>. All Rights Reserved.