Adds a new segment
@param string|\csslib\Segment $segment Segment to be addded
@param \csslib\Segment $other If given the segment to be added wil be inserted before the other segment
@return \csslib\Segment The added segment
5146
public function addSegment($segment, $other = null){
		if(!$segment instanceof Segment){
			$segment = new Segment($segment);
		}
		if($this->getIndexOf($segment->getName())) throw new \Exception('Section with this name already exists');
		if($other){
			if(($index = $this->getIndexOf($other))===false) throw new \Exception('Segment not found');
			array_splice($this->segments, $index, 0, [$segment]);
		}else{
			$this->segments[] = $segment;
		}
		return $segment;
	}
69120
public static function createFromSegments(iterable $segments, int $type = self::IS_RELATIVE): self
    {
        static $type_list = [self::IS_ABSOLUTE => 1, self::IS_RELATIVE => 1];

        if (!isset($type_list[$type])) {
            throw new PathTypeNotFound(sprintf('"%s" is an invalid or unsupported %s type', $type, self::class));
        }

        $pathSegments = [];
        foreach ($segments as $value) {
            if (!is_scalar($value) && !method_exists($value, '__toString')) {
                throw new TypeError('The submitted segments are invalid');
            }
            $pathSegments[] = (string) $value;
        }

        $path = implode(self::SEPARATOR, $pathSegments);
        if (static::IS_ABSOLUTE !== $type) {
            return new self(ltrim($path, self::SEPARATOR));
        }

        if (self::SEPARATOR !== ($path[0] ?? '')) {
            return new self(self::SEPARATOR.$path);
        }

        return new self($path);
    }
801739
public static function adjacentSide(
        Segment $hypotenuse,
        Segment $adjacentSide
    ): Segment {
        $side = $hypotenuse
            ->length()
            ->power(new Integer(2))
            ->subtract($adjacentSide->length()->power(new Integer(2)))
            ->squareRoot();

        return new Segment($side);
    }
431835
private function getIndexOf($segment){
		if($segment instanceof Segment){
			foreach($this->segments as $index=>$other){
				if($other === $segment){
					return $index;
				}
			}
		}else{
			foreach($this->segments as $index=>$other){
				if($other->getName() === $segment){
					return $index;
				}
			}
		}
		return false;
	}
130374
public function mergeSegment(Segment $segment)
    {
        if (! array_key_exists($segment->getName(), $this->segments)) {
            throw new OdfException($segment->getName() . 'cannot be parsed, has it been set yet ?');
        }
        $string = $segment->getName();
        // $reg = '@<text:p[^>]*>\[!--\sBEGIN\s' . $string . '\s--\](.*)\[!--.+END\s' . $string . '\s--\]<\/text:p>@smU';
        $reg = '@\[!--\sBEGIN\s' . $string . '\s--\](.*)\[!--.+END\s' . $string . '\s--\]@smU';
        $this->contentXml = preg_replace($reg, $segment->getXmlParsed(), $this->contentXml);
        foreach ($segment->manif_vars as $val) {
            $this->manif_vars[] = $val;   //copy all segment image names into current array
        }
        return $this;
    }
1362547
protected function addSegment(Segment $segment)
    {
        if (!$segment->getSegment() && $this->segmentName) {
            $segment->setSegment($this->segmentName);
        }

        if (!$segment->getType()) {
            $metricTypes = array(self::TYPE_NUMBER, self::TYPE_FLOAT, self::TYPE_MONEY, self::TYPE_DURATION_S, self::TYPE_DURATION_MS);
            if (in_array($this->getType(), $metricTypes, $strict = true)) {
                $segment->setType(Segment::TYPE_METRIC);
            } else {
                $segment->setType(Segment::TYPE_DIMENSION);
            }
        }

        if (!$segment->getCategoryId() && $this->category) {
            $segment->setCategory($this->category);
        }

        if (!$segment->getName() && $this->nameSingular) {
            $segment->setName($this->nameSingular);
        }

        $sqlSegment = $segment->getSqlSegment();

        if (empty($sqlSegment) && !$segment->getUnionOfSegments()) {
            if (!empty($this->sqlSegment)) {
                $segment->setSqlSegment($this->sqlSegment);
            } elseif ($this->dbTableName && $this->columnName) {
                $segment->setSqlSegment($this->dbTableName . '.' . $this->columnName);
            } else {
                throw new Exception('Segment cannot be added because no sql segment is set');
            }
        }

        if (!$this->suggestedValuesCallback) {
            // we can generate effecient value callback for enums automatically
            $enum = $this->getEnumColumnValues();
            if (!empty($enum)) {
                $this->suggestedValuesCallback = function ($idSite, $maxValuesToReturn) use ($enum) {
                    $values = array_values($enum);
                    return array_slice($values, 0, $maxValuesToReturn);
                };
            }
        }

        if (!$this->acceptValues) {
            // we can generate accept values for enums automatically
            $enum = $this->getEnumColumnValues();
            if (!empty($enum)) {
                $enumValues = array_values($enum);
                $enumValues = array_slice($enumValues, 0, 20);
                $this->acceptValues = 'Eg. ' . implode(', ', $enumValues);
            };
        }

        if ($this->acceptValues && !$segment->getAcceptValues()) {
            $segment->setAcceptedValues($this->acceptValues);
        }

        if (!$this->sqlFilterValue && !$segment->getSqlFilter() && !$segment->getSqlFilterValue()) {
            // no sql filter configured, we try to configure automatically for enums
            $enum = $this->getEnumColumnValues();
            if (!empty($enum)) {
                $this->sqlFilterValue = function ($value, $sqlSegmentName) use ($enum) {
                    if (isset($enum[$value])) {
                        return $value;
                    }

                    $id = array_search($value, $enum);

                    if ($id === false) {
                        $id = array_search(strtolower(trim(urldecode($value))), $enum);

                        if ($id === false) {
                            throw new \Exception("Invalid '$sqlSegmentName' segment value $value");
                        }
                    }

                    return $id;
                };
            };
        }

        if ($this->suggestedValuesCallback && !$segment->getSuggestedValuesCallback()) {
            $segment->setSuggestedValuesCallback($this->suggestedValuesCallback);
        }

        if ($this->sqlFilterValue && !$segment->getSqlFilterValue()) {
            $segment->setSqlFilterValue($this->sqlFilterValue);
        }

        if ($this->sqlFilter && !$segment->getSqlFilter()) {
            $segment->setSqlFilter($this->sqlFilter);
        }

        if (!$this->allowAnonymous) {
            $segment->setRequiresAtLeastViewAccess(true);
        }

        $this->segments[] = $segment;
    }
1273315
public function addAll(Models $other)
    {
        if ($other->count() > 0) {
            $this->models->addAll($other->models);
        }

        return $this;
    }
1031358
def add_segments(self, segments):
        
        self.tracks.update([seg.track for seg in segments])
        self.segments.extend(segments)
1343918
public function append($segment)
    {
        $segments = is_array($segment) ? $segment : func_get_args();

        return $this->replicate(['path' => $this->path->copy()->extend($segments)]);
    }
992936
public function appendSegment($segment)
	{
		if (is_string($segment)) {
			$this->segments[] = $segment;
		} else {
			throw new \InvalidArgumentException(
				__METHOD__."() expects parameter one, segment, to be a string"
			);
		}
		
		return $this;
	}
295201
public function equals($other, $parts=['scheme', 'user', 'host', 'path'])
    {
        $other = $other instanceof UrlContract ? $other : new static($other);
        $parts = (array)$parts;

        foreach ($parts as $part) {
            if ($part == 'path') {
                continue;
            }
            if ($this->$part != $other->$part) {
                return false;
            }
        }

        if (!in_array('path', $parts)) {
            return true;
        }

        return $this->path->equals($other->path);
    }
803088
def put_subsegment(self, subsegment):
        
        entity = self.get_trace_entity()
        if not entity:
            log.warning("Active segment or subsegment not found. Discarded %s." % subsegment.name)
            return

        entity.add_subsegment(subsegment)
        self._local.entities.append(subsegment)
801474
public function addPageToSection($section = 'Other', $name, $uri, $priority = 0)
    {
        return $this->findSectionOrCreate($section)->addPage(new Page([
            'name' => $name,
            'url'  => $uri,
        ]), $priority);
    }
420261
public function offsetSet($offset, $segment)
	{
		if (is_null($offset)) {
			$this->segments[] = (string) $segment;
		} else {
			$this->segments[$offset] = (string) $segment;
		}
	}
1272053
public function updateSegment(
        $idSegment,
        $name,
        $definition,
        $autoArchive = '',
        $enableAllUsers = '',
        array $optional = []
    )
    {
        return $this->_request('SegmentEditor.update', [
            'idSegment' => $idSegment,
            'name' => $name,
            'definition' => $definition,
            'autoArchive' => $autoArchive,
            'enableAllUsers' => $enableAllUsers,
        ], $optional);
    }
543487
public void addSegment(Segment segment, boolean bStartNewPath) {
		mergeVertexDescription(segment.getDescription());
		if (segment.getType() == Type.Line) {
			Point point = new Point();
			if (bStartNewPath || isEmpty()) {
				segment.queryStart(point);
				startPath(point);
			}

			segment.queryEnd(point);
			lineTo(point);
		} else {
			throw GeometryException.GeometryInternalError();
		}
	}
511035
public function appendPathSegment($segment)
    {
        if (substr($this->path, -1) != static::PATH_SEGMENT_SEPARATOR) $this->path .= static::PATH_SEGMENT_SEPARATOR;
        if (substr($segment, 0, 1) == static::PATH_SEGMENT_SEPARATOR) $segment = substr($segment, 1);
        $this->path .= $segment;
        return $this;
    }