Source code: org/odmg/DBag.java
1 package org.odmg;
2
3 /**
4 * This interface defines the operations associated with an ODMG bag collection.
5 * All of the operations defined by the JavaSoft <code>Collection</code>
6 * interface are supported by an ODMG implementation of <code>DBag</code>,
7 * the exception <code>UnsupportedOperationException</code> is not thrown when a
8 * call is made to any of the <code>Collection</code> methods.
9 * @author David Jordan (as Java Editor of the Object Data Management Group)
10 * @version ODMG 3.0
11 */
12 // * @see java.lang.UnsupportedOperationException
13
14 public interface DBag extends DCollection
15 {
16 /**
17 * A new <code>DBag</code> instance is created that is the union of this object
18 * and <code>otherBag</code>.
19 * This method is similar to the <code>addAll</code> method in <code>Collection</code>,
20 * except that this method creates a new collection and <code>addAll</code>
21 * modifies the object to contain the result.
22 * @param otherBag The other bag to use in the union operation.
23 * @return A <code>DBag</code> instance that contains the union of this object
24 * and <code>otherBag</code>.
25 */
26 // * @see com.sun.java.util.collections.Collection#addAll
27 public DBag union(DBag otherBag);
28
29 /**
30 * A new <code>DBag</code> instance is created that contains the intersection of
31 * this object and the <code>DBag</code> referenced by <code>otherBag</code>.
32 * This method is similar to the <code>retainAll</code> method in <code>Collection</code>,
33 * except that this method creates a new collection and <code>retainAll</code>
34 * modifies the object to contain the result.
35 * @param otherBag The other bag to use in creating the intersection.
36 * @return A <code>DBag</code> instance that contains the intersection of this
37 * object and <code>otherBag</code>.
38 */
39 // @see com.sun.java.util.collections.Collection#retainAll
40 public DBag intersection(DBag otherBag);
41
42 /**
43 * A new <code>DBag</code> instance is created that contains the difference of
44 * this object and the <code>DBag</code> instance referenced by <code>otherBag</code>.
45 * This method is similar to the <code>removeAll</code> method in <code>Collection</code>,
46 * except that this method creates a new collection and <code>removeAll</code>
47 * modifies the object to contain the result.
48 * @param otherBag The other bag to use in creating the difference.
49 * @return A <code>DBag</code> instance that contains the elements of this object
50 * minus the elements in <code>otherBag</code>.
51 */
52 // * @see com.sun.java.util.collections.Collection#removeAll
53 public DBag difference(DBag otherBag);
54
55 /**
56 * This method returns the number of occurrences of the object <code>obj</code>
57 * in the <code>DBag</code> collection.
58 * @param obj The value that may have elements in the collection.
59 * @return The number of occurrences of <code>obj</code> in this collection.
60 */
61 public int occurrences(Object obj);
62 }