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