Interface Container<Item>

Type Parameters:
Item - the item type
All Superinterfaces:
Iterable<Item>
All Known Subinterfaces:
DynamicSequence<Item>, LinkedList<Item>, Queue<Item>, Stack<Item>, StaticSequence<Item>
All Known Implementing Classes:
ArrayQueue, ArrayQueue, ArrayStack, ArrayStack, CircularDynamicArray, CircularDynamicArray, DoublyLinkedList, DoublyLinkedList, DynamicArray, DynamicArray, LinkedQueue, LinkedQueue, LinkedStack, LinkedStack, SinglyLinkedList, SinglyLinkedList, StaticArray, StaticArray

public interface Container<Item> extends Iterable<Item>
A container.

Something that contains some number of items, not necessarily in any particular order.

  • Method Summary

    Modifier and Type
    Method
    Description
    default boolean
    contains(Item item)
    Check if the given item is equal to any of those contained.
    default boolean
    Check if it's empty.
    Get an iterable that yields each item once.
    default Iterator<Item>
     
    int
    Get the number of contained items.

    Methods inherited from interface java.lang.Iterable

    forEach, spliterator
  • Method Details

    • size

      int size()
      Get the number of contained items.
      Returns:
      the size
    • isEmpty

      default boolean isEmpty()
      Check if it's empty.
      Returns:
      whether there are no items
    • contains

      default boolean contains(Item item)
      Check if the given item is equal to any of those contained.
      Parameters:
      item - the item to check for membership
      Returns:
      whether such an item is contained
    • items

      Iterable<Item> items()
      Get an iterable that yields each item once.
      Returns:
      an iterable over the items
    • iterator

      default Iterator<Item> iterator()
      Specified by:
      iterator in interface Iterable<Item>