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 Summary
All Methods Instance Methods Abstract Methods Modifier and Type Method Description void
add(Item item)
Addsitem
to this bag.boolean
isEmpty()
Returnstrue
if this bag is empty, andfalse
otherwise.int
size()
Returns the number of items in this bag.-
Methods inherited from interface java.lang.Iterable
forEach, iterator, spliterator
-
-
-
-
Method Detail
-
isEmpty
boolean isEmpty()
Returnstrue
if this bag is empty, andfalse
otherwise.- Returns:
true
if this bag is empty, andfalse
otherwise.
-
size
int size()
Returns the number of items in this bag.- Returns:
- number of items in this bag.
-
add
void add(Item item)
Addsitem
to this bag.- Parameters:
item
- the item.
-
-