Package dsa

Interface Bag<Item>

  • All Superinterfaces:
    Iterable<Item>
    All Known Implementing Classes:
    LinkedBag, ResizingArrayBag

    public interface Bag<Item>
    extends Iterable<Item>
    This interface specifies the API for the bag data structure.
    • Method Detail

      • isEmpty

        boolean isEmpty()
        Returns true if this bag is empty, and false otherwise.
        Returns:
        true if this bag is empty, and false otherwise.
      • size

        int size()
        Returns the number of items in this bag.
        Returns:
        number of items in this bag.
      • add

        void add​(Item item)
        Adds item to this bag.
        Parameters:
        item - the item.