Closed GoogleCodeExporter closed 9 years ago
Ok-- if I have
Multiset.Entry entry = ... some Multiset.Entry
then this does work:
myMultiset.entrySet().remove(entry);
Perhaps there should be some sort of convenience method in the Multiset
interface for
removing an element completely, as well as for decrementing some or all of its
count.
Original comment by angus.fo...@gmail.com
on 8 Jun 2008 at 9:04
Are you sure? Which multiset implementation are you using? Could you provide a
failing test case?
The AbstractMapBasedMultiset.removeAllOccurences code, copied below, removes the
entry from the backing map.
private int removeAllOccurrences(@Nullable Object element,
Map<E, AtomicInteger> map) {
AtomicInteger frequency = map.remove(element);
if (frequency == null) {
return 0;
}
int numberRemoved = frequency.getAndSet(0);
size -= numberRemoved;
return numberRemoved;
}
Original comment by jared.l....@gmail.com
on 8 Jun 2008 at 4:17
I'm closing this issue, since I couldn't reproduce it. If you can provide some
code
that behaves incorrectly, please reopen this.
Original comment by jared.l....@gmail.com
on 10 Jun 2008 at 7:00
This is ironic, because the method that you want, removeAllOccurrences(), both
(a)
exists and (b) is being removed!!
So it's the exact opposite of what you'd have wanted. However,
removeAllOccurrences(a) is identical in behavior to both elementSet().remove(a)
and
the (soon-to-be-added) setCount(a, 0), so it became highly redundant.
Incidentally, there is zero difference between setting an element's count to
zero and
removing the element completely. They are the same thing.
Original comment by kevin...@gmail.com
on 10 Jun 2008 at 7:06
Original issue reported on code.google.com by
angus.fo...@gmail.com
on 8 Jun 2008 at 8:56