code
stringlengths
114
1.05M
path
stringlengths
3
312
quality_prob
float64
0.5
0.99
learning_prob
float64
0.2
1
filename
stringlengths
3
168
kind
stringclasses
1 value
package measurement import ( "regexp" "sort" "strconv" "strings" "github.com/wayn3h0/gop/decimal" "github.com/wayn3h0/gop/errors" ) // DimensionUnit represents the unit of dimension. type DimensionUnit int // Dimension Units. const ( Millimeter DimensionUnit = 1 // base Centimeter DimensionUnit = 10 Meter ...
measurement/dimension.go
0.81772
0.437884
dimension.go
starcoder
package ebnf import "io" const sentinel byte = 4 // inputBuffer implements the two-buffer scheme for reading the input characters. type inputBuffer struct { src io.Reader // The first and second halves of the buff are alternatively reloaded. // Each half is of the same size N plus an additional space for the sen...
internal/ebnf/input_buffer.go
0.771843
0.503052
input_buffer.go
starcoder
package is import ( "errors" "reflect" ) func init() { loadTestFile() } var ( comments map[string]map[int]string arguments map[string]map[int]string ) // Is is the test helper. type Is struct { T } // New makes a new test helper given by T. Any failures will reported onto T. // Most of the time T will be te...
is.go
0.59302
0.499451
is.go
starcoder
package typ import "xelf.org/xelf/cor" // Param describes a strc field or spec parameter. type Param struct { Name string Key string Type } func P(name string, t Type) Param { return Param{Name: name, Key: cor.Keyed(name), Type: t} } func (p Param) IsOpt() bool { return p.Name != "" && p.Name[len(p.Name)-1] ==...
typ/body.go
0.651687
0.520192
body.go
starcoder
package enumerable // ReduceIntToInt reduces a slice of int to int func ReduceIntToInt(in []int, memo int, f func(int, int) int) int { for _, value := range in { memo = f(memo, value) } return memo } // ReduceIntToFloat64 reduces a slice of int to float64 func ReduceIntToFloat64(in []int, memo float64, f func(fl...
generated_reduce_funcs.go
0.818302
0.408159
generated_reduce_funcs.go
starcoder
package text import ( "bytes" "github.com/yuin/goldmark/util" ) var space = []byte(" ") // A Segment struct holds information about source positions. type Segment struct { // Start is a start position of the segment. Start int // Stop is a stop position of the segment. // This value should be excluded. Stop ...
vendor/github.com/yuin/goldmark/text/segment.go
0.823754
0.47725
segment.go
starcoder
package shapes import ( . "github.com/gabz57/goledmatrix/canvas" . "github.com/gabz57/goledmatrix/components" ) type Panel struct { shape *CompositeDrawable cornerRadius int dimensions Point fill bool border bool } func NewPanel(parent *Graphic, layout *Layout, initialPosition Point, di...
components/shapes/panel.go
0.568176
0.401541
panel.go
starcoder
package encoding import ( "bytes" "fmt" "math" "math/bits" "github.com/eleme/lindb/pkg/bit" ) const blockSizeAdjustment = 1 type FloatEncoder struct { previousVal uint64 buf bytes.Buffer bw *bit.Writer leading int trailing int first bool finish bool err error } type FloatDecoder struct { val u...
pkg/encoding/float.go
0.632957
0.40751
float.go
starcoder
package dijkstra import ( "github.com/DrakeEsdon/Go-Snake/datatypes" "github.com/RyanCarrier/dijkstra" "math" ) func addGameStateToGraph(request *datatypes.GameRequest, g *dijkstra.Graph, canGoToTail bool) *dijkstra.Graph { board := &request.Board you := request.You dangerousSnakeMoves := GetPossibleMovesOfEqua...
dijkstra/dijkstra.go
0.636805
0.465448
dijkstra.go
starcoder
// Package conti provides business logic of trial account calculation package conti import ( "math" ) type Report struct { Balance BalanceSections Profit ProfitSections } type BalanceSections struct { Assets Tally Liabls Tally Equity Tally // Retained result // Accumulated results, i.e. retained earnings ...
conti/sections.go
0.628635
0.452113
sections.go
starcoder
package hplot import ( "math" "gonum.org/v1/plot" "gonum.org/v1/plot/plotter" "gonum.org/v1/plot/vg" "gonum.org/v1/plot/vg/draw" ) // S2D plots a set of 2-dim points with error bars. type S2D struct { Data plotter.XYer // GlyphStyle is the style of the glyphs drawn // at each point. draw.GlyphStyle // o...
hplot/s2d.go
0.75985
0.47859
s2d.go
starcoder
package neox import ( "github.com/neo4j/neo4j-go-driver/neo4j" ) // Record wraps the standard implementation of a neo4j.Record // adding some useful utlities type Record struct { neo4j.Record } // GetIntAtIndex retrieves the value for the record at the provided index // asserting it as an integer, returning the va...
record.go
0.836988
0.501282
record.go
starcoder
package rect import ( "math" "sort" ) // Rectangle struct defines a plane figure with four straight sides // and four right angles, which contains 4 vertixes points, P1 through P4 type Rectangle struct { P1, P2, P3, P4 Point } // maximum error used for floating point math var ɛ = 0.00001 // IsRect determins if t...
rectangle.go
0.810441
0.637934
rectangle.go
starcoder
package slices import ( "math/rand" ) type integer interface { ~int | ~int8 | ~int16 | ~int32 | ~int64 | ~uint | ~uint8 | ~uint16 | ~uint32 | ~uint64 | ~uintptr } type float interface { ~float32 | ~float64 } type complex interface { ~complex64 | ~complex128 } type ordered interface { integer | float | string ...
slices.go
0.568056
0.400398
slices.go
starcoder
package convexhull import ( "fmt" "math" "sort" "github.com/go-gl/gl" ) type Point struct { X, Y float64 } type PointList []Point func MakePoint(x float64, y float64) Point { return Point{X: x, Y: y} } func PrintStack(s *Stack) { v := s.top fmt.Printf("Stack: ") for v != nil { fmt.Printf("%v ", v.value...
convexhull/grahamscan.go
0.660939
0.403743
grahamscan.go
starcoder
package set type Set struct { elements map[interface{}]struct{} } // New creates and returns a new set containing `xs`. func New(xs ...interface{}) *Set { n := make(map[interface{}]struct{}) for _, x := range xs { n[x] = struct{}{} } return &Set{n} } // Copy returns a distinct copy of `s`. func (s *Set) Copy(...
set.go
0.888487
0.417746
set.go
starcoder
package rbt // KeyComparison structure used as result of comparing two keys type KeyComparison int8 const ( // KeyIsLess is returned as result of key comparison if the first key is less than the second key KeyIsLess KeyComparison = iota - 1 // KeysAreEqual is returned as result of key comparison if the ...
rbtree.go
0.896004
0.52476
rbtree.go
starcoder
package goqkit /* QBits register which has same of qbits and can apply the many quantum gates */ type Register struct { //Number of QBits in this register. numberOfQBits int //QBits value. if this register has 0x01,0x02 qbits, then QBits will be 0x03 qBits uint //How many shift from local to global value in circu...
register.go
0.837221
0.504639
register.go
starcoder
package main import ( "fmt" ) // Structure of a node in the tree type Node struct { /* Every node has a data, pointer to its left child and also right child.*/ data int left *Node right *Node } /* This function prints thre pre order traversal of the tree recursively.*/ func pre_order(root *Node) { // If we r...
Go/ds/binary_tree/pre_order_traversal/Pre_Order_Traversal.go
0.608594
0.621311
Pre_Order_Traversal.go
starcoder
package iso20022 // Net position of a segregated holding, in a single security, within the overall position held in a securities account at a specified place of safekeeping. type AggregateBalancePerSafekeepingPlace2 struct { // Total quantity of financial instrument for the referenced holding. AggregateBalance *Bal...
AggregateBalancePerSafekeepingPlace2.go
0.874131
0.517266
AggregateBalancePerSafekeepingPlace2.go
starcoder
package circuits import ( "fmt" "math" "time" "github.com/markkurossi/mpc/circuit" "github.com/markkurossi/mpc/compiler/utils" "github.com/markkurossi/mpc/types" ) // Builtin implements a buitin circuit that uses input wires a and b // and returns the circuit result in r. type Builtin func(cc *Compiler, a, b,...
compiler/circuits/compiler.go
0.693888
0.466299
compiler.go
starcoder
package models import ( "math/rand" "github.com/DheerendraRathor/GoTracer/utils" ) type Material interface { Scatter(*Ray, *HitRecord, *rand.Rand) (bool, *Vector, *Ray) IsLight() bool } type BaseMaterial struct { Albedo *Vector isLight bool } func NewBaseMaterial(albedo *Vector, isLight bool) *BaseMaterial ...
models/material.go
0.782247
0.450782
material.go
starcoder
package aggregation import ( "sync" "time" ) // TimedFloat64Buckets keeps buckets that have been collected at a certain time. type TimedFloat64Buckets struct { bucketsMutex sync.RWMutex buckets map[time.Time]float64Bucket granularity time.Duration } // NewTimedFloat64Buckets generates a new TimedFloat64Bu...
pkg/autoscaler/aggregation/bucketing.go
0.81899
0.509093
bucketing.go
starcoder
package types // A Kind represents the specific kind of type that a Type represents. // The zero Kind is not a valid kind. type Kind uint // KindString implements fmt.Stringer interface. func (k Kind) String() string { name, ok := kindNameMap[k] if !ok { return "Invalid" } return name } // IsNumber checks if g...
types/kind.go
0.781539
0.470919
kind.go
starcoder
package utils import ( "fmt" "strconv" "strings" "unsafe" ) // ToSliceByte converts an unsafe.Pointer to a slice of byte // Usage: // f := []float64{1.0, 2.0, 3.0} // b := ToSliceByte(unsafe.Pointer(&f[0]), len(f)*8) func ToSliceByte(ptr unsafe.Pointer, l int) []byte { sl := (*[1]byte)(ptr)[:] setCapLen(unsafe....
internal/utils/slice.go
0.737347
0.450299
slice.go
starcoder
package ast // Declaration represents a Declaration node. type Declaration struct { HoistableDeclaration *HoistableDeclaration ClassDeclaration *ClassDeclaration LexicalDeclaration *LexicalDeclaration } // HoistableDeclaration represents a HoistableDeclaration node. type HoistableDeclaration struct { Functi...
internal/parser/ast/declaration.go
0.603698
0.506347
declaration.go
starcoder
package math import ( "math" "math/bits" ) // @param m `1 <= m` // @return x mod m func SafeMod(x, m int64) int64 { x %= m if x < 0 { x += m } return x } // Fast moduler by barrett reduction type Barrett struct { M uint Im uint64 } // @param m `1 <= m` func NewBarrett(m uint) *Barrett { return &Barrett{...
internal/math/math.go
0.558327
0.420064
math.go
starcoder
package graph import ( "strings" "github.com/srafi1/LineForge/ansi" "github.com/srafi1/LineForge/mathstring" ) type Point struct { x float64 y float64 myString string myColor string } func (p *Point) New() { p.checkAxis(-1) p.myString = " " } //toString prints myString with whate...
graph/point.go
0.628863
0.477554
point.go
starcoder
package trapping_rain_water /* 42. 接雨水 https://leetcode-cn.com/problems/trapping-rain-water 给定 n 个非负整数表示每个宽度为 1 的柱子的高度图,计算按此排列的柱子,下雨之后能接多少雨水。 上面是由数组 [0,1,0,2,1,0,1,3,2,1,2,1] 表示的高度图,在这种情况下,可以接 6 个单位的雨水(蓝色部分表示雨水)。 感谢 Marcos 贡献此图。 示例: 输入: [0,1,0,2,1,0,1,3,2,1,2,1] 输出: 6 */ /* #### 考虑每个位置能接到的雨水量 遍历数组,对于位置 i,考虑可以接到多少雨...
solutions/trapping-rain-water/d.go
0.582491
0.476762
d.go
starcoder
package data import ( "github.com/kode4food/ale/types" "github.com/kode4food/ale/types/basic" ) type ( // ArityChecker is the interface for arity checks ArityChecker func(int) error // Convention describes the way a function should be called Convention int // Call is the type of function that can be turned i...
data/function.go
0.669637
0.407333
function.go
starcoder
package quad import ( "math" "sync" ) // Implements Integral type trapezoidalIntegral struct { function func(float64) float64 accuracy float64 steps int workers int stats *Stats lock sync.RWMutex } // Create a new Integral, based on the trapezoidal // rule. This will evaluate the integral concurrentl...
pkg/quad/trap.go
0.768125
0.459319
trap.go
starcoder
Package lingua accurately detects the natural language of written text, be it long or short. What this library does Its task is simple: It tells you which language some provided textual data is written in. This is very useful as a preprocessing step for linguistic data in natural language processing applications such...
doc.go
0.875734
0.904861
doc.go
starcoder
package isolationforest import ( "math" "math/rand" ) // IsolationForest data type of forest type IsolationForest struct { nTrees int sampleSize int trees []*IsolationTree rng rand.Rand } var goroutineWatcher chan struct{} // Init constructor of IsolationForest func Init(nTrees int, sampleSize...
isolationforest.go
0.692538
0.47993
isolationforest.go
starcoder
package cube import ( gl "github.com/adrianderstroff/realtime-clouds/pkg/core/gl" geometry "github.com/adrianderstroff/realtime-clouds/pkg/view/geometry" ) // MakeQuad creates a Quad with the specified width, height and depth. // If the normals should be inside the quad the inside parameter should be true. func Mak...
pkg/view/geometry/cube/cube.go
0.715821
0.457743
cube.go
starcoder
package alt import ( "fmt" "math" "reflect" "strconv" "strings" "time" "github.com/ohler55/ojg" "github.com/ohler55/ojg/gen" ) // DefaultRecomposer provides a shared Recomposer. Note that this should not // be shared across go routines unless all types that will be used are // registered first. That can be ...
ingest/vendor/github.com/ohler55/ojg/alt/recomposer.go
0.576423
0.449211
recomposer.go
starcoder
package sgf import ( "bytes" "fmt" "io" ) // A Node is the fundamental unit in an SGF tree. Nodes have 0 or more keys, // which have 1 or more values. Keys and values are strings. These strings are // kept in an unescaped state; escaping and unescaping is handled during loading // and saving of files. A node also ...
node.go
0.68458
0.465266
node.go
starcoder
package managedseed import ( "io/ioutil" "os" "strings" gardencorev1beta1 "github.com/gardener/gardener/pkg/apis/core/v1beta1" seedmanagementv1alpha1 "github.com/gardener/gardener/pkg/apis/seedmanagement/v1alpha1" "github.com/gardener/gardener/pkg/gardenlet/apis/config" confighelper "github.com/gardener/garde...
pkg/gardenlet/controller/managedseed/managedseed_valueshelper.go
0.633524
0.445228
managedseed_valueshelper.go
starcoder
package data import ( "bytes" "math/rand" "github.com/kode4food/ale/types" "github.com/kode4food/ale/types/basic" ) type ( // Vector is a fixed-length array of Values Vector interface { vector() // marker Sequence ValuerSequence Prepender Appender Reverser RandomAccess Caller Valuer } vect...
data/vector.go
0.73077
0.593256
vector.go
starcoder
package geojson import ( "encoding/json" "errors" ) var ( // ErrNoGeometry happens when no Geometry has been specified during, for instance // a MarshalJSON operation ErrNoGeometry = errors.New("no geometry specified") // ErrMultipleGeometries happens when more than one Geometry has been specified // and usual...
geometry.go
0.725551
0.558447
geometry.go
starcoder
package longest_increasing_path_in_a_matrix /* 329.矩阵中的最长递增路径 https://leetcode-cn.com/problems/longest-increasing-path-in-a-matrix 给定一个整数矩阵,找出最长递增路径的长度。 对于每个单元格,你可以往上,下,左,右四个方向移动。 你不能在对角线方向上移动或移动到边界外(即不允许环绕)。 示例 1: 输入: nums = [ [9,9,4], [6,6,8], [2,1,1] ] 输出: 4 解释: 最长递增路径为 [1, 2, 6, 9]。 示例 2: 输入: nums = [ [3,4,5],...
solutions/longest-increasing-path-in-a-matrix/d.go
0.587352
0.624866
d.go
starcoder
package render import ( "fmt" "strconv" "time" "golang.org/x/tools/godoc/vfs" ) var registry = map[string](func(vfs.FileSystem) Component){} // RegisterComponent adds a new component to the registry, returning an error if duplicate names exist. func RegisterComponent(name string, generator func(vfs.FileSystem) ...
render/component.go
0.63477
0.411998
component.go
starcoder
package gcdby import ( "math/big" ) type step struct { delta int f *big.Int g *big.Int p []*big.Float } var ( zero = big.NewInt(0) zerof = big.NewFloat(0) one = big.NewInt(1) onef = big.NewFloat(1) two = big.NewInt(2) twof = big.NewFloat(2) ) func truncate(f *big.Int, t uint) *big.Int ...
gcd.go
0.569613
0.401717
gcd.go
starcoder
package models import ( "math" "raytracer/utility" "sort" "github.com/go-gl/mathgl/mgl32" "github.com/udhos/gwob" ) type Triangle struct { Index int Vertices [3]mgl32.Vec3 TextureCoords [3]mgl32.Vec2 // TODO: Add vertex normals // For Woop intersection //LocalM mgl32.Mat3 //LocalN mgl32.Vec...
src/backend/models/triangle.go
0.502441
0.560794
triangle.go
starcoder
package assertions import ( "fmt" "reflect" "strings" ) import ( "github.com/smartystreets/oglematchers" ) // ShouldEqual receives exactly two parameters and does an equality check. func ShouldEqual(actual interface{}, expected ...interface{}) string { if message := need(1, expected); message != success { ret...
src/github.com/smartystreets/goconvey/assertions/equality.go
0.760473
0.731442
equality.go
starcoder
package plugins import ( "strings" "time" ) // State describes a pull-request states, based on the events we've // seen. type State interface { // Has the state been activated Active() bool // How long has the state been activated (will panic if not active) Age(t time.Time) time.Duration // Receive the event, ...
velodrome/transform/plugins/states.go
0.542621
0.447219
states.go
starcoder
package advent import . "github.com/davidparks11/advent2021/internal/advent/day11" var _ Problem = &dumboOctopus{} type dumboOctopus struct { dailyProblem } func NewDumboOctopus() Problem { return &dumboOctopus{ dailyProblem{ day: 11, }, } } func (d *dumboOctopus) Solve() interface{} { input := d.GetInp...
internal/advent/day11.go
0.736874
0.451508
day11.go
starcoder
package element import ( "errors" "math" "reflect" ) type Element struct { Val interface{} Type reflect.Kind } var emptyElement = New(nil) var Ops = map[string]func(Element, Element) (Element, error) { "+": func(a, b Element) (Element, error) { return New(a.Val.(float64) + b.Val.(float64)), nil }, "-": fun...
src/frame/element/element.go
0.63861
0.42322
element.go
starcoder
package swagger const ( Antidoteinfo = `{ "swagger": "2.0", "info": { "title": "antidoteinfo.proto", "version": "version not set" }, "consumes": [ "application/json" ], "produces": [ "application/json" ], "paths": { "/exp/antidoteinfo": { "get": { "operationId": "Anti...
api/exp/swagger/swagger.pb.go
0.606149
0.40751
swagger.pb.go
starcoder
package crf import ( "math" "github.com/nlpodyssey/spago/ag" "github.com/nlpodyssey/spago/mat" "github.com/nlpodyssey/spago/mat/float" ) // FIXME: ViterbiStructure currently works with float64 only // ViterbiStructure implements Viterbi decoding. type ViterbiStructure struct { scores mat.Matrix backpoi...
nn/crf/viterbi.go
0.538983
0.453262
viterbi.go
starcoder
package fsm import ( "fmt" "sync" ) const ( NO_INPUT Input = -1 ) // An Input to give to an FSM. type Input int // An Action describes something an FSM will do. // It returns an Input to allow for automatic chaining of actions. type Action func() Input // NO_ACTION is useful for when you need a certain input to...
vendor/github.com/discoviking/fsm/fsm.go
0.680985
0.42483
fsm.go
starcoder
package containers import ( "io" "unsafe" "github.com/RoaringBitmap/roaring" "github.com/RoaringBitmap/roaring/roaring64" "github.com/matrixorigin/matrixone/pkg/vm/engine/tae/stl" "github.com/matrixorigin/matrixone/pkg/vm/engine/tae/stl/containers" "github.com/matrixorigin/matrixone/pkg/vm/engine/tae/types" ) ...
pkg/vm/engine/tae/containers/vector.go
0.540924
0.426979
vector.go
starcoder
package main func infoGeneral() { println(` ### All CSVs ### The first row: - "CODE": Means the following column says what version of the code produced the output. - "v0.2.2": The code version - "RAMES": Means the following column says what RAMSES specification was used. - "SPU045-S2:6F": The RAMSES ver...
cmd/rac/output.go
0.533884
0.520009
output.go
starcoder
// Helper code to assist emitting correctly minimally parenthesized // TypeScript type literals. package tstypes import ( "bytes" ) // Supported types include type identifiers, arrays `T[]`, unions // `A|B`, and maps with string keys. type TypeAst interface { depth() int } // Produces a TypeScript type literal fo...
pkg/codegen/internal/tstypes/tstypes.go
0.722331
0.537891
tstypes.go
starcoder
package yoo import ( "math" "errors" "encoding/binary" ) type ByteArray struct { buf []byte posWrite int posRead int endian binary.ByteOrder } var ByteArrayEndian binary.ByteOrder = binary.BigEndian func CreateByteArray(bytes []byte) *ByteArray { var ba *ByteArray if len(bytes) > 0 { ba = &Byt...
tbs.go
0.645008
0.47591
tbs.go
starcoder
package nQueens //Count will take a board matrix and return a solution count func Count(n int) int { solutionCount := 0 doneCh := make(chan bool) countCh := make(chan int) for i := 0; i < n; i++ { go pathSupervisor(makeBoardWithPiece(n, i), 1, makeColsWithPiece(n, i), doneCh, countCh) } for n > 0 { select { ...
go/concurrent/nQueens.go
0.718298
0.44071
nQueens.go
starcoder
package golgi import ( "fmt" "github.com/chewxy/hm" G "gorgonia.org/gorgonia" "gorgonia.org/tensor" ) type unnameable interface { unnamed() } type id struct{} func (l id) Model() G.Nodes { return nil } func (l id) Fwd(x G.Input) G.Result { return x.Node() } func (l id) Type() hm.Type { return...
trivial.go
0.713931
0.411879
trivial.go
starcoder
package cios import ( "encoding/json" ) // Location struct for Location type Location struct { Latitude float32 `json:"latitude"` Longitude float32 `json:"longitude"` } // NewLocation instantiates a new Location object // This constructor will assign default values to properties that have it defined, // and make...
cios/model_location.go
0.841044
0.46721
model_location.go
starcoder
package day11 import ( "errors" "fmt" "github.com/knalli/aoc" ) func solve1(lines []string) error { if grid, err := parseGrid(lines); err != nil { return err } else { round := 0 changes := 0 for { changes, grid = doPlacements1(grid) round++ if changes == 0 { break } } occupiedSeats :=...
day11/puzzle.go
0.554712
0.4184
puzzle.go
starcoder
package beta import ( "math" ) /* * Beta related functions */ // Complete : complete beta function, B(a,b) func Complete(a, b float64) float64 { return math.Exp(lgamma(a) + lgamma(b) - lgamma(a+b)) } // Incomplete : B(x;a,b) is the incomplete beta function func Incomplete(x, a, b float64) float64 { return regI...
beta/betaFunc.go
0.777046
0.502075
betaFunc.go
starcoder
package rtree import ( "fmt" "strings" "go-hep.org/x/hep/groot/root" ) type join struct { name string title string trees []Tree branches []Branch leaves []Leaf bmap map[string]Branch lmap map[string]Leaf } // Join returns a new Tree that represents the logical join of the input trees....
groot/rtree/join.go
0.734405
0.448607
join.go
starcoder
package models import ( i878a80d2330e89d26896388a3f487eef27b0a0e6c010c493bf80be1452208f91 "github.com/microsoft/kiota-abstractions-go/serialization" ) // BookingAppointment type BookingAppointment struct { Entity // Additional information that is sent to the customer when an appointment is confirmed. ...
models/booking_appointment.go
0.622918
0.438364
booking_appointment.go
starcoder
package wid import ( "image" "gioui.org/gesture" "gioui.org/io/pointer" "gioui.org/layout" "gioui.org/op/clip" "gioui.org/op/paint" ) // Resize provides a draggable handle in between two widgets for resizing their area. type Resize struct { // ratio defines how much space is available to the first widget. ax...
wid/resizer.go
0.679391
0.510863
resizer.go
starcoder
package client import ( "math" "sort" ) //nearestObstacle() returns a integer corresponding to the stick that is nearest to the ball at that moment. func (ball *Ball) nearestObstacle(c1 chan int) { distance := [8]int32{61, 136, 211, 286, 361, 436, 511, 586} i := sort.Search(len(distance), func(i int) bool { retu...
src/client/collision.go
0.735642
0.420183
collision.go
starcoder
package mat import ( "math" "github.com/angelsolaorbaiceta/inkmath/nums" "github.com/angelsolaorbaiceta/inkmath/vec" ) /* AreEqual returns true iff matrices have the same number of rows and columns with exactly the same values in matching positions. */ func AreEqual(m1, m2 ReadOnlyMatrix) bool { if m1.Rows() != ...
mat/matrices.go
0.83924
0.65619
matrices.go
starcoder
package element import ( "math" "math/rand" mathex "github.com/locatw/go-ray-tracer/math" . "github.com/locatw/go-ray-tracer/vector" ) type Ray struct { Origin Vector Direction Vector } type HitInfo struct { Object Shape Position Vector Normal Vector T float64 } func CreateRay(origin Vector...
src/github.com/locatw/go-ray-tracer/element/ray.go
0.807385
0.54462
ray.go
starcoder
package dclass // A DataType declares the type of data stored by a Parameter. type DataType int const ( InvalidType DataType = iota // Basic DataTypes Int8Type Int16Type Int32Type Int64Type Uint8Type Uint16Type Uint32Type Uint64Type FloatType StringType BlobType CharType StructType ) // An Error is a...
dclass/types.go
0.703753
0.434341
types.go
starcoder
package rates import ( "errors" "regexp" ) // ErrRateInvalid is the error that signals about invalid rate value var ErrRateInvalid = errors.New("rate must be greater that zero") // Rule is the base class of rule type Rule struct { Rate float64 } // NewRule is the constructor for Rule func NewRule(rate float64) (...
components/rates/rule.go
0.712232
0.447158
rule.go
starcoder
// Package ghash is a constant time 64 bit optimized GHASH implementation. package ghash import "encoding/binary" const blockSize = 16 func bmul64(x, y uint64) uint64 { x0 := x & 0x1111111111111111 x1 := x & 0x2222222222222222 x2 := x & 0x4444444444444444 x3 := x & 0x8888888888888888 y0 := y & 0x11111111111111...
ghash/ghash.go
0.678859
0.422386
ghash.go
starcoder
package circonus import ( "github.com/circonus-labs/circonus-gometrics" "github.com/go-kit/kit/metrics" ) // NewCounter returns a counter backed by a Circonus counter with the given // name. Due to the Circonus data model, fields are not supported. func NewCounter(name string) metrics.Counter { return counter(nam...
vendor/github.com/go-kit/kit/metrics/circonus/circonus.go
0.884346
0.475605
circonus.go
starcoder
package sprite const Font_JR_sm_A = ` XX X X X X XXX X X X X` const Font_JR_sm_B = ` XX X X X X XX X X XX` const Font_JR_sm_C = ` XX X X X X X XX` const Font_JR_sm_D = ` XX X X X X X X X X XX` const Font_JR_sm_E = ` XXX X X XX X XXX` const Font_JR_sm_F = ` XXX X X XX X X` const Font_JR_sm_G = ` XX X X X X X X X...
font_jr_sm.go
0.699152
0.441553
font_jr_sm.go
starcoder
package indexfile import ( "flag" "github.com/brimdata/zed/cmd/zed/dev" "github.com/brimdata/zed/cmd/zed/root" "github.com/brimdata/zed/pkg/charm" ) var Cmd = &charm.Spec{ Name: "indexfile", Usage: "indexfile <command> [options] [arguments...]", Short: "create and search Zed indexes", Long: ` "zed dev index...
cmd/zed/dev/indexfile/command.go
0.562898
0.516108
command.go
starcoder
package h28 // Row of data table. type Row struct { ID string Description string Comment string } // Table of data. type Table struct { ID string Name string Row []Row } // TableLookup provides valid values for field types. var TableLookup = map[string]Table{ `0001`: {ID: `0001`, Name: `Admin...
h28/table.go
0.651909
0.757839
table.go
starcoder
package wkb import ( "encoding/binary" "fmt" "io" "reflect" "github.com/xeonx/geom" ) const ( //XDR is the flag used in WKB to represents Big Endian encoding XDR = 0x00 //LDR is the flag used in WKB to represents Little Endian encoding LDR = 0x01 ) //Type represents a geometry type as defined in the WKB sp...
encoding/wkb/wkb.go
0.675015
0.435181
wkb.go
starcoder
package geom import ( "math" ) const EPS = 1e-9 type Point struct{ x, y float64 } // Model a linear equation ax + by + c = 0. // a is the slope. // b = 0 if it is a vertical line; otherwise b = 1. type Line struct{ a, b, c float64 } // Given two points compute line: ax + by + c = 0. func NewLine(p1, p2 Point) *L...
geom.go
0.814274
0.553204
geom.go
starcoder
package models import ( i878a80d2330e89d26896388a3f487eef27b0a0e6c010c493bf80be1452208f91 "github.com/microsoft/kiota-abstractions-go/serialization" ) // UserExperienceAnalyticsBatteryHealthModelPerformance type UserExperienceAnalyticsBatteryHealthModelPerformance struct { Entity // Number of active devi...
models/user_experience_analytics_battery_health_model_performance.go
0.772788
0.509154
user_experience_analytics_battery_health_model_performance.go
starcoder
package core import ( "bytes" "errors" "image" "image/jpeg" "math" "path" "sync" "github.com/bububa/facenet/imageutil" tf "github.com/tensorflow/tensorflow/tensorflow/go" "github.com/tensorflow/tensorflow/tensorflow/go/op" ) // Net is a wrapper for the TensorFlow Facenet model. type Net struct { model ...
core/net.go
0.690246
0.437643
net.go
starcoder
package main import ( "fmt" "math" ) /* This is the function which implements the jump search algorithm. The input to the function is the sorted array, the element which we are looking for and the size of the sorted array.*/ func search(array []int, element, n int) int { //Size to jump var jump int = int(math.Sq...
Go/search/Jump_Search/JumpSearch.go
0.532182
0.706488
JumpSearch.go
starcoder
package main type CsgOp int const ( CsgUnion CsgOp = iota CsgDifference CsgIntersection ) type Csg struct { Namer Grouper L Groupable R Groupable Op CsgOp OpTest func(bool, bool, bool) bool } // CsgUnion builds a CSG shape that is the union of a set of objects func NewCsgUnion(o ...Groupable...
csg.go
0.642993
0.442335
csg.go
starcoder
package kubernetes import ( "github.com/hashicorp/terraform/helper/schema" ) func podSpecFields(isUpdatable bool) map[string]*schema.Schema { s := map[string]*schema.Schema{ "active_deadline_seconds": { Type: schema.TypeInt, Optional: true, ValidateFunc: validatePositiveInteger, Descriptio...
vendor/github.com/terraform-providers/terraform-provider-kubernetes/kubernetes/schema_pod_spec.go
0.796728
0.511046
schema_pod_spec.go
starcoder
// Go is a pass by value language (no exception here) package main import "fmt" // declaring a function that takes an int, a float, a string and a bool value. // the function works on copy so the changes are not seen outside (pass by value) func changeValues(quantity int, price float64, name string, sold bool) { q...
78_master-go-programing/10 - pointers/2 - passing values and pointers to functions/main.go
0.534127
0.478955
main.go
starcoder
package btcjson import ( "errors" ) // defaultHelpStrings contains the help text for all commands that are supported // by btcjson by default. var defaultHelpStrings = map[string]string{ "addmultisigaddress": `addmultisigaddress nrequired ["key",...] ("account" ) Add a multisignature address to the wallet where 'n...
cmdhelp.go
0.582729
0.421969
cmdhelp.go
starcoder
package petstore import ( "encoding/json" ) // Capitalization struct for Capitalization type Capitalization struct { SmallCamel *string `json:"smallCamel,omitempty"` CapitalCamel *string `json:"CapitalCamel,omitempty"` SmallSnake *string `json:"small_Snake,omitempty"` CapitalSnake *string `json:"Capital_Snake,o...
samples/client/petstore/go/go-petstore/model_capitalization.go
0.774839
0.407157
model_capitalization.go
starcoder
package kdtree import ( "errors" "gonum.org/v1/gonum/mat" "github.com/sjwhitworth/golearn/metrics/pairwise" "sort" ) type node struct { feature int value []float64 srcRowNo int left *node right *node } // Tree is a kdtree. type Tree struct { firstDiv *node data [][]float64 } type SortData ...
vendor/github.com/sjwhitworth/golearn/kdtree/kdtree.go
0.629775
0.450178
kdtree.go
starcoder
package test import ( "testing" cdata "github.com/pip-services3-go/pip-services3-commons-go/data" "github.com/stretchr/testify/assert" ) type DummyPersistenceFixture struct { dummy1 Dummy dummy2 Dummy persistence IDummyPersistence } func NewDummyPersistenceFixture(persistence IDummyPersistence) *Dum...
test/fixtures/DummyPersistenceFixture.go
0.588534
0.631765
DummyPersistenceFixture.go
starcoder
package v1alpha1 // GatewayListerExpansion allows custom methods to be added to // GatewayLister. type GatewayListerExpansion interface{} // GatewayNamespaceListerExpansion allows custom methods to be added to // GatewayNamespaceLister. type GatewayNamespaceListerExpansion interface{} // InsightsListerExpansion all...
client/listers/application/v1alpha1/expansion_generated.go
0.542136
0.410756
expansion_generated.go
starcoder
package itertools import ( "github.com/Tom-Johnston/mamba/ints" ) //PermutationIterator is a struct containing the state of the iterator. //It iterates over permutations according to Heap's algorithm. type PermutationIterator struct { n int i int c []int p []int } //Permutations returns a new permuation iterato...
itertools/permutations.go
0.76207
0.483587
permutations.go
starcoder
Package pkg provides libraries for building Controllers. Controllers implement Kubernetes APIs and are foundational to building Operators, Workload APIs, Configuration APIs, Autoscalers, and more. Client Client provides a Read + Write client for reading and writing Kubernetes objects. Cache Cache provides a Read c...
pkg/doc.go
0.791176
0.651182
doc.go
starcoder
package bloomtree import ( "crypto/sha512" "errors" "fmt" "math" "sort" "github.com/willf/bitset" ) // BloomFilter interface. Requires two methods: // The BitArray method - returns the bloom filter as a bit array. // The Proof method - If the element is in the bloom filter, it returns: // indices, true (where ...
bloomTree.go
0.665954
0.481698
bloomTree.go
starcoder
package pkg import ( "fmt" "reflect" "time" ) // EvaluateMultiplication will evaluate multiplication operation over two value func EvaluateMultiplication(left, right reflect.Value) (reflect.Value, error) { switch left.Kind() { case reflect.Int, reflect.Int8, reflect.Int16, reflect.Int32, reflect.Int64: lv := l...
pkg/reflectmath.go
0.718792
0.701847
reflectmath.go
starcoder
// Package view provides a simple API for formatting dates as strings in a manner that is easy to use in view-models, // especially when using Go templates. package view import ( "github.com/simplylizz/date" ) const ( // DMYFormat is a typical British representation. DMYFormat = "02/01/2006" // MDYFormat is a ty...
view/vdate.go
0.872497
0.595757
vdate.go
starcoder
package main import ( "container/heap" "sort" ) // Any is anything type Any = interface{} // HuffmanNode a node in a Huffman tree. type HuffmanNode struct { // left points to the left HuffmanNode. left *HuffmanNode // right points to the right HuffmanNode. right *HuffmanNode // token stored by a node. // If ...
huffman.go
0.664976
0.443179
huffman.go
starcoder
package schedule import ( "errors" "fmt" "math" "strconv" "strings" "time" ) type TimeUnit int const timefmt = "2006-01-02 15:04:05" const ( Minute TimeUnit = iota Hour Day Week Month Year ) var nilTime time.Time var tuLookup = map[string]TimeUnit{ "Minute": Minute, "Hour": Hour, "Day": Day, ...
schedule/sched.go
0.678966
0.442456
sched.go
starcoder
package db import ( "reflect" "time" ) // Comparison defines methods for representing comparison operators in a // portable way across databases. type Comparison interface { Operator() ComparisonOperator Value() interface{} } // ComparisonOperator is a type we use to label comparison operators. type Comparison...
comparison.go
0.817246
0.531696
comparison.go
starcoder
package siesta import ( "errors" "fmt" "io" "net" "strconv" "strings" "sync" "time" ) // InvalidOffset is a constant that is used to denote an invalid or uninitialized offset. const InvalidOffset int64 = -1 // Connector is an interface that should provide ways to clearly interact with Kafka cluster and hide...
vendor/github.com/elodina/siesta/connector.go
0.696887
0.414543
connector.go
starcoder
package processor import ( "github.com/Jeffail/benthos/lib/log" "github.com/Jeffail/benthos/lib/metrics" "github.com/Jeffail/benthos/lib/types" ) //------------------------------------------------------------------------------ func init() { Constructors["split"] = TypeSpec{ constructor: NewSplit, descriptio...
lib/processor/split.go
0.592549
0.480418
split.go
starcoder
package structs /// <summary> /// Represents the IMAGE_FILE_HEADER structure from <see href="https://docs.microsoft.com/en-us/windows/desktop/api/winnt/ns-winnt-_image_file_header">here</see> /// </summary> type FileHeader struct { /// <summary> /// The architecture type of the computer. An image file can only be ru...
structs/fileheader.go
0.897139
0.406538
fileheader.go
starcoder
package dstream import "fmt" type concatHorizontal struct { // The streams to be concatenated streams []Dstream // All names in all streams (in the same order used by // GetPos). names []string // The index of the current stream within streams pos int // The number of observations in the concatenated stre...
dstream/concathorizontal.go
0.727007
0.459986
concathorizontal.go
starcoder
package geom import ( "math" ) // epsilon32 is the machine epsilon, or the upper bound on the relative error due to rounding in floating point arithmatic var epsilon32 = float32(math.Nextafter32(1, 2) - 1) const ( pi = 3.14159265358979323846264338327950288419716939937510582097494459 // http://oeis.org/A000796 ...
math.go
0.807461
0.594404
math.go
starcoder
package geometry // Alignment options for different vertex attribute layouts const ( ALIGN_MULTI_BATCH = 0 // having each attribute in a different slice (1111)(2222)(3333) ALIGN_SINGLE_BATCH = 1 // having all attributes in one slice but batched (111122223333) ALIGN_INTERLEAVED = 2 // having all attributes in one ...
pkg/view/geometry/geometry.go
0.732879
0.501465
geometry.go
starcoder
package ts // SlicePkt implements Pkt interface and represents MPEG-TS packet that can be // a slice of some more data (eg. slice of buffer that contains more packets). // Use it only when you can't use ArrayPkt. Assigning variable of type SlicePkt // to variable of type Pkt causes memory allocation (you can use *Slic...
ts/slicepkt.go
0.713032
0.559771
slicepkt.go
starcoder