Starts a new subpath that begins in the same point as the start and end
point of the previous one.
507261
public function closePath() 
    {
        $pathsCount = count($this->paths);
        if ($pathsCount > 0) {
            $path = $this->paths[$pathsCount - 1];
            $pathCount = count($path);
            
            if ($pathCount > 2) {
                // Close path
                if ($path[0] != $path[$pathCount - 2] ||
                    $path[1] != $path[$pathCount - 1]
                ) {
                    $path[] = $path[0];
                    $path[] = $path[1];
                }

                // Begin a new path
                $this->paths[] = array($path[0], $path[1]);
            }
        }
    }
521973
def find_path(self, start, end, grid):
        
        start.g = 0
        start.f = 0
        return super(AStarFinder, self).find_path(start, end, grid)
617367
function middleInside (data, start, a, b) {
  var node = start,
    inside = false,
    px = (data[a] + data[b]) / 2,
    py = (data[a + 1] + data[b + 1]) / 2
  do {
    var p1 = node.i,
      p2 = node.next.i

    if (((data[p1 + 1] > py) !== (data[p2 + 1] > py)) &&
      (px < (data[p2] - data[p1]) * (py - data[p1 + 1]) / (data[p2 + 1] - data[p1 + 1]) + data[p1])) {
      inside = !inside
    }

    node = node.next
  } while (node !== start)

  return inside
}
1133082
def in_single_path(self):
        
        return len(self.successor) == 1 and not self.successor[0].in_or_out and \
               len(self.precedence) == 1 and len(self.precedence[0].successor) <= 1
158983
void movePath(int geom, int before_path, int path_to_move) {
		if (path_to_move == -1)
			throw new IllegalArgumentException();

		if (before_path == path_to_move)
			return;

		int next = getNextPath(path_to_move);
		int prev = getPrevPath(path_to_move);
		int geom_src = getGeometryFromPath(path_to_move);
		if (prev == -1) {
			setFirstPath_(geom_src, next);
		} else {
			setNextPath_(prev, next);
		}

		if (next == -1) {
			setLastPath_(geom_src, prev);
		} else {
			setPrevPath_(next, prev);
		}

		setGeometryVertexCount_(geom_src, getPointCount(geom_src)
				- getPathSize(path_to_move));
		setGeometryPathCount_(geom_src, getPathCount(geom_src) - 1);

		if (before_path == -1)
			prev = getLastPath(geom);
		else
			prev = getPrevPath(before_path);

		setPrevPath_(path_to_move, prev);
		setNextPath_(path_to_move, before_path);
		if (before_path == -1)
			setLastPath_(geom, path_to_move);
		else
			setPrevPath_(before_path, path_to_move);
		if (prev == -1)
			setFirstPath_(geom, path_to_move);
		else
			setNextPath_(prev, path_to_move);
		setGeometryVertexCount_(geom, getPointCount(geom)
				+ getPathSize(path_to_move));
		setGeometryPathCount_(geom, getPathCount(geom) + 1);
		setPathGeometry_(path_to_move, geom);
	}
1102589
function buildPath(lines, jumpSize, jumpType) {

        var path = new g.Path();
        var segment;

        // first move to the start of a first line
        segment = g.Path.createSegment('M', lines[0].start);
        path.appendSegment(segment);

        // make a paths from lines
        joint.util.toArray(lines).forEach(function(line, index) {

            if (line.isJump) {
                var angle, diff;

                var control1, control2;

                if (jumpType === 'arc') { // approximates semicircle with 2 curves
                    angle = -90;
                    // determine rotation of arc based on difference between points
                    diff = line.start.difference(line.end);
                    // make sure the arc always points up (or right)
                    var xAxisRotate = Number((diff.x < 0) || (diff.x === 0 && diff.y < 0));
                    if (xAxisRotate) angle += 180;

                    var midpoint = line.midpoint();
                    var centerLine = new g.Line(midpoint, line.end).rotate(midpoint, angle);

                    var halfLine;

                    // first half
                    halfLine = new g.Line(line.start, midpoint);

                    control1 = halfLine.pointAt(2 / 3).rotate(line.start, angle);
                    control2 = centerLine.pointAt(1 / 3).rotate(centerLine.end, -angle);

                    segment = g.Path.createSegment('C', control1, control2, centerLine.end);
                    path.appendSegment(segment);

                    // second half
                    halfLine = new g.Line(midpoint, line.end);

                    control1 = centerLine.pointAt(1 / 3).rotate(centerLine.end, angle);
                    control2 = halfLine.pointAt(1 / 3).rotate(line.end, -angle);

                    segment = g.Path.createSegment('C', control1, control2, line.end);
                    path.appendSegment(segment);

                } else if (jumpType === 'gap') {
                    segment = g.Path.createSegment('M', line.end);
                    path.appendSegment(segment);

                } else if (jumpType === 'cubic') { // approximates semicircle with 1 curve
                    angle = line.start.theta(line.end);

                    var xOffset = jumpSize * 0.6;
                    var yOffset = jumpSize * 1.35;

                    // determine rotation of arc based on difference between points
                    diff = line.start.difference(line.end);
                    // make sure the arc always points up (or right)
                    xAxisRotate = Number((diff.x < 0) || (diff.x === 0 && diff.y < 0));
                    if (xAxisRotate) yOffset *= -1;

                    control1 = g.Point(line.start.x + xOffset, line.start.y + yOffset).rotate(line.start, angle);
                    control2 = g.Point(line.end.x - xOffset, line.end.y + yOffset).rotate(line.end, angle);

                    segment = g.Path.createSegment('C', control1, control2, line.end);
                    path.appendSegment(segment);
                }

            } else {
                segment = g.Path.createSegment('L', line.end);
                path.appendSegment(segment);
            }
        });

        return path;
    }
961488
private void firstWalk(TreeNode v, TreeNode leftSibling) {
		if (tree.isLeaf(v)) {
			// No need to set prelim(v) to 0 as the getter takes care of this.

			TreeNode w = leftSibling;
			if (w != null) {
				// v has left sibling

				setPrelim(v, getPrelim(w) + getDistance(v, w));
			}

		} else {
			// v is not a leaf

			TreeNode defaultAncestor = tree.getFirstChild(v);
			TreeNode previousChild = null;
			for (TreeNode w : tree.getChildren(v)) {
				firstWalk(w, previousChild);
				defaultAncestor = apportion(w, defaultAncestor, previousChild,
						v);
				previousChild = w;
			}
			executeShifts(v);
			double midpoint = (getPrelim(tree.getFirstChild(v)) + getPrelim(tree
					.getLastChild(v))) / 2.0;
			TreeNode w = leftSibling;
			if (w != null) {
				// v has left sibling

				setPrelim(v, getPrelim(w) + getDistance(v, w));
				setMod(v, getPrelim(v) - midpoint);

			} else {
				// v has no left sibling

				setPrelim(v, midpoint);
			}
		}
	}
1033173
private static String mergePaths(String path1, String path2)
  {
    return path1 + (path1.endsWith(Path.SEPARATOR) ? "" : Path.SEPARATOR) + path2;
  }
1046572
function subEndpoints(prefix, suffixes) {
  return function () {
    Array.prototype.forEach.call(suffixes, function (suffix) {
      var path = prefix + suffix;
      createEndpointFromPath(path);
      console.log('  registered path %s', path);
    });
  }
}
886638
public boolean startsWith(UnixPath other) {
    UnixPath me = removeTrailingSeparator();
    other = other.removeTrailingSeparator();
    if (other.path.length() > me.path.length()) {
      return false;
    } else if (me.isAbsolute() != other.isAbsolute()) {
      return false;
    } else if (!me.path.isEmpty() && other.path.isEmpty()) {
      return false;
    }
    return startsWith(split(), other.split());
  }
1186183
def relative_path_from(start, dest)
      start, dest = Pathname.new(start), Pathname.new(dest)
      start = start.dirname unless start.directory?
      dest.relative_path_from(start).to_s
    end
582741
@Pure
	@SuppressWarnings("checkstyle:cyclomaticcomplexity")
	public PT getStartingPointFor(int index) {
		if ((index < 1) || (this.segmentList.size() <= 1)) {
			if (this.startingPoint != null) {
				return this.startingPoint;
			}
		} else {
			int idx = index;
			ST currentSegment = this.segmentList.get(idx);
			ST previousSegment = this.segmentList.get(--idx);

			// Because the two segments are the same
			// we must go deeper in the path elements
			// to detect the right segment
			int count = 0;
			while ((previousSegment != null) && (previousSegment.equals(currentSegment))) {
				currentSegment = previousSegment;
				idx--;
				previousSegment = (idx >= 0) ? this.segmentList.get(idx) : null;
				count++;
			}

			if (count > 0) {
				PT sp = null;
				if (previousSegment != null) {
					final PT p1 = currentSegment.getBeginPoint();
					final PT p2 = currentSegment.getEndPoint();
					final PT p3 = previousSegment.getBeginPoint();
					final PT p4 = previousSegment.getEndPoint();

					assert p1 != null && p2 != null && p3 != null && p4 != null;
					if (p1.equals(p3) || p1.equals(p4)) {
						sp = p1;
					} else if (p2.equals(p3) || p2.equals(p4)) {
						sp = p2;
					}

				} else {
					sp = this.startingPoint;
				}
				if (sp != null) {
					return ((count % 2) == 0) ? sp : currentSegment.getOtherSidePoint(sp);
				}

			} else if ((currentSegment != null) && (previousSegment != null)) {
				// if the two segments are different
				// it is simple to detect the
				// common point
				final PT p1 = currentSegment.getBeginPoint();
				final PT p2 = currentSegment.getEndPoint();
				final PT p3 = previousSegment.getBeginPoint();
				final PT p4 = previousSegment.getEndPoint();

				assert p1 != null && p2 != null && p3 != null && p4 != null;
				if (p1.equals(p3) || p1.equals(p4)) {
					return p1;
				}
				if (p2.equals(p3) || p2.equals(p4)) {
					return p2;
				}
			}
		}

		return null;
	}
495663
public UnixPath subpath(int beginIndex, int endIndex) {
    if (path.isEmpty() && beginIndex == 0 && endIndex == 1) {
      return this;
    }
    checkArgument(beginIndex >= 0 && endIndex > beginIndex);
    List<String> subList;
    try {
      subList = getParts().subList(beginIndex, endIndex);
    } catch (IndexOutOfBoundsException e) {
      throw new IllegalArgumentException();
    }
    return new UnixPath(permitEmptyComponents, JOINER.join(subList));
  }
1307775
def cwd(self, new_path):
        ''''''
        old_cwd = self._cwd
        self._cwd = new_path
        return old_cwd
352585
public boolean startsWith(Path other) {
		if (isAbsolute() != other.isAbsolute())
			return false;
		List<String> otherSegments = other.getSegments();
		List<String> thisSegments = getSegments();
		int otherSegmentSize = otherSegments.size();
		int thisSegmentSize = thisSegments.size();
		if (otherSegmentSize > thisSegmentSize) {
			return false;
		}
		for (int i = 0; i < otherSegmentSize; i++) {
			String otherSeg = otherSegments.get(i);
			String thisSeg = thisSegments.get(i);
			if (!otherSeg.equals(thisSeg))
				return false;
		}
		return true;
	}
476290
function createEndpointFromPath(path, query, filePath) {
  filePath = filePath || path;
  return createEndpointFromObject(path, query, getJSON(filePath));
}
685370
public void startPath(Point point) {
		if (point.isEmpty())
			throw new IllegalArgumentException();// throw new
													// IllegalArgumentException();

		mergeVertexDescription(point.getDescription());
		_initPathStartPoint();
		point.copyTo(m_moveToPoint);

		// TODO check MultiPathImpl.cpp comment
		// "//the description will be merged later"
		// assignVertexDescription(m_moveToPoint.getDescription());
		m_bPathStarted = true;
	}