Adds elements to the end of the list.

@param CollectionInterface|array $elements Elements to add to the list.

@return ArrayList A reference to the list.

@see add
503931
public function addAll($elements)
    {
        if ($elements instanceof CollectionInterface) {
            $elements = $elements->toArray();
        } else {
            $elements = array_values($elements);
        }
        $this->elements = array_merge($this->elements, $elements);
        return $this;
    }
1172716
public function flatten(array $elements)
    {
        $level = [];

        foreach ($elements as $node)
        {
            if (is_array($node))
            {
                $level = array_merge($level, $this->flatten($node));
            }
            else
            {
                $level[] = $node;
            }
        }

        return $level;
    }
528721
public function insertAfter($element)
    {
        $e = self::create($element);
        $newnodes = array();
        foreach ($e as $i => $node) {
            /** @var \DOMNode $node */
            $refnode = $node->nextSibling;
            foreach ($this as $newnode) {
                /** @var \DOMNode $newnode */
                $newnode = static::importNewnode($newnode, $node, $i);
                if ($refnode === null) {
                    $node->parentNode->appendChild($newnode);
                } else {
                    $node->parentNode->insertBefore($newnode, $refnode);
                }
                $newnodes[] = $newnode;
            }
        }
        return self::create($newnodes);
    }
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;
    }
180
public function setElements(array $elements)
    {
        $this->elements = [];
        foreach ($elements as $name => $element) {
            $this->setElement($name, $element);
        }

        return $this;
    }
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;
	}
394232
public function add($element) : BagInterface
    {
        array_unshift($this->elements, $element);
        shuffle($this->elements);
        return $this;
    }
949215
public function push(...$elements): self
    {
        foreach ($elements as $element) {
            $this->validate($element);

            $this->elements[] = $element;
        }

        return $this;
    }
1072279
private function removeElements( $elements ) {
		$list = $elements;
		if ( $elements instanceof \DOMNodeList ) {
			$list = [];
			foreach ( $elements as $element ) {
				$list[] = $element;
			}
		}
		/** @var $element \DOMElement */
		foreach ( $list as $element ) {
			if ( $element->parentNode ) {
				$element->parentNode->removeChild( $element );
			}
		}
		return $list;
	}
1336052
private function _build_items(array $items)
	{
		foreach ($items as $key => $item) {
			$this->_items[$key] = new Element_Item($item, $this, $key);
		}

		return $this;
	}
474530
public function add($element) {
		if (!in_array($element, $this->collection, true)) {
			$this->collection[$this->size()] = $element;
		}

		return $this;
	}
1284912
public function append($element) {
        $this->elements[] = $element;
        $this->fire(new ListCreateEvent($element, $this->count() - 1));
        return $this;
    }
749150
public function add(ElementInterface $element)
    {
        $id = $element->id;

        if ($id === null) $id = $this->generateId();

        $this->checkId($id);

        $this->objects[$id] = $element;
    }
244875
public function addElement(BaseElement $element): ContainerElement
    {
        $element->parent = $this;
        $this->children[] = $element;
        if ($element instanceof ContainerElement) {
            return $element;
        }

        return $this;
    }
841777
public function addElements(array $elements) {
		foreach ($elements as $name => $element) {
			if (is_string($name)) {
				$this->addElement($element, $name);
			} else {
				$this->addElement($element);
			}
		}
		
		return $this;
	}
823283
public function diff(Collection $collection) : self
    {
        foreach ($this->elements as $element) {
            if (!$collection->contains($element)) {
                $this->removeElement($element);
            }
        }

        foreach ($collection as $element) {
            if (!$this->contains($element)) {
                $this->add($element);
            }
        }

        return $this;
    }
25638
public function add($element)
    {
        if (!$this->contains($element)) {
            $hash = $this->hash($element);
            $this->hashTable[$hash][] = $element;
            return true;
        }
        return false;
    }