Merge 2 lists of min cell name components.

@param minColumnNames lhs
@param candidates rhs
@param comparator comparator to use
@return a list with smallest column names according to (sub)comparator
17117
public static List<ByteBuffer> mergeMin(List<ByteBuffer> minColumnNames, List<ByteBuffer> candidates, CellNameType comparator)
    {
        if (minColumnNames.isEmpty())
            return minimalBuffersFor(candidates);

        if (candidates.isEmpty())
            return minColumnNames;

        List<ByteBuffer> biggest = minColumnNames.size() > candidates.size() ? minColumnNames : candidates;
        List<ByteBuffer> smallest = minColumnNames.size() > candidates.size() ? candidates : minColumnNames;

        // We want to always copy the smallest list, and maybeGrow does it only if it's actually smaller
        List<ByteBuffer> retList = smallest.size() == biggest.size()
                                 ? new ArrayList<>(smallest)
                                 : maybeGrow(smallest, biggest.size());

        for (int i = 0; i < biggest.size(); i++)
            retList.set(i, minimalBufferFor(min(retList.get(i), biggest.get(i), comparator.subtype(i))));

        return retList;
    }
807649
public static String getCoalesceColumnNames(String columnOrColumnList) {
    if (Strings.isNullOrEmpty(columnOrColumnList)) {
      return null;
    }
    if (columnOrColumnList.contains(",")) {
      return "COALESCE(" + columnOrColumnList + ")";
    }
    return columnOrColumnList;
  }
1355306
private void mergeCols(ExcelRows excelRowsAnn, Cell templateCell, int itemSize) {
        val tmplRowIndexRef = templateCell.getRowIndex() + 1;
        for (val mergeColAnn : excelRowsAnn.mergeCols()) {
            val from = PoiUtil.findCell(sheet, mergeColAnn.fromColRef() + tmplRowIndexRef);
            val to = PoiUtil.findCell(sheet, mergeColAnn.toColRef() + tmplRowIndexRef);

            val fromRow = from.getRowIndex();
            val fromCol = from.getColumnIndex();
            val toCol = to.getColumnIndex();

            for (int i = fromRow; i < fromRow + itemSize; ++i) {
                sheet.addMergedRegion(new CellRangeAddress(i, i, fromCol, toCol));
            }
        }
    }
62550
private Entry mergeLists(Entry a, Entry b) {
        if (a == null) return b;
        if (b == null) return a;

        // splice the two circular lists together like a Mobius strip
        final Entry aOldNext = a.next;
        a.next = b.next;
        a.next.previous = a;
        b.next = aOldNext;
        b.next.previous = b;

        return comparator.compare(a.priority, b.priority) < 0 ? a : b;
    }
905416
private void sameValueMergeRows(MergeRow mergeRowAnn, int itemSize, Cell fromCell) {
        String lastValue = PoiUtil.getCellStringValue(fromCell);
        int preRow = fromCell.getRowIndex();
        val col = fromCell.getColumnIndex();
        int i = preRow + 1;

        for (final int ii = preRow + itemSize; i < ii; ++i) {
            val cell = sheet.getRow(i).getCell(col);
            val cellValue = PoiUtil.getCellStringValue(cell);
            if (StringUtils.equals(cellValue, lastValue)) continue;

            directMergeRows(mergeRowAnn, preRow, i - 1, col);
            lastValue = cellValue;
            preRow = i;
        }

        directMergeRows(mergeRowAnn, preRow, i - 1, col);
    }
277217
def sampleCellsWithinColumns(numCellPairs, cellsPerColumn, numColumns, seed=42):
  
  np.random.seed(seed)
  cellPairs = []
  for i in range(numCellPairs):
    randCol = np.random.randint(numColumns)
    randCells = np.random.choice(np.arange(cellsPerColumn), (2, ), replace=False)

    cellsPair = randCol * cellsPerColumn + randCells
    cellPairs.append(cellsPair)
  return cellPairs
490882
public static List<Range> union(List<Range> ranges){
        ranges = new ArrayList<Range>(ranges);
        Collections.sort(ranges, new Comparator<Range>(){
            @Override
            public int compare(Range r1, Range r2){
                return r1.min-r2.min;
            }
        });
        List<Range> union = new ArrayList<Range>();
        for(Range r: ranges){
            if(union.isEmpty())
                union.add(r);
            else
                CollectionUtil.addAll(union, union.remove(union.size() - 1).union(r));
        }
        return union;
    }
86083
public Table sortDescendingOn(String... columnNames) {
        Sort key = getSort(columnNames);
        return sortOn(key);
    }
714416
public static Writable min(JavaRDD<List<Writable>> allData, String columnName, Schema schema){
        int columnIdx = schema.getIndexOfColumn(columnName);
        JavaRDD<Writable> col = allData.map(new SelectColumnFunction(columnIdx));
        return col.min(Comparators.forType(schema.getType(columnName).getWritableType()));
    }
798425
public static List<ColumnDefinition> fromSchema(UntypedResultSet serializedColumns, String ksName, String cfName, AbstractType<?> rawComparator, boolean isSuper)
    {
        List<ColumnDefinition> cds = new ArrayList<>();
        for (UntypedResultSet.Row row : serializedColumns)
        {
            Kind kind = row.has(KIND)
                      ? Kind.deserialize(row.getString(KIND))
                      : Kind.REGULAR;

            Integer componentIndex = null;
            if (row.has(COMPONENT_INDEX))
                componentIndex = row.getInt(COMPONENT_INDEX);
            else if (kind == Kind.CLUSTERING_COLUMN && isSuper)
                componentIndex = 1; // A ColumnDefinition for super columns applies to the column component

            // Note: we save the column name as string, but we should not assume that it is an UTF8 name, we
            // we need to use the comparator fromString method
            AbstractType<?> comparator = getComponentComparator(rawComparator, componentIndex, kind);
            ColumnIdentifier name = new ColumnIdentifier(comparator.fromString(row.getString(COLUMN_NAME)), comparator);

            AbstractType<?> validator;
            try
            {
                validator = TypeParser.parse(row.getString(TYPE));
            }
            catch (RequestValidationException e)
            {
                throw new RuntimeException(e);
            }

            IndexType indexType = null;
            if (row.has(INDEX_TYPE))
                indexType = IndexType.valueOf(row.getString(INDEX_TYPE));

            Map<String, String> indexOptions = null;
            if (row.has(INDEX_OPTIONS))
                indexOptions = FBUtilities.fromJsonMap(row.getString(INDEX_OPTIONS));

            String indexName = null;
            if (row.has(INDEX_NAME))
                indexName = row.getString(INDEX_NAME);

            cds.add(new ColumnDefinition(ksName, cfName, name, validator, indexType, indexOptions, indexName, componentIndex, kind));
        }

        return cds;
    }
815345
def _getCellsWithFewestSegments(self, columns):
    
    candidateCells = np2.getAllCellsInColumns(columns, self.cellsPerColumn)

    # Arrange the segment counts into one row per minicolumn.
    segmentCounts = np.reshape(
      self.basalConnections.getSegmentCounts(candidateCells) +
      self.apicalConnections.getSegmentCounts(candidateCells),
      newshape=(len(columns),
                self.cellsPerColumn))

    # Filter to just the cells that are tied for fewest in their minicolumn.
    minSegmentCounts = np.amin(segmentCounts, axis=1, keepdims=True)
    candidateCells = candidateCells[np.flatnonzero(segmentCounts ==
                                                   minSegmentCounts)]

    # Filter to one cell per column, choosing randomly from the minimums.
    # To do the random choice, add a random offset to each index in-place, using
    # casting to floor the result.
    (_,
     onePerColumnFilter,
     numCandidatesInColumns) = np.unique(candidateCells / self.cellsPerColumn,
                                         return_index=True, return_counts=True)

    offsetPercents = np.empty(len(columns), dtype="float32")
    self.rng.initializeReal32Array(offsetPercents)

    np.add(onePerColumnFilter,
           offsetPercents*numCandidatesInColumns,
           out=onePerColumnFilter,
           casting="unsafe")

    return candidateCells[onePerColumnFilter]
268922
public static CellRangeAddress mergeCells(final Sheet sheet, int startCol, int startRow, int endCol, int endRow) {
        ArgUtils.notNull(sheet, "sheet");

        // 結合先のセルの値を空に設定する
        for(int r=startRow; r <= endRow; r++) {
            for(int c=startCol; c <= endCol; c++) {

                if(r == startRow && c == startCol) {
                    continue;
                }

                Cell cell = getCell(sheet, c, r);
                cell.setCellType(CellType.BLANK);
            }
        }

        final CellRangeAddress range = new CellRangeAddress(startRow, endRow, startCol, endCol);
        sheet.addMergedRegion(range);
        return range;
    }
605138
public static <T> Constructor<T>[] candidateConstructors(Constructor<T>[] constructors, Object[] args) {
        return candidateConstructors(constructors, collectArgTypes(args));
    }
728953
private List<ColumnDefinition> getColumns(CFMetaData cfm) throws InvalidRequestException
    {
        List<ColumnDefinition> columnDefs = new ArrayList<>(columns.size());

        for (Map.Entry<Term, String> col : columns.entrySet())
        {
            try
            {
                ByteBuffer columnName = cfm.comparator.asAbstractType().fromStringCQL2(col.getKey().getText());
                String validatorClassName = CFPropDefs.comparators.containsKey(col.getValue())
                                          ? CFPropDefs.comparators.get(col.getValue())
                                          : col.getValue();
                AbstractType<?> validator = TypeParser.parse(validatorClassName);
                columnDefs.add(ColumnDefinition.regularDef(cfm, columnName, validator, null));
            }
            catch (ConfigurationException e)
            {
                InvalidRequestException ex = new InvalidRequestException(e.toString());
                ex.initCause(e);
                throw ex;
            }
            catch (SyntaxException e)
            {
                InvalidRequestException ex = new InvalidRequestException(e.toString());
                ex.initCause(e);
                throw ex;
            }
        }

        return columnDefs;
    }
29175
public static <N extends Number> Number min(List<N> numberList) {
        return cal(numberList, DoubleStream::min);
    }
176144
public List<StepCandidate> prioritise(String stepAsText, List<StepCandidate> candidates) {
        return prioritisingStrategy.prioritise(stepAsText, candidates);
    }
1143179
public static <T> List<T> lcs(List<T> arg0, List<T> arg1, Comparator<T> comparator) {
        if (arg0 == null || arg1 == null) {
            return Collections.emptyList();
        }
        return lcs(arg0, arg1, comparator, 0, 0);
    }