Adds an element to the bag. This method adds the specified element to the bag. Duplicates are allowed, and the bag will maintain the order in which elements are added. @param element the element to add; must not be null
(E element)
| 59 | * @param element the element to add; must not be {@code null} |
| 60 | */ |
| 61 | public void add(E element) { |
| 62 | Node<E> newNode = new Node<>(); |
| 63 | newNode.content = element; |
| 64 | newNode.nextElement = firstElement; |
| 65 | firstElement = newNode; |
| 66 | size++; |
| 67 | } |
| 68 | |
| 69 | /** |
| 70 | * Checks if the bag contains a specific element. |
no outgoing calls