Package dsa.lab01.base
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 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
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
Get the item at the given index.- Parameters:
index- the index- Returns:
- the item that is at that index
- Throws:
IndexOutOfBoundsException- ifindex< 0 orindex>=n(wherenis the size)
-
set
Set the item at the given index.Replaces whatever item was there before.
- Parameters:
index- the indexitem- the new item that should now be at that index- Throws:
IndexOutOfBoundsException- ifindex< 0 orindex>=n(wherenis the size)
-