code: public synchronized int addAllAbsent(Collection<? extends E> collection) {
          Object[] toAdd = collection.toArray();
          Object[] newElements = new Object[elements.length + toAdd.length];
          System.arraycopy(elements, 0, newElements, 0, elements.length);
          int addedCount = 0;
          for (Object o : toAdd) {
              if (indexOf(o, newElements, 0, elements.length + addedCount) == -1) {
                  newElements[elements.length + addedCount++] = o;
              }
          }
          if (addedCount < toAdd.length) {
              newElements = Arrays.copyOfRange(
                      newElements, 0, elements.length + addedCount); // trim to size
          }
          elements = newElements;
          return addedCount;
      }
docs: Adds the elements of {@code collection} that are not already present in
  this list. If {@code collection} includes a repeated value, at most one
  occurrence of that value will be added to this list. Elements are added
  at the end of this list.
  
  <p>Callers of this method may prefer {@link CopyOnWriteArraySet}, whose
  API is more appropriate for set operations.