2: import java.util.Collection;
4: /**
5: * A data type representing an unordered collection of items, possibly
6: * including duplicates.
7: *
8: * @author Mark Young (A00000000)
9: */
10: public interface Bag<T> extends Collection<T> {
11:
12: /**
13: * Remove an item from this Bag. The item to remove is at the discretion of
14: * the implementation.
15: *
16: * @return an arbitrary item removed from this Bag
17: * @throws java.util.NoSuchElementException if the Bag was empty
18: */
19: public T remove();
21: /**
22: * Count how many times the given item appears in this Bag. An item gets
23: * counted if {@code Objects.equals} reports it equal to the given item.
24: *
25: * @param anItem the item to count
26: * @return how many copies of that item appear in this Bag
27: */
28: public int getFrequency(T anItem);
30: }