Checks if element is not an instance of members of $notAllowedElements[] and adds it to composite.

@param Element $element
@return Element
183655
public function addElement(Element $element): Element
    {
        foreach ($this->notAllowedElements as $notAllowed) {
            if ($element instanceof $notAllowed) {
                $callerName = \str_replace([__NAMESPACE__, '\\'], '', \get_called_class());
                $notAllowedName = \str_replace([__NAMESPACE__, '\\'], '', $notAllowed);
                throw new InvalidArgumentException($callerName.' cannot contain '.$notAllowedName);
            }
        }
        $this->elements[] = $element;
        return $element;
    }
552424
public function findByElementAndNotUserId(Element $element, $notUserId)
    {
        $qb = $this->createQueryBuilder('l');
        $qb
            ->where($qb->expr()->eq('l.element', $element->getEid()))
            ->andWhere($qb->expr()->neq('l.userId', $qb->expr()->literal($notUserId)));

        return $qb->getQuery()->getResult();
    }
1048685
public function add($element, $index = null) {
		if ($index === null) {
			$this->collection[$this->size()] = $element;
		} else {
			array_splice($this->collection, $index, 0, $element);
		}
		
		return $this;
	}
243534
protected function _isInheritCheckboxRequired(\Magento\Framework\Data\Form\Element\AbstractElement $element)
    {
        return $element->getCanUseContainerValue() || $element->getCanUseDefaultValue();
    }
1183490
public function remove($element) {
		$index = array_search($element, $this->collection, true);
		if ($index !== null) {
			unset($this->collection[$index]);
		}

		return $this;
	}
272592
protected function addElement($element)
    {
        if($element->getData() == null) {
            throw new Exception("Invalid Element data: null is not allowed.");
        }
        if ($this->elementExistsWith($element->getData())) {
            $this->addWeightToExisting($element);
        } else {
            $this->elements[] = $element;
        }

        return $this;
    }
279605
public function contains($element)
    {
        if ($this->isInitialized()) {
            return $this->collection->contains($element);
        }

        return $this->entityPersister->exists($element, $this->criteria);
    }
515691
public function add($element)
    {
        $this->guardAgainstDuplicatedElement($element);

        $isAdded = false;
        if (false === $this->contains($element)) {
            $isAdded = true;
            $this->offsetSet($element->uId()->id(), $element);
        }

        return $isAdded;
    }
238654
public function validate($element): bool
    {
        if (!$expectedType = $this->getType()) {
            return true;
        }

        $expectedType = $this->typeMap[$expectedType] ?? $expectedType;
        $actualType   = \gettype($element);

        if (($actualType === 'object' && $element instanceof $expectedType) || $actualType === $expectedType) {
            return true;
        }

        throw new InvalidTypeException($expectedType, $actualType === 'object' ? \get_class($element) : $actualType);
    }
454488
public function remove($element)
    {
        $key = array_search($element, $this->elements, true);
        if (false !== $key) {
            unset($this->elements[$key]);
            $this->elements = array_values($this->elements);
        }
        foreach ($this->subLists as $subList) {
            $subList->drop($key, true);
        }
        return $this;
    }
1143596
protected function assertElement($element)
	{
		if ( !is_a($element, $this->elementClass) ) {
			$message = 'Collection element must be of "%s" class, but element of "%s" class given';

			throw new ElementCollectionException(
				sprintf($message, $this->elementClass, get_class($element)),
				ElementCollectionException::TYPE_ELEMENT_CLASS_MISMATCH
			);
		}

		return $this->acceptElement($element);
	}
1062036
protected function serializeElement($element)
	{
		return (is_array($element)) ? $this->serializeStrings($element) : $this->serializeLiteral($element);
	}
1372793
private function getValueFromKey($element, $key)
    {
        if ((is_object($element) && !$this->getValueKeyFromObject($element, $key)) || (is_array($element) && !isset($element[$key]))) {
            $getterName = 'get'.str_replace(' ', '', ucwords($key));

            throw new NotValidKeyElementInListException($key.' is not a valid key. If your elements are Entities class, please check if you implement '.$getterName.'() method.');
        }

        return is_object($element) ? $this->getValueKeyFromObject($element, $key) : $element[$key];
    }
174301
public static function fromElementBase(ElementBase $el): self
    {
        // if element is already wrapped
        if ($el instanceof self) {
            return $el;
        }
        return new self($el->asElement());
    }
745982
public function contains($element)
    {
        $hash = $this->hash($element);
        return isset($this->hashTable[$hash])
               && in_array($element, $this->hashTable[$hash], true);
    }
434353
public function removeElement($element)
    {
        if (!$this->hasElement($element)) {
            return false;
        }

        $totalCollection = $this->count();
        $key             = $this->indexOf($element);

        unset($this->collections[$key]);

        return $this->count() !== $totalCollection;
    }
1210344
function removeElement($element)
    {
        if(get_class($element) !== $this->manager->getModel()){
            throw new InvalidArgumentException("This element is not compatible with this collection, it only support  ".$this->manager->getModel());
        }

        $key = array_search($element, $this->elements, true);

        if ($key !== false) {
            unset($this->elements[$key]);

            return true;
        }

        return false;
    }