Package dsa
Interface Bag<T>
- Type Parameters:
T
- the type of items in the bag.
- All Superinterfaces:
Iterable<T>
- All Known Implementing Classes:
LinkedBag
,ResizingArrayBag
This interface specifies the API for the bag data structure.
-
Method Summary
Methods inherited from interface java.lang.Iterable
forEach, iterator, spliterator
-
Method Details
-
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
Addsitem
to this bag.- Parameters:
item
- the item.
-
toString
String toString()Returns a string representation of this bag.
-