@Test public void withAll() { HashBag<String> bag = this.testObj.withAll("1", "2", "3", "2", "3", "3"); Assert.assertEquals(1, bag.getOccurrences("1")); Assert.assertEquals(2, bag.getOccurrences("2")); Assert.assertEquals(3, bag.getOccurrences("3")); }
HashBag<T> withAll(T... elements) { for (T element : elements) { this.backingMap.merge(element, 1, (existingValue, newValue) -> existingValue + 1); this.size++; } return this; }
HashBag implements MutableBag<T> { HashBag<T> withAll(T... elements) { for (T element : elements) { this.backingMap.merge(element, 1, (existingValue, newValue) -> existingValue + 1); this.size++; } return this; } }
HashBag implements MutableBag<T> { HashBag<T> withAll(T... elements) { for (T element : elements) { this.backingMap.merge(element, 1, (existingValue, newValue) -> existingValue + 1); this.size++; } return this; }  }
HashBag implements MutableBag<T> { HashBag<T> withAll(T... elements) { for (T element : elements) { this.backingMap.merge(element, 1, (existingValue, newValue) -> existingValue + 1); this.size++; } return this; }  @Override int sizeDistinct(); @Override int size(); @Override boolean isEmpty(); @Override boolean contains(Object o); @Override Object[] toArray(); void forEachWithIndex(BiConsumer<? super T, Integer> biConsumer); @Override T1[] toArray(T1[] array); @Override boolean add(T element); @Override boolean remove(Object o); @Override boolean containsAll(Collection<?> c); @Override boolean addAll(Collection<? extends T> c); @Override boolean removeAll(Collection<?> c); @Override boolean retainAll(Collection<?> c); @Override void clear(); @Override Iterator<T> iterator(); @Override int getOccurrences(T element); @Override boolean addOccurrence(T element); @Override boolean addOccurrences(T element, int occurrences); @Override boolean removeOccurrence(T element); @Override boolean removeOccurrences(T element, int occurrences); @Override void forEachWithOccurrences(BiConsumer<? super T, Integer> biConsumer); @Override void forEach(Consumer<? super T> consumer); @Override int hashCode(); @Override boolean equals(Object other); }
HashBag implements MutableBag<T> { HashBag<T> withAll(T... elements) { for (T element : elements) { this.backingMap.merge(element, 1, (existingValue, newValue) -> existingValue + 1); this.size++; } return this; }  @Override int sizeDistinct(); @Override int size(); @Override boolean isEmpty(); @Override boolean contains(Object o); @Override Object[] toArray(); void forEachWithIndex(BiConsumer<? super T, Integer> biConsumer); @Override T1[] toArray(T1[] array); @Override boolean add(T element); @Override boolean remove(Object o); @Override boolean containsAll(Collection<?> c); @Override boolean addAll(Collection<? extends T> c); @Override boolean removeAll(Collection<?> c); @Override boolean retainAll(Collection<?> c); @Override void clear(); @Override Iterator<T> iterator(); @Override int getOccurrences(T element); @Override boolean addOccurrence(T element); @Override boolean addOccurrences(T element, int occurrences); @Override boolean removeOccurrence(T element); @Override boolean removeOccurrences(T element, int occurrences); @Override void forEachWithOccurrences(BiConsumer<? super T, Integer> biConsumer); @Override void forEach(Consumer<? super T> consumer); @Override int hashCode(); @Override boolean equals(Object other);  }