addIfNotContains method

void addIfNotContains(
  1. T element
)

Do that:

if (!contains(element)) add(element);

Implementation

void addIfNotContains(T element) {
  if (!contains(element)) add(element);
}