toggle method
void
toggle(
- E element
Adds the element
to the set if it is not in the set, removes the element
if it is in the set.
{1}.toggle(1); // {}
{}.toggle(1); // {1}
Implementation
void toggle(E element) {
if (!remove(element)) {
add(element);
}
}