Interface BadStaticSequence<Item>

Type Parameters:
Item - the item type

public interface BadStaticSequence<Item>
A static sequence.

A container whose n items are in an order given by their indices, where the first item is at index 0, the second at index 1, and so on, the nth being at index n-1.

  • Method Summary

    Modifier and Type
    Method
    Description
    boolean
    contains(Item item)
    Check if the given item is equal to any of those contained.
    get(int index)
    Get the item at the given index.
    default boolean
    Check if it's empty.
    void
    set(int index, Item item)
    Set the item at the given index.
    int
    Get the number of contained items.
  • 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

      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
    • get

      Item get(int index) throws IndexOutOfBoundsException
      Get the item at the given index.
      Parameters:
      index - the index
      Returns:
      the item that is at that index
      Throws:
      IndexOutOfBoundsException - if index < 0 or index >= n (where n is the size)
    • set

      void set(int index, Item item) throws IndexOutOfBoundsException
      Set the item at the given index.

      Replaces whatever item was there before.

      Parameters:
      index - the index
      item - the new item that should now be at that index
      Throws:
      IndexOutOfBoundsException - if index < 0 or index >= n (where n is the size)