Package dsa
Class LinkedBag<Item>
- java.lang.Object
-
- dsa.LinkedBag<Item>
-
-
Constructor Summary
Constructors Constructor Description LinkedBag()
Constructs an empty bag.
-
Method Summary
All Methods Static Methods Instance Methods Concrete Methods Modifier and Type Method Description void
add(Item item)
Addsitem
to this bag.boolean
isEmpty()
Returnstrue
if this bag is empty, andfalse
otherwise.Iterator<Item>
iterator()
Returns an iterator to iterate over the items in this bag.static void
main(String[] args)
Unit tests the data type.int
size()
Returns the number of items in this bag.String
toString()
Returns a string representation of this bag.-
Methods inherited from class java.lang.Object
clone, equals, finalize, getClass, hashCode, notify, notifyAll, wait, wait, wait
-
Methods inherited from interface java.lang.Iterable
forEach, spliterator
-
-
-
-
Method Detail
-
isEmpty
public boolean isEmpty()
Description copied from interface:Bag
Returnstrue
if this bag is empty, andfalse
otherwise.
-
size
public int size()
Description copied from interface:Bag
Returns the number of items in this bag.
-
iterator
public Iterator<Item> iterator()
Returns an iterator to iterate over the items in this bag.
-
toString
public String toString()
Returns a string representation of this bag.
-
main
public static void main(String[] args)
Unit tests the data type.- Parameters:
args
- the command-line arguments.
-
-