// Make sure we always have as many Cols as we do cells.
178168
func (s *Sheet) maybeAddCol(cellCount int) {
	if cellCount > s.MaxCol {
		loopCnt := cellCount - s.MaxCol
		currIndex := s.MaxCol + 1
		for i := 0; i < loopCnt; i++ {

			col := &Col{
				style:     NewStyle(),
				Min:       currIndex,
				Max:       currIndex,
				Hidden:    false,
				Collapsed: false}
			s.Cols = append(s.Cols, col)
			currIndex++
		}

		s.MaxCol = cellCount
	}
}
679949
func ensureCap(s []byte, n int) []byte {
	if n <= cap(s) {
		return s
	}
	// logic adapted from appendslice1 in runtime
	m := cap(s)
	if m == 0 {
		m = n
	} else {
		for {
			if m < 1024 {
				m += m
			} else {
				m += m / 4
			}
			if m >= n {
				break
			}
		}
	}
	t := make([]byte, len(s), m)
	copy(t, s)
	return t
}
296463
func (m *Table) SetColumns(cols []string) {
	m.FieldPositions = make(map[string]int, len(cols))
	for idx, col := range cols {
		//col = strings.ToLower(col)
		m.FieldPositions[col] = idx
		cols[idx] = col
	}
	m.cols = cols
}
268728
func CheckOnce(cols []*Column) error {
	m := map[string]struct{}{}
	for _, col := range cols {
		name := col.Name
		_, ok := m[name.L]
		if ok {
			return errDuplicateColumn.Gen("column specified twice - %s", name)
		}

		m[name.L] = struct{}{}
	}

	return nil
}
1279061
func (m Mat3) Col(col int) Vec3 {
	return Vec3{m[col*3+0], m[col*3+1], m[col*3+2]}
}
1353344
func (m Mat4x2) Col(col int) Vec4 {
	return Vec4{m[col*4+0], m[col*4+1], m[col*4+2], m[col*4+3]}
}
352187
func (t *TableMap) ColMap(field string) *ColumnMap {
	col := colMapOrNil(t, field)
	if col == nil {
		e := fmt.Sprintf("No ColumnMap in table %s type %s with field %s",
			t.TableName, t.gotype.Name(), field)

		panic(e)
	}
	return col
}
871079
func (mat *MatMxN) NumRowCols() (rows, cols int) {
	return mat.m, mat.n
}
1259086
func (t *ShellTable) MaxColumnWidths() []int {
	if t.maxColumnWidths == nil {
		t.maxColumnWidths = &[]int{}
	}
	for _, r := range t.rows {
		for i, c := range r.columns {
			if len(*t.maxColumnWidths) == i {
				*t.maxColumnWidths = append(*t.maxColumnWidths, 0)
			}
			colWidth := len(c.String())
			if colWidth > (*t.maxColumnWidths)[i] {
				(*t.maxColumnWidths)[i] = colWidth
			}
		}
	}
	return *t.maxColumnWidths
}
453782
func (f *File) adjustColDimensions(xlsx *xlsxWorksheet, col, offset int) {
	for rowIdx := range xlsx.SheetData.Row {
		for colIdx, v := range xlsx.SheetData.Row[rowIdx].C {
			cellCol, cellRow, _ := CellNameToCoordinates(v.R)
			if col <= cellCol {
				if newCol := cellCol + offset; newCol > 0 {
					xlsx.SheetData.Row[rowIdx].C[colIdx].R, _ = CoordinatesToCellName(newCol, cellRow)
				}
			}
		}
	}
}
1216009
func Mat4x2FromCols(col0, col1 Vec4) Mat4x2 {
	return Mat4x2{col0[0], col0[1], col0[2], col0[3], col1[0], col1[1], col1[2], col1[3]}
}
1156389
func (c Cap) CellUnionBound() []CellID {
	// TODO(roberts): The covering could be made quite a bit tighter by mapping
	// the cap to a rectangle in (i,j)-space and finding a covering for that.

	// Find the maximum level such that the cap contains at most one cell vertex
	// and such that CellID.AppendVertexNeighbors() can be called.
	level := MinWidthMetric.MaxLevel(c.Radius().Radians()) - 1

	// If level < 0, more than three face cells are required.
	if level < 0 {
		cellIDs := make([]CellID, 6)
		for face := 0; face < 6; face++ {
			cellIDs[face] = CellIDFromFace(face)
		}
		return cellIDs
	}
	// The covering consists of the 4 cells at the given level that share the
	// cell vertex that is closest to the cap center.
	return cellIDFromPoint(c.center).VertexNeighbors(level)
}
372750
func (r *Row) Columns() []uint64 {
	a := make([]uint64, 0, r.Count())
	for i := range r.segments {
		a = append(a, r.segments[i].Columns()...)
	}
	return a
}
862173
func (st *Stack) ensureCapacity(newCapacity uint64) error {
	// Maximum length of a slice that allocates memory is the same as the native int max size
	// We could rethink this limit, but we don't want different validators to disagree on
	// transaction validity so we pick the lowest common denominator
	if newCapacity > math.MaxInt32 {
		// If we ever did want more than an int32 of space then we would need to
		// maintain multiple pages of memory
		return fmt.Errorf("cannot address memory beyond a maximum index "+
			"with int32 width (%v bytes)", math.MaxInt32)
	}
	newCapacityInt := int(newCapacity)
	// We're already big enough so return
	if newCapacityInt <= len(st.slice) {
		return nil
	}
	if st.maxCapacity > 0 && newCapacity > st.maxCapacity {
		return fmt.Errorf("cannot grow memory because it would exceed the "+
			"current maximum limit of %v bytes", st.maxCapacity)
	}
	// Ensure the backing array of slice is big enough
	// Grow the memory one word at time using the pre-allocated zeroWords to avoid
	// unnecessary allocations. Use append to make use of any spare capacity in
	// the slice's backing array.
	for newCapacityInt > cap(st.slice) {
		// We'll trust Go exponentially grow our arrays (at first).
		st.slice = append(st.slice, Zero256)
	}
	// Now we've ensured the backing array of the slice is big enough we can
	// just re-slice (even if len(mem.slice) < newCapacity)
	st.slice = st.slice[:newCapacity]
	return nil
}
1079305
func (s *Sheet) SetColWidth(startcol, endcol int, width float64) error {
	if startcol > endcol {
		return fmt.Errorf("Could not set width for range %d-%d: startcol must be less than endcol.", startcol, endcol)
	}
	end := endcol + 1
	s.maybeAddCol(end)
	for ; startcol < end; startcol++ {
		s.Cols[startcol].Width = width
	}

	return nil
}
1054914
func HasCorrectAxes(c *chronograf.DashboardCell) error {
	for label, axis := range c.Axes {
		if !oneOf(label, "x", "y", "y2") {
			return chronograf.ErrInvalidAxis
		}

		if !oneOf(axis.Scale, "linear", "log", "") {
			return chronograf.ErrInvalidAxis
		}

		if !oneOf(axis.Base, "10", "2", "") {
			return chronograf.ErrInvalidAxis
		}
	}

	return nil
}
497918
func (m Mat3x2) Cols() (col0, col1 Vec3) {
	return m.Col(0), m.Col(1)
}