001package myhw2.data;
002
003import java.util.Comparator;
004import java.util.Iterator;
005
006/**
007 * A collection of Records.
008 * Records can only be created and destroyed using the Inventory.
009 * @see Data
010 */
011public interface Inventory extends Iterable<Record> {
012        /**
013         *  Return the number of Records.
014         */
015        public int size();
016
017        /**
018         *  Return the record for a given Video; if not present, return <code>null</code>.
019         */
020        public Record get(Video v);
021
022        /**
023         *  Return an iterator over Records in the Inventory.
024         *  <p>The iterator returns objects that implement the Record interface.</p>
025         *  <p>Any attempt to remove objects using the iterator should
026         *  result in an <code>UnsupportedOperationException</code>.</p>
027         *  <p>The Record order is unspecified</p>
028         */
029        public Iterator<Record> iterator();
030
031        /**
032         *  Return an iterator over the Inventory, sorted accoring the
033         *  Comparator.
034         *  <p>The iterator returns objects that implement the
035         *  <code>Record</code> interface.</p>
036         *  <p>Any attempt to remove objects using the iterator should
037         *  result in an <code>UnsupportedOperationException</code>.</p>
038         *  <p>The iteration order is determined by the comparator (least first).</p>
039         *  <p>The comparator may assume that its arguments implement
040         *  <code>Record</code>.</p>
041         *  @param comparator determines the order of the records returned.
042         */
043        public Iterator<Record> iterator(Comparator<Record> comparator);
044
045        /**
046         * Returns the inventory as a string; one record per line.
047         */
048        public String toString();
049}