Merges lines together if the common corner is close to a common line
@return true the list being changed
553635
protected boolean mergeSegments() {

		// See if merging will cause a degenerate case
		if( splits.size() <= 3 )
			return false;

		boolean change = false;
		work.reset();

		for( int i = 0; i < splits.size; i++ ) {
			int start = splits.data[i];
			int end = splits.data[(i+2)%splits.size];

			if( selectSplitOffset(start,circularDistance(start,end)) < 0 ) {
				// merge the two lines by not adding it
				change = true;
			} else {
				work.add(splits.data[(i + 1)%splits.size]);
			}

		}

		// swap the two lists
		GrowQueue_I32 tmp = work;
		work = splits;
		splits = tmp;

		return change;
	}
142118
function mergedCompilerMsgLists(list1, list2) {
  var list = [];

  list1 = list1 || [];
  list2 = list2 || [];

  function lessThan(e1, e2) {
    if (e1.lineno < e2.lineno)
      return true;
    return e1.lineno === e2.lineno && e1.charno < e2.charno;
  }

  var i1 = 0, i2 = 0;
  while (true) {
    if (i1 >= list1.length)
      return list.concat(list2.slice(i2));
    if (i2 >= list2.length)
      return list.concat(list1.slice(i1));
    if (lessThan(list1[i1], list2[i2]))
      list.push(list1[i1++]);
    else
      list.push(list2[i2++]);
  }
}
95193
protected boolean isExecuteMerge()
    {
        long elapsedTimeMs = getCurrentTime() - this.previousMergeTime;
        if (elapsedTimeMs >= TimeUnit.SECONDS.toMillis(this.mergeInterval))
        {
            return true;
        }

        return false;
    }
412365
private boolean intersectsOtherTexture(RegionData data) {
        final Rectangle rec1 = new Rectangle(data.x, data.y, data.width, data.height);
        for (RegionData other : regions.values()) {
            final Rectangle rec2 = new Rectangle(other.x, other.y, other.width, other.height);
            if (rec1.intersects(rec2)) {
                return true;
            }
        }
        return false;
    }
340648
public static boolean removeMergedRange(final Sheet sheet, final CellRangeAddress mergedRange) {
        ArgUtils.notNull(sheet, "sheet");
        ArgUtils.notNull(mergedRange, "mergedRange");

        final String mergedAddress = mergedRange.formatAsString(sheet.getSheetName(), true);

        final int num = sheet.getNumMergedRegions();
        for(int i=0; i < num; i ++) {
            final CellRangeAddress range = sheet.getMergedRegion(i);
            final String rangeAddress = range.formatAsString(sheet.getSheetName(), true);
            if(rangeAddress.equals(mergedAddress)) {
                sheet.removeMergedRegion(i);
                return true;
            }
        }

        return false;
    }
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());
    }
750061
public boolean isSimple() {
		if (isEmpty()) {
			return true;
		}

		if (getNumGeometries() > 1) {
			for (int n = 0; n < getNumGeometries(); n++) {
				if (!getGeometryN(n).isSimple()) {
					return false;
				}
			}
		} else {
			final Coordinate[] coords1 = getCoordinates();
			final Coordinate[] coords2 = getCoordinates();
			if (coords1.length > 1 && coords2.length > 1) {
				for (int i = 0; i < coords2.length - 1; i++) {
					for (int j = 0; j < coords1.length - 1; j++) {
						if (Mathlib.lineIntersects(coords2[i], coords2[i + 1], coords1[j], coords1[j + 1])) {
							return false;
						}
					}
				}
			} else {
				// TODO implement me
			}
		}

		return true;
	}
503902
public boolean removeLeadingEmptyLines()
    {
        boolean wasEmpty = false;
        Line line = this.lines;
        while (line != null && line.isEmpty)
        {
            this.removeLine(line);
            line = this.lines;
            wasEmpty = true;
        }
        return wasEmpty;
    }
973749
private void directMergeRows(MergeRow mergeRowAnn, int fromRow, int lastRow, int col) {
        fixCellValue(mergeRowAnn, fromRow, col);

        if (lastRow < fromRow) return;
        if (lastRow == fromRow && mergeRowAnn.moreCols() == 0) return;

        val c1 = new CellRangeAddress(fromRow, lastRow, col, col + mergeRowAnn.moreCols());
        sheet.addMergedRegion(c1);
    }
110121
boolean alignEdges(FastQueue<Node> corners) {
		open.clear();
		open.add( corners.get(0) );

		marked.resize(corners.size);
		marked.fill(false);

		marked.set(corners.get(0).index,true);

		while( !open.isEmpty() ) {
			Node na = open.remove();

			// examine each neighbor and see the neighbor is correctly aligned
			for (int i = 0; i < 4; i++) {
				if( na.edges[i] == null ) {
					continue;
				}
				// Compute which index should be an edge pointing back at 'na'
				int j = (i+2)%4;

				Node nb = na.edges[i];

				// Sanity check. If it has been marked it should be correctly aligned
				if( marked.get(nb.index) ) {
					if( nb.edges[j] != na ) {
						if( verbose != null ) verbose.println("BUG! node "+nb.index+" has been processed and edge "+j+" doesn't point to node "+na.index);
						return false;
					}
					continue;
				}

				// Rotate edges
				boolean failed = true;
				for (int attempt = 0; attempt < 4; attempt++) {
					if( nb.edges[j] != na ) {
						nb.rotateEdgesDown();
					} else {
						failed = false;
						break;
					}
				}
				if( failed ) {
					if( verbose != null ) verbose.println("BUG! Can't align edges");
					return false;
				}
				marked.set(nb.index,true);
				open.add(nb);
			}
		}
		return true;
	}
229090
private void mergeSameDay(LinkedList<TimephasedCost> list)
   {
      LinkedList<TimephasedCost> result = new LinkedList<TimephasedCost>();

      TimephasedCost previousAssignment = null;
      for (TimephasedCost assignment : list)
      {
         if (previousAssignment == null)
         {
            assignment.setAmountPerDay(assignment.getTotalAmount());
            result.add(assignment);
         }
         else
         {
            Date previousAssignmentStart = previousAssignment.getStart();
            Date previousAssignmentStartDay = DateHelper.getDayStartDate(previousAssignmentStart);
            Date assignmentStart = assignment.getStart();
            Date assignmentStartDay = DateHelper.getDayStartDate(assignmentStart);

            if (previousAssignmentStartDay.getTime() == assignmentStartDay.getTime())
            {
               result.removeLast();

               double cost = previousAssignment.getTotalAmount().doubleValue();
               cost += assignment.getTotalAmount().doubleValue();

               TimephasedCost merged = new TimephasedCost();
               merged.setStart(previousAssignment.getStart());
               merged.setFinish(assignment.getFinish());
               merged.setTotalAmount(Double.valueOf(cost));
               assignment = merged;
            }

            assignment.setAmountPerDay(assignment.getTotalAmount());
            result.add(assignment);
         }

         previousAssignment = assignment;
      }

      list.clear();
      list.addAll(result);
   }
876986
@Override
    public boolean hasOuterJoin() {
        assert(m_leftNode != null && m_rightNode != null);
        return m_joinType != JoinType.INNER ||
                m_leftNode.hasOuterJoin() || m_rightNode.hasOuterJoin();
    }
680016
public static <T> List<T> mergeLists(List<T> list1, List<T> list2) {
        List<T> merged = new LinkedList<T>();
        if (list1 != null) {
            merged.addAll(list1);
        }
        if (list2 != null) {
            merged.addAll(list2);
        }
        return merged;
    }
200386
private function moveToNextLine(): bool
    {
        if ($this->currentLineNb >= \count($this->lines) - 1) {
            return false;
        }

        $this->currentLine = $this->lines[++$this->currentLineNb];

        return true;
    }
1017127
def _perform_merge(self, other):
        
        if len(other.value) > len(self.value):
            self.value = other.value[:]
        return True
1332109
void cleanupMerge(LinkedList<Change> diffs) {
        diffs.add(new Change(Operation.EQUAL, ""));  // Add a dummy entry at the end.
        ListIterator<Change> pointer = diffs.listIterator();
        int count_delete = 0;
        int count_insert = 0;
        String text_delete = "";
        String text_insert = "";
        Change thisDiff = pointer.next();
        Change prevEqual = null;
        int commonlength;
        while (thisDiff != null) {
            switch (thisDiff.operation) {
                case INSERT:
                    count_insert++;
                    text_insert += thisDiff.text;
                    prevEqual = null;
                    break;
                case DELETE:
                    count_delete++;
                    text_delete += thisDiff.text;
                    prevEqual = null;
                    break;
                case EQUAL:
                    if (count_delete + count_insert > 1) {
                        boolean both_types = count_delete != 0 && count_insert != 0;
                        // Delete the offending records.
                        pointer.previous();  // Reverse direction.
                        while (count_delete-- > 0) {
                            pointer.previous();
                            pointer.remove();
                        }
                        while (count_insert-- > 0) {
                            pointer.previous();
                            pointer.remove();
                        }
                        if (both_types) {
                            // Factor out any common prefixies.
                            commonlength = commonPrefix(text_insert, text_delete);
                            if (commonlength != 0) {
                                if (pointer.hasPrevious()) {
                                    thisDiff = pointer.previous();
                                    assert thisDiff.operation == Operation.EQUAL
                                            : "Previous diff should have been an equality.";
                                    thisDiff.text += text_insert.substring(0, commonlength);
                                    pointer.next();
                                } else {
                                    pointer.add(new Change(Operation.EQUAL,
                                                           text_insert.substring(0, commonlength)));
                                }
                                text_insert = text_insert.substring(commonlength);
                                text_delete = text_delete.substring(commonlength);
                            }
                            // Factor out any common suffixies.
                            commonlength = commonSuffix(text_insert, text_delete);
                            if (commonlength != 0) {
                                thisDiff = pointer.next();
                                thisDiff.text = text_insert.substring(text_insert.length()
                                                                      - commonlength) + thisDiff.text;
                                text_insert = text_insert.substring(0, text_insert.length()
                                                                       - commonlength);
                                text_delete = text_delete.substring(0, text_delete.length()
                                                                       - commonlength);
                                pointer.previous();
                            }
                        }
                        // Insert the merged records.
                        if (text_delete.length() != 0) {
                            pointer.add(new Change(Operation.DELETE, text_delete));
                        }
                        if (text_insert.length() != 0) {
                            pointer.add(new Change(Operation.INSERT, text_insert));
                        }
                        // Step forward to the equality.
                        thisDiff = pointer.hasNext() ? pointer.next() : null;
                    } else if (prevEqual != null) {
                        // Merge this equality with the previous one.
                        prevEqual.text += thisDiff.text;
                        pointer.remove();
                        thisDiff = pointer.previous();
                        pointer.next();  // Forward direction
                    }
                    count_insert = 0;
                    count_delete = 0;
                    text_delete = "";
                    text_insert = "";
                    prevEqual = thisDiff;
                    break;
            }
            thisDiff = pointer.hasNext() ? pointer.next() : null;
        }
        if (diffs.getLast().text.length() == 0) {
            diffs.removeLast();  // Remove the dummy entry at the end.
        }

    /*
     * Second pass: look for single edits surrounded on both sides by equalities
     * which can be shifted sideways to eliminate an equality.
     * e.g: A<ins>BA</ins>C -> <ins>AB</ins>AC
     */
        boolean changes = false;
        // Create a new iterator at the start.
        // (As opposed to walking the current one back.)
        pointer = diffs.listIterator();
        Change prevDiff = pointer.hasNext() ? pointer.next() : null;
        thisDiff = pointer.hasNext() ? pointer.next() : null;
        Change nextDiff = pointer.hasNext() ? pointer.next() : null;
        // Intentionally ignore the first and last element (don't need checking).
        while (nextDiff != null) {
            if (prevDiff.operation == Operation.EQUAL &&
                nextDiff.operation == Operation.EQUAL) {
                // This is a single edit surrounded by equalities.
                if (thisDiff.text.endsWith(prevDiff.text)) {
                    // Shift the edit over the previous equality.
                    thisDiff.text = prevDiff.text
                                    + thisDiff.text.substring(0, thisDiff.text.length()
                                                                 - prevDiff.text.length());
                    nextDiff.text = prevDiff.text + nextDiff.text;
                    pointer.previous(); // Walk past nextDiff.
                    pointer.previous(); // Walk past thisDiff.
                    pointer.previous(); // Walk past prevDiff.
                    pointer.remove(); // Delete prevDiff.
                    pointer.next(); // Walk past thisDiff.
                    thisDiff = pointer.next(); // Walk past nextDiff.
                    nextDiff = pointer.hasNext() ? pointer.next() : null;
                    changes = true;
                } else if (thisDiff.text.startsWith(nextDiff.text)) {
                    // Shift the edit over the next equality.
                    prevDiff.text += nextDiff.text;
                    thisDiff.text = thisDiff.text.substring(nextDiff.text.length())
                                    + nextDiff.text;
                    pointer.remove(); // Delete nextDiff.
                    nextDiff = pointer.hasNext() ? pointer.next() : null;
                    changes = true;
                }
            }
            prevDiff = thisDiff;
            thisDiff = nextDiff;
            nextDiff = pointer.hasNext() ? pointer.next() : null;
        }
        // If shifts were made, the diff needs reordering and another shift sweep.
        if (changes) {
            cleanupMerge(diffs);
        }
    }
464304
function mergeListSiblings( listNode )
	{
		var mergeSibling;
		( mergeSibling = function( rtl )
		{
			var sibling = listNode[ rtl ? 'getPrevious' : 'getNext' ]( nonEmpty );
			if ( sibling &&
			     sibling.type == CKEDITOR.NODE_ELEMENT &&
			     sibling.is( listNode.getName() ) )
			{
				// Move children order by merge direction.(#3820)
				mergeChildren( listNode, sibling, null, !rtl );

				listNode.remove();
				listNode = sibling;
			}
		} )();
		mergeSibling( 1 );
	}