Look for two corners which point to the same point and removes one of them from the corner list
320350
void removeDuplicates( GrowQueue_I32 corners ) {
		// remove duplicates
		for (int i = 0; i < corners.size(); i++) {
			Point2D_I32 a = contour.get(corners.get(i));

			// start from the top so that removing a corner doesn't mess with the for loop
			for (int j = corners.size()-1; j > i; j--) {
				Point2D_I32 b = contour.get(corners.get(j));

				if( a.x == b.x && a.y == b.y ) {
					// this is still ok if j == 0 because it wrapped around.  'i' will now be > size
					corners.remove(j);
				}
			}
		}
	}
941185
function removeFromList(i, L, R) {
    R[L[i]] = R[i];
    L[R[i]] = L[i];
    R[i] = i;
    L[i] = i;
}
219393
private Point intersection(int x1, int y1, int x2, int y2, DesktopWindowRect rect) {
    Point
        bottom =
        intersection(x1, y1, x2, y2, rect.getX(), rect.getY(), rect.getX() + rect.getHeight(),
                     rect.getY());
    if (bottom != null) {
      return bottom;
    }

    Point
        right =
        intersection(x1, y1, x2, y2, rect.getX() + rect.getWidth(), rect.getY(),
                     rect.getX() + rect.getWidth(), rect.getY() + rect.getHeight());
    if (right != null) {
      return right;
    }

    Point
        top =
        intersection(x1, y1, x2, y2, rect.getX(), rect.getY() + rect.getHeight(),
                     rect.getX() + rect.getWidth(), rect.getY() + rect.getHeight());
    if (top != null) {
      return top;
    }

    Point
        left =
        intersection(x1, y1, x2, y2, rect.getX(), rect.getY(), rect.getX(),
                     rect.getY() + rect.getHeight());
    if (left != null) {
      return left;
    }

    return null;
  }
57338
def find_block_end(row, line_list, sentinal, direction=1):
    
    import re
    row_ = row
    line_ = line_list[row_]
    flag1 = row_ == 0 or row_ == len(line_list) - 1
    flag2 = re.match(sentinal, line_)
    if not (flag1 or flag2):
        while True:
            if (row_ == 0 or row_ == len(line_list) - 1):
                break
            line_ = line_list[row_]
            if re.match(sentinal, line_):
                break
            row_ += direction
    return row_
263749
function(obj) {
            var arr = this.map.get(obj.x, obj.y);
            var index = arr.indexOf(obj);
            arr.splice(index, 1);
            index = this.objects.indexOf(obj);
            this.objects.splice(index, 1);
            if(obj.onRemove){
                obj.onRemove();
            }
        }
782334
public int findSideIntersect(SquareNode n , LineSegment2D_F64 line , Point2D_F64 intersection, LineSegment2D_F64 storage ) {
		for (int j = 0,i=3; j < 4; i=j,j++) {
			storage.a = n.square.get(i);
			storage.b = n.square.get(j);

			if( Intersection2D_F64.intersection(line,storage,intersection) != null ) {
				return i;
			}
		}

		// bug but I won't throw an exception to stop it from blowing up a bunch
		return -1;
	}
848009
def find_close_value(self, LIST, value):
        '''
        
        '''
        diff = inf
        for a in LIST:
            if abs(value - a) < diff:
                diff = abs(value - a)
                result = a
        return(result)
1295574
def Minus(self, other):
    
    return Point(self.x - other.x,
                 self.y - other.y,
                 self.z - other.z)
539933
def delete(self, shape=None, part=None, point=None):
        """"""
        # shape, part, point
        if shape and part and point:
            del self._shapes[shape][part][point]
        # shape, part
        elif shape and part and not point:
            del self._shapes[shape][part]
        # shape
        elif shape and not part and not point:
            del self._shapes[shape]
        # point
        elif not shape and not part and point:
            for s in self._shapes:
                if s.shapeType == 1:
                    del self._shapes[point]
                else:
                    for part in s.parts:
                        del s[part][point]
        # part, point
        elif not shape and part and point:
            for s in self._shapes:
                del s[part][point]
        # part
        elif not shape and part and not point:
            for s in self._shapes:
                del s[part]
1322252
private Point2D intersect(List<Point2D> outline, Line2D line) {

        Point2D previousPoint = outline.get(outline.size() - 1);
        for (Point2D point : outline) {

            Line2D currentLine = new Line2D.Double(point.getX(), point.getY(), previousPoint.getX(),
                    previousPoint.getY());
            if (line.intersectsLine(currentLine)) {
                return lineLineIntersect(currentLine, line);
            }
            previousPoint = point;
        }
        return new Point2D.Double(line.getX1(), line.getY1());
    }
71014
def cut(self, a, b, bstjoin=False):
        
        if self.first_lookup[a] > self.last_lookup[b]:
            a, b = b, a

        o_a1 = self.first_lookup[a]
        o_a2 = self.last_lookup[a]
        o_b1 = self.first_lookup[b]
        o_b2 = self.last_lookup[b]
        assert o_a1 < o_b1
        # assert o_b1 < o_b2
        assert o_b2 < o_a2

        # splice out the inside contiguous range inplace
        inside, outside = self.tour_tree.splice_inplace(o_b1, o_b2 + 1)
        # Remove unneeded values
        outside = outside.splice_inplace(o_b1, o_a2 + 1)[1]

        other = EulerTourTree()
        other.tour_tree = inside
        # We can reuse these pointers without any modification
        other.first_lookup = self.first_lookup
        other.first_lookup = self.last_lookup
        # Should make an O(n) cleanup step at some point
        return other
131495
def intersect(self, r):
        """"""
        if not len(r) == 4:
            raise ValueError("bad sequ. length")
        self.x0, self.y0, self.x1, self.y1 = TOOLS._intersect_rect(self, r)
        return self
502777
def search_point(self, point, result):
        
        for k in self.s_center:
            if k.begin <= point < k.end:
                result.add(k)
        if point < self.x_center and self[0]:
            return self[0].search_point(point, result)
        elif point > self.x_center and self[1]:
            return self[1].search_point(point, result)
        return result
53375
function fixAngleOverlap(list) {
    var firstItem = list[0];
    var lastItem = list[list.length - 1];
    if (firstItem
        && lastItem
        && Math.abs(Math.abs(firstItem.coord - lastItem.coord) - 360) < 1e-4
    ) {
        list.pop();
    }
}
851718
public void process(List<ChessboardCorner> corners ) {
		this.corners = corners;

		// reset internal data structures
		vertexes.reset();
		edges.reset();
		clusters.reset();

		// Create a vertex for each corner
		for (int idx = 0; idx < corners.size(); idx++) {
			Vertex v = vertexes.grow();
			v.reset();
			v.index = idx;
		}

		// Initialize nearest-neighbor search.
		nn.setPoints(corners,true);

		// Connect corners to each other based on relative distance on orientation
		for (int i = 0; i < corners.size(); i++) {
			findVertexNeighbors(vertexes.get(i),corners);
		}

		// If more than one vertex's are near each other, pick one and remove the others
		handleAmbiguousVertexes(corners);
//		printDualGraph();

		// Prune connections which are not mutual
		for (int i = 0; i < vertexes.size; i++) {
			Vertex v = vertexes.get(i);
			v.pruneNonMutal(EdgeType.PARALLEL);
			v.pruneNonMutal(EdgeType.PERPENDICULAR);
		}
//		printDualGraph();

		// Select the final 2 to 4 connections from perpendicular set
		// each pair of adjacent perpendicular edge needs to have a matching parallel edge between them
		// Use each perpendicular edge as a seed and select the best one
		for (int idx = 0; idx < vertexes.size(); idx++) {
			selectConnections(vertexes.get(idx));
		}
//		printConnectionGraph();

		// Connects must be mutual to be accepted. Keep track of vertexes which were modified
		dirtyVertexes.clear();
		for (int i = 0; i < vertexes.size; i++) {
			Vertex v = vertexes.get(i);
			int before = v.connections.size();
			v.pruneNonMutal(EdgeType.CONNECTION);
			if( before != v.connections.size() ) {
				dirtyVertexes.add(v);
				v.marked = true;
			}
		}

//		printConnectionGraph();
		// attempt to recover from poorly made decisions in the past from the greedy algorithm
		repairVertexes();

		// Prune non-mutual edges again. Only need to consider dirty edges since it makes sure that the new
		// set of connections is a super set of the old
		for (int i = 0; i < dirtyVertexes.size(); i++) {
			dirtyVertexes.get(i).pruneNonMutal(EdgeType.CONNECTION);
			dirtyVertexes.get(i).marked = false;
		}

		// Final clean up to return just valid grids
		disconnectInvalidVertices();

		// Name says it all
		convertToOutput(corners);
	}
1089201
private void removePoint(Point point, Collidable collidable, Map<Point, Set<Collidable>> elements, Integer group)
    {
        final Set<Collidable> points = elements.get(point);
        points.remove(collidable);
        if (points.isEmpty())
        {
            elements.remove(point);
        }
        if (elements.isEmpty())
        {
            collidables.remove(group);
        }
    }
359717
def search_overlap(self, point_list):
        
        result = set()
        for j in point_list:
            self.search_point(j, result)
        return result