TODO: The publicly exposed parts of this should be in lib/SSCGridUtils.
339586
function trimString(s) {
  let l = 0;
  let r = s.length - 1;
  while (l < s.length && s[l] === ' ') {
    l++;
  }
  while (r > l && s[r] === ' ') {
    r -= 1;
  }
  return s.substring(l, r + 1);
}
218696
private static HashMap<String, String> buildAllArtworkColumnProjectionMap() {
        final HashMap<String, String> allColumnProjectionMap = new HashMap<>();
        allColumnProjectionMap.put(BaseColumns._ID, BaseColumns._ID);
        allColumnProjectionMap.put(ProviderContract.Artwork.TOKEN,
                ProviderContract.Artwork.TOKEN);
        allColumnProjectionMap.put(ProviderContract.Artwork.TITLE,
                ProviderContract.Artwork.TITLE);
        allColumnProjectionMap.put(ProviderContract.Artwork.BYLINE,
                ProviderContract.Artwork.BYLINE);
        allColumnProjectionMap.put(ProviderContract.Artwork.ATTRIBUTION,
                ProviderContract.Artwork.ATTRIBUTION);
        allColumnProjectionMap.put(ProviderContract.Artwork.PERSISTENT_URI,
                ProviderContract.Artwork.PERSISTENT_URI);
        allColumnProjectionMap.put(ProviderContract.Artwork.WEB_URI,
                ProviderContract.Artwork.WEB_URI);
        allColumnProjectionMap.put(ProviderContract.Artwork.METADATA,
                ProviderContract.Artwork.METADATA);
        allColumnProjectionMap.put(ProviderContract.Artwork.DATA,
                ProviderContract.Artwork.DATA);
        allColumnProjectionMap.put(ProviderContract.Artwork.DATE_ADDED,
                ProviderContract.Artwork.DATE_ADDED);
        allColumnProjectionMap.put(ProviderContract.Artwork.DATE_MODIFIED,
                ProviderContract.Artwork.DATE_MODIFIED);
        return allColumnProjectionMap;
    }
1297753
public void createCubicGrid() {
        //		logger.debug("	CREATE CUBIC GRID");
        gridGenerator.setDimension(findGridBoundaries(), true);
        gridGenerator.generateGrid();
        this.grid = gridGenerator.getGrid();
    }
356918
function() {
            	var matrix_rows = [];
            	var n = this.elements.length;
            	for (var i = 0; i < n; i++) {
            	    matrix_rows.push($V(this.elements[i]).inspect());
            	}
            	return matrix_rows.join('\n');
                }
1235288
def _build_vertex_data(self):
        
        grid = self._grid
        w = 1.0 / grid[1]
        h = 1.0 / grid[0]

        quad = np.array([[0, 0, 0], [w, 0, 0], [w, h, 0],
                         [0, 0, 0], [w, h, 0], [0, h, 0]],
                        dtype=np.float32)
        quads = np.empty((grid[1], grid[0], 6, 3), dtype=np.float32)
        quads[:] = quad

        mgrid = np.mgrid[0.:grid[1], 0.:grid[0]].transpose(1, 2, 0)
        mgrid = mgrid[:, :, np.newaxis, :]
        mgrid[..., 0] *= w
        mgrid[..., 1] *= h

        quads[..., :2] += mgrid
        tex_coords = quads.reshape(grid[1]*grid[0]*6, 3)
        tex_coords = np.ascontiguousarray(tex_coords[:, :2])
        vertices = tex_coords * self.size

        self._subdiv_position.set_data(vertices.astype('float32'))
        self._subdiv_texcoord.set_data(tex_coords.astype('float32'))
1154267
protected static void constructM(List<Point2D_F64> obsPts,
									 DMatrixRMaj alphas, DMatrixRMaj M)
	{
		int N = obsPts.size();
		M.reshape(3*alphas.numCols,2*N,false);

		for( int i = 0; i < N; i++ ) {
			Point2D_F64 p2 = obsPts.get(i);

			int row = i*2;

			for( int j = 0; j < alphas.numCols; j++ ) {
				int col = j*3;

				double alpha = alphas.unsafe_get(i, j);
				M.unsafe_set(col, row, alpha);
				M.unsafe_set(col + 1, row, 0);
				M.unsafe_set(col + 2, row, -alpha * p2.x);
				M.unsafe_set(col    , row + 1, 0);
				M.unsafe_set(col + 1, row + 1, alpha);
				M.unsafe_set(col + 2, row + 1, -alpha * p2.y);
			}
		}
	}
1254745
public void imageToGrid( Point2D_F64 pixel , Point2D_F64 grid ) {
		transformGrid.imageToGrid(pixel.x, pixel.y, grid);
	}
686606
private void appendDesc(StringBuilder sb)
    {
        String srcId;

        if (mSystemId != null) {
            sb.append("[row,col,system-id]: ");
            srcId = mSystemId;
        } else if (mPublicId != null) {
            sb.append("[row,col,public-id]: ");
            srcId = mPublicId;
        } else {
            sb.append("[row,col {unknown-source}]: ");
            srcId = null;
        }
        sb.append('[');
        sb.append(mRow);
        sb.append(',');
        sb.append(mCol);

        // Uncomment for testing, to see the char offset:
        //sb.append(" #").append(mCharOffset);
        //sb.append("{").append(System.identityHashCode(this)).append("}");

        if (srcId != null) {
            sb.append(',');
            sb.append('"');
            sb.append(srcId);
            sb.append('"');
        }
        sb.append(']');
        if (mContext != null) {
            StringUtil.appendLF(sb);
            sb.append(" from ");
            mContext.appendDesc(sb);
        }
    }
1050549
void putIntoCanonical( SquareGrid grid ) {

		boolean rowOdd = grid.rows%2 == 1;
		boolean colOdd = grid.columns%2 == 1;

		if( colOdd == rowOdd ) {
			// if odd and square then 4 solutions.  Otherwise just two solution that are on
			// opposite sides on the grid
			if( rowOdd && grid.rows == grid.columns ) {
				int best = -1;
				double bestDistance = Double.MAX_VALUE;
				for (int i = 0; i < 4; i++) {
					SquareNode n = grid.getCornerByIndex(i);
					double d = n.center.normSq();
					if( d < bestDistance ) {
						best = i;
						bestDistance = d;
					}
				}

				for (int i = 0; i < best; i++) {
					tools.rotateCCW(grid);
				}
			} else {
				double first = grid.get(0,0).center.normSq();
				double last = grid.getCornerByIndex(2).center.normSq();

				if( last < first ) {
					tools.reverse(grid);
				}
			}
		}
		// if only one is odd then there is a unique solution.  Since uber is already in a legit
		// configuration nothing needs ot be done
	}
1207281
function parseGridData(data, getPosition, getWeight = null) {
  const pointCount = count(data);
  const positions = new Float32Array(pointCount * 2);
  const positions64xyLow = new Float32Array(pointCount * 2);
  const weightValues = new Float32Array(pointCount * 3);

  let yMin = Infinity;
  let yMax = -Infinity;
  let xMin = Infinity;
  let xMax = -Infinity;
  let y;
  let x;
  const {iterable, objectInfo} = createIterable(data);
  for (const object of iterable) {
    objectInfo.index++;
    const position = getPosition(object, objectInfo);
    const {index} = objectInfo;
    x = position[0];
    y = position[1];
    positions[index * 2] = x;
    positions[index * 2 + 1] = y;

    positions64xyLow[index * 2] = fp64LowPart(x);
    positions64xyLow[index * 2 + 1] = fp64LowPart(y);

    const weight = getWeight ? getWeight(object, objectInfo) : DEFAULT_WEIGHT;
    // Aggregator expects each weight is an array of size 3
    if (Array.isArray(weight)) {
      weightValues[index * 3] = weight[0];
      weightValues[index * 3 + 1] = weight[1];
      weightValues[index * 3 + 2] = weight[2];
    } else {
      // backward compitability
      weightValues[index * 3] = weight;
    }

    if (Number.isFinite(y) && Number.isFinite(x)) {
      yMin = y < yMin ? y : yMin;
      yMax = y > yMax ? y : yMax;

      xMin = x < xMin ? x : xMin;
      xMax = x > xMax ? x : xMax;
    }
  }
  const weights = {
    weight1: {
      size: 1,
      operation: AGGREGATION_OPERATION.SUM,
      needMax: true,
      values: weightValues
    }
  };
  const boundingBox = {xMin, xMax, yMin, yMax};
  return {
    positions,
    positions64xyLow,
    weights,
    boundingBox
  };
}
672010
private function createGrid(): void
    {
        $this->grid = new Grid();
        $sizes      = StringUtil::deserialize($this->model->sizes, true);

        $this->buildRow();

        foreach ($sizes as $size) {
            $field      = $size . 'Size';
            $definition = StringUtil::deserialize($this->model->{$field}, true);

            if ($size === 'xs') {
                $size = '';
            }

            $this->buildSize($size, $definition, $sizes);
        }
    }
1284992
function connectedComponents_dense(cells, vertex_count) {
  var labels = new UnionFind(vertex_count)
  for(var i=0; i<cells.length; ++i) {
    var c = cells[i]
    for(var j=0; j<c.length; ++j) {
      for(var k=j+1; k<c.length; ++k) {
        labels.link(c[j], c[k])
      }
    }
  }
  var components = []
    , component_labels = labels.ranks
  for(var i=0; i<component_labels.length; ++i) {
    component_labels[i] = -1
  }
  for(var i=0; i<cells.length; ++i) {
    var l = labels.find(cells[i][0])
    if(component_labels[l] < 0) {
      component_labels[l] = components.length
      components.push([cells[i].slice(0)])
    } else {
      components[component_labels[l]].push(cells[i].slice(0))
    }
  }
  return components
}
453237
def compose_components(model=@model, offset=[0,0])
			warn "HtmlGrid::List#compose_components is deprecated"
			each_component { |matrix, component|
				res = resolve_offset(matrix, offset)
				comp = create(component, model)
				if((tab = matrix.at(3)) && comp.respond_to?(:tabindex=))
					comp.tabindex = tab
				end
				@grid.add(label(comp, component), res.at(0), res.at(1), 
					self::class::VERTICAL)
			}
		end
1145511
public void addGridHeading()
    {
        JPanel panel = new JPanel();
        panel.setOpaque(false);
        panel.setAlignmentX(LEFT_ALIGNMENT);
        panel.setAlignmentY(TOP_ALIGNMENT);
        this.add(panel);
        panel.setLayout(new BoxLayout(panel, BoxLayout.X_AXIS));
        
        m_rgcompHeadings = new JLabel[this.getModel().getColumnCount()];
        for (int iColumnIndex = 0; iColumnIndex < m_rgcompHeadings.length; iColumnIndex++)
        {
            panel.add(m_rgcompHeadings[iColumnIndex] = new JLabel(this.getModel().getColumnName(iColumnIndex) + " "));
        }
    }
687387
function(){
    // If the data grid has already been built, nothing to do here
    if (this.spreadsheet.datagrid) return this.spreadsheet.datagrid;
    
    var s = this.series,
        datagrid = this.spreadsheet.loadDataGrid(),
        colgroup = ['<colgroup><col />'],
        buttonDownload, buttonSelect, t;
    
    // First row : series' labels
    var html = ['<table class="flotr-datagrid"><tr class="first-row">'];
    html.push('<th>&nbsp;</th>');
    _.each(s, function(serie,i){
      html.push('<th scope="col">'+(serie.label || String.fromCharCode(65+i))+'</th>');
      colgroup.push('<col />');
    });
    html.push('</tr>');
    // Data rows
    _.each(datagrid, function(row){
      html.push('<tr>');
      _.times(s.length+1, function(i){
        var tag = 'td',
            value = row[i],
            // TODO: do we really want to handle problems with floating point
            // precision here?
            content = (!_.isUndefined(value) ? Math.round(value*100000)/100000 : '');
        if (i === 0) {
          tag = 'th';
          var label = getRowLabel.call(this, content);
          if (label) content = label;
        }

        html.push('<'+tag+(tag=='th'?' scope="row"':'')+'>'+content+'</'+tag+'>');
      }, this);
      html.push('</tr>');
    }, this);
    colgroup.push('</colgroup>');
    t = D.node(html.join(''));

    /**
     * @TODO disabled this
    if (!Flotr.isIE || Flotr.isIE == 9) {
      function handleMouseout(){
        t.select('colgroup col.hover, th.hover').invoke('removeClassName', 'hover');
      }
      function handleMouseover(e){
        var td = e.element(),
          siblings = td.previousSiblings();
        t.select('th[scope=col]')[siblings.length-1].addClassName('hover');
        t.select('colgroup col')[siblings.length].addClassName('hover');
      }
      _.each(t.select('td'), function(td) {
        Flotr.EventAdapter.
          observe(td, 'mouseover', handleMouseover).
          observe(td, 'mouseout', handleMouseout);
      });
    }
    */

    buttonDownload = D.node(
      '<button type="button" class="flotr-datagrid-toolbar-button">' +
      this.options.spreadsheet.toolbarDownload +
      '</button>');

    buttonSelect = D.node(
      '<button type="button" class="flotr-datagrid-toolbar-button">' +
      this.options.spreadsheet.toolbarSelectAll+
      '</button>');

    this.
      observe(buttonDownload, 'click', _.bind(this.spreadsheet.downloadCSV, this)).
      observe(buttonSelect, 'click', _.bind(this.spreadsheet.selectAllData, this));

    var toolbar = D.node('<div class="flotr-datagrid-toolbar"></div>');
    D.insert(toolbar, buttonDownload);
    D.insert(toolbar, buttonSelect);

    var containerHeight =this.canvasHeight - D.size(this.spreadsheet.tabsContainer).height-2,
        container = D.node('<div class="flotr-datagrid-container" style="position:absolute;left:0px;top:0px;width:'+
          this.canvasWidth+'px;height:'+containerHeight+'px;overflow:auto;z-index:10"></div>');

    D.insert(container, toolbar);
    D.insert(container, t);
    D.insert(this.el, container);
    this.spreadsheet.datagrid = t;
    this.spreadsheet.container = container;

    return t;
  }
218225
function() {
        this.io = µBlock.CompiledLineIO;
        this.blockId = undefined;
        this.block = undefined;
        this.stringifier = this.io.serialize;
        this.blocks = new Map();
        this.properties = new Map();
    }
27184
function RenderGrid()
	{
	global $gSQLBlockRows; // used by rs2html to indicate how many rows to display
		include_once(ADODB_DIR.'/tohtml.inc.php');
		ob_start();
		$gSQLBlockRows = $this->rows;
		rs2html($this->rs,$this->gridAttributes,$this->gridHeader,$this->htmlSpecialChars);
		$s = ob_get_contents();
		ob_end_clean();
		return $s;
	}