// GenerateLine returns a truth matrix as if all the nodes are in a straight linke
// with the given spacing between them.
18610
func GenerateLine(nodes int, spacing time.Duration) [][]time.Duration {
	truth := make([][]time.Duration, nodes)
	for i := range truth {
		truth[i] = make([]time.Duration, nodes)
	}

	for i := 0; i < nodes; i++ {
		for j := i + 1; j < nodes; j++ {
			rtt := time.Duration(j-i) * spacing
			truth[i][j], truth[j][i] = rtt, rtt
		}
	}
	return truth
}
823061
func (s *Position) SetLine(v int64) *Position {
	s.Line = &v
	return s
}
736916
func splitLines(data []byte, eof bool) (advance int, token []byte, err error) {
	if eof && len(data) == 0 {
		return 0, nil, nil
	}

	if i := bytes.IndexByte(data, '\n'); i >= 0 {
		orgStdout.Write(data[nextOutPos : i+1])
		nextOutPos = 0
		return i + 1, data[0:i], nil
	}

	orgStdout.Write(data[nextOutPos:])
	nextOutPos = len(data)

	if eof {
		// This is a final, non-terminated line. Return it.
		return len(data), data, nil
	}

	return 0, nil, nil
}
1070639
func GenerateFullQuery(statement sqlparser.Statement) *sqlparser.ParsedQuery {
	buf := sqlparser.NewTrackedBuffer(nil)
	statement.Format(buf)
	return buf.ParsedQuery()
}
67196
func (t *Tabulate) buildLine(padded_widths []int, padding []int, l Line) string {
	cells := make([]string, len(padded_widths))

	for i, _ := range cells {
		b := createBuffer()
		b.Write(l.hline, padding[i]+MIN_PADDING)
		cells[i] = b.String()
	}

	var buffer bytes.Buffer
	buffer.WriteString(l.begin)

	// Print contents
	for i := 0; i < len(cells); i++ {
		buffer.WriteString(cells[i])
		if i != len(cells)-1 {
			buffer.WriteString(l.sep)
		}
	}

	buffer.WriteString(l.end)
	return buffer.String()
}
129148
func (n *Node) Generate() ID {

	n.mu.Lock()

	now := time.Since(n.epoch).Nanoseconds() / 1000000

	if now == n.time {
		n.step = (n.step + 1) & n.stepMask

		if n.step == 0 {
			for now <= n.time {
				now = time.Since(n.epoch).Nanoseconds() / 1000000
			}
		}
	} else {
		n.step = 0
	}

	n.time = now

	r := ID((now)<<n.timeShift |
		(n.node << n.nodeShift) |
		(n.step),
	)

	n.mu.Unlock()
	return r
}
466198
func (pq *ParsedQuery) GenerateQuery(bindVariables map[string]*querypb.BindVariable, extras map[string]Encodable) (string, error) {
	if len(pq.bindLocations) == 0 {
		return pq.Query, nil
	}
	var buf strings.Builder
	buf.Grow(len(pq.Query))
	if err := pq.Append(&buf, bindVariables, extras); err != nil {
		return "", err
	}
	return buf.String(), nil
}
634457
func (rb *route) generateFieldQuery(sel sqlparser.SelectStatement, jt *jointab) string {
	formatter := func(buf *sqlparser.TrackedBuffer, node sqlparser.SQLNode) {
		switch node := node.(type) {
		case *sqlparser.ColName:
			if !rb.isLocal(node) {
				_, joinVar := jt.Lookup(node)
				buf.Myprintf("%a", ":"+joinVar)
				return
			}
		case sqlparser.TableName:
			if !systemTable(node.Qualifier.String()) {
				node.Name.Format(buf)
				return
			}
			node.Format(buf)
			return
		}
		sqlparser.FormatImpossibleQuery(buf, node)
	}

	return sqlparser.NewTrackedBuffer(formatter).WriteNode(sel).ParsedQuery().Query
}
400717
func (this *Manidator) printLines() int {
	linesPrinted := 0
	closedCnt := 0

	width, _, err := terminal.GetSize(0)
	if err != nil {
		width = DefaultTerminalWidth
	}

	// Determine the max length for each line of output. This is computed on each pass to account for the user resizing
	// their terminal.
	maxWidth := width - this.nameWidth - 6

	for _, dator := range this.dators {
		name := dator.GetName()

		// just in case the name changed after Begin was called
		if len(name) > this.nameWidth {
			name = name[:this.nameWidth]
		}

		line := dator.GetLastLine()

		// ellide lines that are longer than the max width of the terminal
		if len(line) > maxWidth {
			line = "..." + line[len(line)-maxWidth:]
		}

		fmt.Printf(this.fmtString, name, line)
		linesPrinted++

		if dator.IsClosed() {
			closedCnt++
		}
	}

	if closedCnt == len(this.dators) {
		close(this.done)
	}

	return linesPrinted
}
752690
func (writer *ConsoleWriter) RotateLines() int {
	writer.lock.RLock()
	defer writer.lock.RUnlock()

	return 0
}
40139
func Line(buffer Buffer, event *cue.Event) {
	if len(event.Frames) == 0 {
		buffer.AppendString("0")
		return
	}
	buffer.AppendString(fmt.Sprintf("%d", event.Frames[0].Line))
}
949282
func doline(canvas *svg.SVG, x1, y1, x2, y2 int, style, direction, label string) {
	var labelstyle string
	var upflag bool

	tadjust := 6
	mx := (x2 - x1) / 2
	my := (y2 - y1) / 2
	lx := x1 + mx
	ly := y1 + my
	m, _ := sloper(x1, y1, x2, y2)
	hline := m == 0
	vline := m == math.Inf(-1) || m == math.Inf(1)
	straight := hline || vline

	switch {
	case m < 0: // upwards line
		upflag = true
		labelstyle += "text-anchor:end;"
		lx -= tadjust
	case hline: // horizontal line
		labelstyle += "text-anchor:middle;baseline-shift:20%;"
		ly -= tadjust
	case m > 0: // downwards line
		upflag = false
		labelstyle += "text-anchor:start;"
		lx += tadjust
	}
	if !straight && direction != "straight" {
		cx, cy := x1, y2 // initial control points
		// fmt.Fprintf(os.Stderr, "%s slope = %.3f\n", label, m)
		if upflag {
			if direction == "ccw" {
				cx, cy = x2, y1
			} else {
				cx, cy = x1, y2
			}
		} else {
			if direction == "ccw" {
				cx, cy = x1, y2
			} else {
				cx, cy = x2, y1
			}
		}
		canvas.Qbez(x1, y1, cx, cy, x2, y2, style)
		labelstyle += "text-anchor:middle"
		canvas.Text(lx, ly, label, labelstyle)
	} else {
		canvas.Line(x1, y1, x2, y2, style)
		canvas.Text(lx, ly, label, labelstyle) // midpoint
	}
}
549024
func (writer *baseFileWriter) RotateLines() int {
	writer.lock.RLock()
	defer writer.lock.RUnlock()
	return writer.rotateLines
}
307046
func (buf *Buffer) EndLine() error {
	_, err := buf.Out.Write(crlf)
	return err
}
491558
func (a *Rect) IntersectLine(X1, Y1, X2, Y2 *int32) bool {
	if a.Empty() {
		return false
	}

	x1 := *X1
	y1 := *Y1
	x2 := *X2
	y2 := *Y2
	rectX1 := a.X
	rectY1 := a.Y
	rectX2 := a.X + a.W - 1
	rectY2 := a.Y + a.H - 1

	// Check if the line is entirely inside the rect
	if x1 >= rectX1 && x1 <= rectX2 && x2 >= rectX1 && x2 <= rectX2 &&
		y1 >= rectY1 && y1 <= rectY2 && y2 >= rectY1 && y2 <= rectY2 {
		return true
	}

	// Check if the line is entirely outside the rect
	if (x1 < rectX1 && x2 < rectX1) || (x1 > rectX2 && x2 > rectX2) ||
		(y1 < rectY1 && y2 < rectY1) || (y1 > rectY2 && y2 > rectY2) {
		return false
	}

	// Check if the line is horizontal
	if y1 == y2 {
		if x1 < rectX1 {
			*X1 = rectX1
		} else if x1 > rectX2 {
			*X1 = rectX2
		}
		if x2 < rectX1 {
			*X2 = rectX1
		} else if x2 > rectX2 {
			*X2 = rectX2
		}

		return true
	}

	// Check if the line is vertical
	if x1 == x2 {
		if y1 < rectY1 {
			*Y1 = rectY1
		} else if y1 > rectY2 {
			*Y1 = rectY2
		}
		if y2 < rectY1 {
			*Y2 = rectY1
		} else if y2 > rectY2 {
			*Y2 = rectY2
		}

		return true
	}

	// Use Cohen-Sutherland algorithm when all shortcuts fail
	outCode1 := computeOutCode(a, x1, y1)
	outCode2 := computeOutCode(a, x2, y2)
	for outCode1 != 0 || outCode2 != 0 {
		if outCode1&outCode2 != 0 {
			return false
		}

		if outCode1 != 0 {
			var x, y int32
			if outCode1&codeTop != 0 {
				y = rectY1
				x = x1 + ((x2-x1)*(y-y1))/(y2-y1)
			} else if outCode1&codeBottom != 0 {
				y = rectY2
				x = x1 + ((x2-x1)*(y-y1))/(y2-y1)
			} else if outCode1&codeLeft != 0 {
				x = rectX1
				y = y1 + ((y2-y1)*(x-x1))/(x2-x1)
			} else if outCode1&codeRight != 0 {
				x = rectX2
				y = y1 + ((y2-y1)*(x-x1))/(x2-x1)
			}

			x1 = x
			y1 = y
			outCode1 = computeOutCode(a, x, y)
		} else {
			var x, y int32
			if outCode2&codeTop != 0 {
				y = rectY1
				x = x1 + ((x2-x1)*(y-y1))/(y2-y1)
			} else if outCode2&codeBottom != 0 {
				y = rectY2
				x = x1 + ((x2-x1)*(y-y1))/(y2-y1)
			} else if outCode2&codeLeft != 0 {
				x = rectX1
				y = y1 + ((y2-y1)*(x-x1))/(x2-x1)
			} else if outCode2&codeRight != 0 {
				x = rectX2
				y = y1 + ((y2-y1)*(x-x1))/(x2-x1)
			}

			x2 = x
			y2 = y
			outCode2 = computeOutCode(a, x, y)
		}
	}

	*X1 = x1
	*Y1 = y1
	*X2 = x2
	*Y2 = y2

	return true
}
157454
func (w *writer) endLine() {
	if !w.inline {
		panic("not in a line")
	}
	w.inline = false
	if w.beforeEnd != nil && !w.delay {
		w.write(" " + w.beforeEnd.String())
		w.beforeEnd = nil
	}
	w.delay = false
	w.write("\n")
}
679180
func (img *Image) DrawLine(x1, y1, x2, y2 int, c color.Color) {
	dx, dy, flag := int(math.Abs(float64(x2-x1))),
		int(math.Abs(float64(y2-y1))),
		false
	if dy > dx {
		flag = true
		x1, y1 = y1, x1
		x2, y2 = y2, x2
		dx, dy = dy, dx
	}
	ix, iy := sign(x2-x1), sign(y2-y1)
	n2dy := dy * 2
	n2dydx := (dy - dx) * 2
	d := n2dy - dx
	for x1 != x2 {
		if d < 0 {
			d += n2dy
		} else {
			y1 += iy
			d += n2dydx
		}
		if flag {
			img.Set(y1, x1, c)
		} else {
			img.Set(x1, y1, c)
		}
		x1 += ix
	}
}