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 ycsb import ( "context" "fmt" "github.com/magiconair/properties" ) // DBCreator creates a database layer. type DBCreator interface { Create(p *properties.Properties) (DB, error) } // DB is the layer to access the database to be benchmarked. type DB interface { // Close closes the database layer. Clos...
pkg/ycsb/db.go
0.58818
0.405007
db.go
starcoder
// A sequence of elements supporting sequential and parallel aggregate // operations. The following example illustrates an aggregate operation using // SEE java/util/function/Consumer.java package spliterator import ( "context" "github.com/searKing/golang/go/util/function/consumer" "github.com/searKing/golang/go...
go/util/spliterator/spliterator.go
0.891221
0.605974
spliterator.go
starcoder
package missing_authentication import ( "github.com/threagile/threagile/model" ) func Category() model.RiskCategory { return model.RiskCategory{ Id: "missing-authentication", Title: "Missing Authentication", Description: "Technical assets (especially multi-tenant systems) should authenticate in...
risks/built-in/missing-authentication/missing-authentication-rule.go
0.663124
0.426262
missing-authentication-rule.go
starcoder
Package admission provides functions to manage webhooks certificates. There are 3 typical ways to use this library: * The sync function can be used as a Reconcile function. * Invoking it directly fromt eh webhook server at startup. * Deploying it as an init container along with the webhook server. Webhook Configur...
examples/godocbot/vendor/sigs.k8s.io/controller-runtime/pkg/admission/doc.go
0.573081
0.464659
doc.go
starcoder
package main import "fmt" // A wire is modeled as a channel of booleans. // You can feed it a single value without blocking. // Reading a value blocks until a value is available. type Wire chan bool func MkWire() Wire { return make(Wire, 1) } // A source for zero values. func Zero() (r Wire) { r = MkWire() go fu...
tasks/Four-bit-adder/four-bit-adder-2.go
0.721449
0.611295
four-bit-adder-2.go
starcoder
package linode import ( "context" "fmt" "github.com/hashicorp/terraform-plugin-sdk/helper/schema" "github.com/linode/linodego" ) func dataSourceLinodeInstanceType() *schema.Resource { return &schema.Resource{ Read: dataSourceLinodeInstanceTypeRead, Schema: map[string]*schema.Schema{ "id": { Type: ...
vendor/github.com/terraform-providers/terraform-provider-linode/linode/data_source_linode_instance_type.go
0.536313
0.407628
data_source_linode_instance_type.go
starcoder
package basic // MergeTestPtr is template to generate itself for different combination of data type. func MergeTestPtr() string { return ` func TestMerge<FINPUT_TYPE1><FINPUT_TYPE2>Ptr(t *testing.T) { var v1 <INPUT_TYPE1> = 1 var v2 <INPUT_TYPE1> = 2 var v3 <INPUT_TYPE1> = 3 var v4 <INPUT_TYPE1> = 4 var v5 <INPU...
internal/template/basic/mergeptrtest.go
0.519521
0.594257
mergeptrtest.go
starcoder
package automaton import ( "container/list" "fmt" "github.com/balzaczyy/golucene/core/util" "unicode" ) // Basic automata operations. /* Returns an automaton that accepts the concatenation of the languages of the given automata. Complexity: linear in total number of states. */ func concatenate(a1, a2 *Automaton...
vendor/github.com/balzaczyy/golucene/core/util/automaton/operations.go
0.75392
0.421611
operations.go
starcoder
package main import ( "image/color" "math" "github.com/hajimehoshi/ebiten" ) func limita(valor, minimo, maximo float32) float32 { if valor < minimo { return minimo } else if valor > maximo { return maximo } else { return valor } } var ( imagemVazia = ebiten.NewImage(2, 2) bolaNumVertic...
blockbreaker/util.go
0.506347
0.452354
util.go
starcoder
package telematics import ( "encoding/binary" "errors" "math" "go.mongodb.org/mongo-driver/bson/bsonrw" "go.mongodb.org/mongo-driver/bson/bsontype" ) // sampling data is an efficient binary-packed format // each []byte data field contains a set of samples (4 bytes per sample) // each sample contains 3 values of...
lib/telematics/types_sampling.go
0.787686
0.543348
types_sampling.go
starcoder
// kvstring package contains functions for representing string key:value pairs as one string and converting // such strings to maps etc. package kvstring import ( "fmt" "github.com/pkg/errors" "strconv" ) const ( KeyValueSeparator = "=" FieldsSeparator = "," ) // RemoveCurlyBraces trims leading and trailing ...
pkg/utils/kvstring/kvstring.go
0.661704
0.498718
kvstring.go
starcoder
package utils import ( "crypto/rand" "encoding/binary" "math/big" "github.com/centrifuge/go-centrifuge/errors" "github.com/centrifuge/gocelery" "github.com/ethereum/go-ethereum/common" "github.com/ethereum/go-ethereum/common/hexutil" ) // ContainsBigIntInSlice checks if value is present in list. func Contains...
utils/tools.go
0.754282
0.510741
tools.go
starcoder
package zklog import ( "crypto/rand" "github.com/Zondax/multi-party-sig/pkg/hash" "github.com/Zondax/multi-party-sig/pkg/math/curve" "github.com/Zondax/multi-party-sig/pkg/math/sample" ) type Public struct { // H = b⋅G H curve.Point // X = a⋅G X curve.Point // Y = a⋅H Y curve.Point } type Private struct...
pkg/zk/log/log.go
0.77081
0.406126
log.go
starcoder
package mongodb import ( "time" "github.com/eroatta/src-reader/entity" "github.com/google/uuid" ) // analysisMapper maps an AnalysisResults entity between its model and database representation. type analysisMapper struct{} // toDTO maps the entity for AnalysisResults into a Data Transfer Object. func (am *analys...
port/outgoing/adapter/repository/mongodb/analysis_mapper.go
0.636692
0.444083
analysis_mapper.go
starcoder
package ark import "fmt" type vector2DProperty struct { X float32 `json:"x"` Y float32 `json:"y"` } func (p *vector2DProperty) Type() PropertyType { return StructVector2DPropertyType } func (p *vector2DProperty) String() string { return fmt.Sprintf("StructVector2DProperty()") } func readVector2DStruct(dataSize ...
struct_vector.go
0.761627
0.417509
struct_vector.go
starcoder
package poly import ( "github.com/adamcolton/geom/calc/comb" poly1d "github.com/adamcolton/geom/calc/poly" "github.com/adamcolton/geom/d2" ) // Coefficients wraps the concept of a list of d2.V. It must return the length // and be able to return the coefficient at any index. type Coefficients interface { Coefficie...
d2/curve/poly/coefficients.go
0.858199
0.733571
coefficients.go
starcoder
package transform import ( "image" "image/draw" "math" "github.com/urandom/drawgl" "github.com/urandom/drawgl/interpolator" "github.com/urandom/drawgl/operation/transform/matrix" ) type transformOperation struct { matrix matrix.Matrix3 interpolator string dstB image.Rectangle } func affine(op...
operation/transform/matrix.go
0.72331
0.528777
matrix.go
starcoder
package go_pwentropy import ( "math" "strings" ) // Given a provided password, it will return the number of entropy bits. It is calculated estimating the symbols classes // used in the password, i.e. if there are only lower case characters, if there are lower and upper cases, if it contains // numbers, etc. func En...
entropy.go
0.68342
0.407392
entropy.go
starcoder
package main import ( "context" "fmt" "sync" "time" ) /* Getting the fastest result from multiple sources In some cases, for example, while integrating information retrieval from multiple sources, you only need the first result, the fastest one, and the other results are irrelevant after that. An example from the...
concurrency/first.go
0.61555
0.642461
first.go
starcoder
package board type Size struct { XSize uint8 `json:"x_size"` YSize uint8 `json:"y_size"` ZSize uint8 `json:"z_size"` } func uint8ArrayToSize(array [3]uint8) Size { return Size{array[0], array[1], array[2]} } func (s Size) getFlattenSize() int { return int(s.XSize) * int(s.YSize) * int(s.ZSize) } func (s Size) T...
internal/board/position.go
0.805058
0.525491
position.go
starcoder
package nn import ( "math" ) // Tensor is an algebraic object that describes a relationship between sets of algebraic objects related to a vector space. type Tensor struct { shape Shape rawData []float64 } // NewTensor creates an instance of tensor. func NewTensor(shape Shape) *Tensor { return &Tensor{ shape...
nn/tensor.go
0.896305
0.78838
tensor.go
starcoder
package ringct import "C" import ( . "github.com/lianxiangcloud/linkchain/libs/cryptonote/types" "github.com/lianxiangcloud/linkchain/libs/cryptonote/xcrypto" ) var Z = Key{0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00,...
libs/cryptonote/ringct/rctops.go
0.556641
0.626567
rctops.go
starcoder
package cimg import ( "errors" "fmt" "image" ) // Image is the concrete image type that is used by all functions inside cimg type Image struct { Pixels []byte Width int Height int Stride int Format PixelFormat Premultiplied bool } // NChan returns the number of channels o...
v2/image.go
0.713432
0.566019
image.go
starcoder
package wav import ( "fmt" "math" ) // ConvertTo44100Hz2Channels16BitSamples returns the input parameter if the // format is already correct (no copying is done in this case). Otherwise a new // Wave structure is returned and its data is converted to the specified format. // In any case the original data is not cha...
wav/resample.go
0.73412
0.449634
resample.go
starcoder
// Copyright 2017 Microsoft Corporation. All rights reserved. // Use of this source code is governed by an MIT // license that can be found in the LICENSE file. /* Package azblob can access an Azure Blob Storage. The azblob package is capable of :- - Creating, deleting, and querying containers in an account ...
sdk/storage/azblob/doc.go
0.769167
0.42656
doc.go
starcoder
package f32 import "fmt" // A Mat4 is a 4x4 matrix of float32 values. // Elements are indexed first by row then column, i.e. m[row][column]. type Mat4 [4]Vec4 func (m Mat4) String() string { return fmt.Sprintf(`Mat4[% 0.3f, % 0.3f, % 0.3f, % 0.3f, % 0.3f, % 0.3f, % 0.3f, % 0.3f, % 0.3f, % 0.3f, % 0.3f, %...
vendor/github.com/fyne-io/mobile/exp/f32/mat4.go
0.575946
0.586079
mat4.go
starcoder
package query import "fmt" type bucketizer string var ( // BUCKETIZERS // BucketizerSum computes the sum of all the values found in the interval to bucketize BucketizerSum bucketizer = "bucketizer.sum" // BucketizerMax returns the max of all the values found on the interval to bucketize BucketizerMax bucketiz...
query/bucketizers.go
0.801315
0.410638
bucketizers.go
starcoder
package rtc import ( "log" ) // Group creates a group of objects at the origin. // It implements the Object interface. func Group(shapes ...Object) *GroupT { g := &GroupT{Shape: Shape{Transform: M4Identity(), Material: GetMaterial()}, bounds: Bounds()} g.AddChild(shapes...) return g } // AddChild adds shape(s) t...
rtc/group.go
0.863909
0.411584
group.go
starcoder
package commands import ( "bytes" "fmt" "reflect" "regexp" "strconv" "strings" ) func stringValue(primitive reflect.Value) (string, error) { switch primitive.Kind() { case reflect.Int: fallthrough case reflect.Int8: fallthrough case reflect.Int16: fallthrough case reflect.Int32: fallthrough case r...
internal/commands/filter.go
0.57821
0.466177
filter.go
starcoder
package colorrange import ( "image/color" "github.com/200sc/go-dist/intrange" ) // Linear64 color ranges return colors on a linear distribution type Linear64 struct { r, g, b, a intrange.Range } // NewLinear64 returns a linear color distribution between min and maxColor func NewLinear64(minColor, maxColor color....
colorrange/linear.go
0.920222
0.523055
linear.go
starcoder
package plantest import ( "testing" "github.com/google/go-cmp/cmp" "github.com/influxdata/flux/plan" "github.com/influxdata/flux/semantic/semantictest" "github.com/influxdata/flux/stdlib/influxdata/influxdb" "github.com/influxdata/flux/stdlib/universe" ) // SimpleRule is a simple rule whose pattern matches any...
plan/plantest/rules.go
0.717705
0.432243
rules.go
starcoder
package window import ( "fmt" "strconv" "strings" "time" "github.com/cockroachdb/errors" ) type rate struct { n int unit rateUnit } func makeUnlimitedRate() rate { return rate{n: -1} } func (r rate) IsUnlimited() bool { return r.n == -1 } type rateUnit int const ( ratePerSecond = iota ratePerMinute...
enterprise/internal/batches/types/scheduler/window/rate.go
0.688364
0.402245
rate.go
starcoder
package uncertainty // numCompareSamples is the number of samples to materialize to generate a comparison. // Follows the paper in choice of value. // TODO(barakmich): maybe worth exposing in some broader way. const numCompareSamples = 10_000 type compareFunc func(x float64, y float64) bool type comparisonOperation ...
equality.go
0.546254
0.701656
equality.go
starcoder
package timebox import ( "time" ) //Set is a container with zero or more slots in it. Slots in a set may overlap each other. //You can use the set to calculate lanes from the slots inside. type Set struct { slots []*Slot } //NewSet creates a new set. func NewSet() *Set { return &Set{} } //Add adds a new slot to ...
set.go
0.789193
0.423637
set.go
starcoder
package source import ( "go/ast" "go/types" ) // builtinArgKind determines the expected object kind for a builtin // argument. It attempts to use the AST hints from builtin.go where // possible. func (c *completer) builtinArgKind(obj types.Object, call *ast.CallExpr) objKind { astObj, err := c.snapshot.View().Loo...
internal/lsp/source/completion_builtin.go
0.607197
0.444083
completion_builtin.go
starcoder
package intcode import "github.com/afarbos/aoc/pkg/convert" type opcode int // OpCodes enumeration of operation code. const ( // Add paramater 1 and 2 and store it in 3 Add opcode = iota + 1 // Multiply paramater 1 and 2 and store it in 3 Multiply // Input stored at parameter 1 Input // Output the value of pa...
pkg/intcode/intcode.go
0.528777
0.451992
intcode.go
starcoder
package kafkawireformat import ( "hash/crc32" ) type Records interface { } // the length field of a RecordBatch denotes the length of the entire message // this is the byte size of the static "overhead" (the size of the metadata fields) // the number of actual bytes that contain Records (or the payload) of this ...
src/main/resources/records.go
0.750461
0.460046
records.go
starcoder
package keybinary import ( "encoding/base64" ) const ( expectEncodedByteArray32 = 43 // base64.RawStdEncoding.EncodedLen(32) expectEncodedByteArray64 = 86 // base64.RawStdEncoding.EncodedLen(64) ) var emptyByteArray32 [32]byte var emptyByteArray64 [64]byte // ByteArray32 contain a 32 bytes array. type ByteArray3...
bytearray.go
0.773302
0.50061
bytearray.go
starcoder
package openapi import ( "encoding/json" ) // ProjectCreate struct for ProjectCreate type ProjectCreate struct { // The ID of the parent of the project. If specified on project creation, this places the project within a hierarchy and implicitly defines the owning domain, which will be the same domain as the paren...
openapi/model_project_create.go
0.700383
0.491761
model_project_create.go
starcoder
package foundation // #include "affine_transform.h" import "C" import ( "unsafe" "github.com/hsiafan/cocoa/coregraphics" "github.com/hsiafan/cocoa/objc" ) type AffineTransform interface { objc.Object RotateByDegrees(angle coregraphics.Float) RotateByRadians(angle coregraphics.Float) ScaleBy(scale coregraphics...
foundation/affine_transform.go
0.659186
0.40645
affine_transform.go
starcoder
package aoc2020 /* --- Day 22: Crab Combat PART 2--- You lost to the small crab! Fortunately, crabs aren't very good at recursion. To defend your honor as a Raft Captain, you challenge the small crab to a game of Recursive Combat. Recursive Combat still starts by splitting the cards into two decks (you offer to play ...
app/aoc2020/aoc2020_22_part2.go
0.709019
0.813794
aoc2020_22_part2.go
starcoder
package reporting import ( "fmt" "io" "os" "sort" "time" "github.com/jinzhu/now" "github.com/markosamuli/glassfactory/model" "github.com/markosamuli/glassfactory/pkg/dateutil" "github.com/olekukonko/tablewriter" ) // FiscalYear represents a time range for a fiscal year type FiscalYear struct { Start time.T...
reporting/fiscal_year.go
0.638046
0.467028
fiscal_year.go
starcoder
package crosslink import ( "math" "unsafe" ) // RangeTriggerNode is a node that belongs to a RangeTrigger // each RangeTrigger has 2 RangeTriggerNode, one positive and one negative, represents 2 sides of a range // it implements CLPosImp as CLNode does type RangeTriggerNode struct { CLNode rangeX CLPosValType...
aoi/aoi_cross_link/range_trigger.go
0.72487
0.505737
range_trigger.go
starcoder
// Package xor implements a nearest-neighbor data structure for the XOR-metric package xor import ( "errors" "fmt" "strconv" "unsafe" ) // Key represents a point in the XOR-space type Key uint64 // Key implements interface Item func (id Key) Key() Key { return id } // Bit returns the k-th MSB. k ranges from 0...
src/circuit/kit/xor/xor.go
0.852537
0.421373
xor.go
starcoder
package indicator import ( "sync" "time" "github.com/evsamsonov/trading-timeseries/timeseries" ) const oneDay = time.Hour * 24 // VolumeWeightedAveragePrice represents indicator to calculate volume-weighted average price (VWAP). // More details https://en.wikipedia.org/wiki/Volume-weighted_average_price type Vol...
indicator/volume_weighted_average_price.go
0.777046
0.4231
volume_weighted_average_price.go
starcoder
package DG2D import ( "fmt" "math" "github.com/notargets/gocfd/DG1D" "github.com/notargets/gocfd/utils" ) type RTBasis2DSimplex struct { P int // Polynomial Order Np int // Number of terms and nodes in basis NpInt, NpEdge int // Number of nodes in interior an...
DG2D/RTElement.go
0.640973
0.657318
RTElement.go
starcoder
package factMapper // tracker is a simple module that maps from a set of facts to a set of labels // based on a set of supplied mapping rules. type tracker struct { // lookup tables derived from the current mapping rules tables *lookupTables // the current set of known facts currentFacts map[string]string // t...
adapters/factMapper/tracker.go
0.720368
0.591723
tracker.go
starcoder
package encoding // Data tables for 4-byte characters in GB18030 encoding. // Based on http://source.icu-project.org/repos/icu/data/trunk/charset/data/ucm/gb-18030-2005.ucm // gb18030Linear converts a 32-bit big-endian representation of a 4-byte // character into a linearly-increasing integer, starting from the base ...
gb18030-data.go
0.658308
0.428652
gb18030-data.go
starcoder
package p295 /** Median is the middle value in an ordered integer list. If the size of the list is even, there is no middle value. So the median is the mean of the two middle value. Examples: [2,3,4] , the median is 3 [2,3], the median is (2 + 3) / 2 = 2.5 Design a data structure that supports the following two ope...
algorithms/p295/295.go
0.810441
0.787992
295.go
starcoder
package tetra3d import ( "math" "sort" "time" "github.com/hajimehoshi/ebiten/v2" "github.com/kvartborg/vector" ) // Model represents a singular visual instantiation of a Mesh. A Mesh contains the vertex information (what to draw); a Model references the Mesh to draw it with a specific // Position, Rotation, and...
model.go
0.810816
0.682561
model.go
starcoder
package main import ( "fmt" log "github.com/sirupsen/logrus" ) type board struct { Solution []*Square Squares [9]*Square CurrentPosition int8 } // Recursive function that takes the current solution and unused squares // and determines the position/orientation of the next empty position func (b *b...
board.go
0.626238
0.40539
board.go
starcoder
package main import ( "bytes" "fmt" "go/format" "io/ioutil" "log" "os" "text/template" "time" ) type unitType struct { Name string Receiver string Description string Type string Unit string ShortUnit string } var unitTypes = []unitType{ {"TimeOffset", "time", "is the elapsed ...
internal/autogen_types.go
0.623721
0.489015
autogen_types.go
starcoder
package sod_shock_tube import ( "fmt" "time" "github.com/notargets/gocfd/DG2D" "github.com/notargets/gocfd/model_problems/Euler1D" "github.com/notargets/gocfd/utils" ) type InterpolationTarget struct { ElementNumber int // Global K element address RS [2]float64 // Coordinat...
model_problems/Euler2D/sod_shock_tube/shock_tube.go
0.663342
0.492066
shock_tube.go
starcoder
func max(a []int) int { result := -1 for i := 0; i < len(a); i++ { if a[i] > result { result = a[i] } } return result } // ref: https://leetcode.com/problems/cherry-pickup/discuss/165218/Java-O(N3)-DP-solution-w-specific-explanation func cherryPickup(grid [][]int) int { ...
leetcode/cherry-pickup/solution.go
0.680242
0.472744
solution.go
starcoder
package data import ( "fmt" ) // Maze describes a maze type Maze struct { width, height int cells []*Cell in, out *DoorPosition } // NewMaze prepares maze as a matrix of cells with all walls set func NewMaze(width, height int) *Maze { length := width * height cells := make([]*Cell, length) for i...
pkg/maze/data/maze.go
0.785391
0.46223
maze.go
starcoder
package models import ( i878a80d2330e89d26896388a3f487eef27b0a0e6c010c493bf80be1452208f91 "github.com/microsoft/kiota-abstractions-go/serialization" ) // AttackSimulationRoot provides operations to manage the attackSimulation property of the microsoft.graph.security entity. type AttackSimulationRoot struct { ...
models/attack_simulation_root.go
0.756268
0.569015
attack_simulation_root.go
starcoder
package linode import ( "context" "encoding/json" "fmt" "strconv" "github.com/hashicorp/terraform-plugin-sdk/helper/schema" "github.com/linode/linodego" ) func dataSourceLinodeDomainRecord() *schema.Resource { return &schema.Resource{ Read: dataSourceLinodeDomainRecordRead, Schema: map[string]*schema.Sch...
vendor/github.com/terraform-providers/terraform-provider-linode/linode/data_source_linode_domain_record.go
0.552298
0.404625
data_source_linode_domain_record.go
starcoder
package ast import ( "fmt" "reflect" "sort" "strconv" "strings" "github.com/cozees/cook/pkg/cook/token" "github.com/cozees/cook/pkg/runtime/args" ) func indexes(ctx Context, ns ...Node) (rg []int, err error) { for _, n := range ns { si, sk, err := n.Evaluate(ctx) if err != nil { return nil, err } el...
pkg/cook/ast/common.go
0.549641
0.438304
common.go
starcoder
package matchers import ( "fmt" "strings" "github.com/onsi/gomega/types" ) func LookLike(expected string) types.GomegaMatcher { return &lookLikeMatcher{expected: prepare(expected)} } type lookLikeMatcher struct { expected string } var whitespaceReplacer = strings.NewReplacer( " ", "␣", "\t", "⇥", ) func (m...
spec/matchers/looklike.go
0.650023
0.436202
looklike.go
starcoder
package main import ( "fmt" "math" "strconv" "strings" ) /** --- Day 9: Encoding Error --- With your neighbor happily enjoying their video game, you turn your attention to an open data port on the little screen in the seat in front of you. Though the port is non-standard, you manage to connect it to your comput...
day09.go
0.606498
0.600569
day09.go
starcoder
package geom //MultiPoint is a collection of two-dimensional geometries representing points type MultiPoint []Point //MultiPointZ is a collection of three-dimensional geometries representing points type MultiPointZ []PointZ //MultiPointM is a collection of two-dimensional geometries representing points, with an add...
multipoint.go
0.871584
0.680132
multipoint.go
starcoder
package dax import ( math "github.com/dlespiau/dax/math" ) // Color represents a color encoded in RGBA. type Color struct { R, G, B, A float32 } // FromRGBA initializes a color from (r,g,b,a) values. Components should be // between 0 and 1. func (color *Color) FromRGBA(r, g, b, a float32) { color.R = r color.G =...
color.go
0.850841
0.597461
color.go
starcoder
package math import ( "errors" "math" ) // checkHistograms check if the histograms are correct. func checkHistograms(hist1, hist2 []float64) error { if len(hist1) == 0 || len(hist2) == 0 { return errors.New("Could not compare the histograms. The histogram is empty.") } if len(hist1) != len(hist2) { return er...
math/math.go
0.84338
0.524395
math.go
starcoder
package pkg import ( "fmt" "golang.org/x/exp/constraints" "math" ) const strNilNode = "_" type BinaryTree[T constraints.Ordered] struct { root *TreeNode[T] } func (b *BinaryTree[T]) Insert(value T) { if b.root == nil { b.root = &TreeNode[T]{Value: value} return } treeNodeAdd(b.root, value) } func (b *B...
spells/data-structures/pkg/binarytree.go
0.692226
0.502625
binarytree.go
starcoder
package gen import ( "fmt" "sort" "github.com/badvassal/wllib/gen/wlerr" ) // Point represents 2d coordinates or a width,height pair. type Point struct { X int Y int } // ExtractBlob copies a subsequence of bytes from a larger sequence. off is // the offset within section to start the copy. end is the offset...
gen/gen.go
0.642769
0.441252
gen.go
starcoder
package bitmaptable import ( "errors" "github.com/boljen/go-bitmap" ) // These are errors that can be returned by the Bitmaptable. var ( ErrIllegalIndex = errors.New("Bitmaptable: Illegal identifier or position") ErrIllegalWidth = errors.New("Bitmaptable: Illegal value width, must be between 1 and 64") ) // Bit...
bitmaptable.go
0.747432
0.564098
bitmaptable.go
starcoder
package lib import ( "log" "math/rand" "net/http" "time" ) // TwoChoice struct contains: // - A slice of node pointers // - A set of indexes to healthy nodes (as a map) // - A set of indexes to unhealthy ndoes (as a map) type TwoChoice struct { Nodes []*Node HealthyNodes map[int]bool UnhealthyNodes ...
lib/twochoice.go
0.556159
0.40539
twochoice.go
starcoder
package tree import ( "fmt" "math" ) //Node represents a node in a binary tree type BTNode struct { data int left *BTNode right *BTNode } type BinaryTree struct { root *BTNode } func NewBinaryTree() *BinaryTree { return &BinaryTree{} } //NewNode creates a new node to be inserted in bst func NewBTNode(data...
tree/binaryTree.go
0.708717
0.420897
binaryTree.go
starcoder
package dlogproofs import ( "math/big" "github.com/xlab-si/emmy/crypto/common" "github.com/xlab-si/emmy/crypto/groups" ) // Verifies that the blinded transcript is valid. That means the knowledge of log_g1(t1), log_G2(T2) // and log_g1(t1) = log_G2(T2). Note that G2 = g2^gamma, T2 = t2^gamma where gamma was chose...
crypto/zkp/primitives/dlogproofs/dlog_equality_blinded_transcript_ec.go
0.681197
0.412648
dlog_equality_blinded_transcript_ec.go
starcoder
package client import ( "crypto" "fmt" "io" "math" pb "github.com/google/go-tpm-tools/proto/tpm" "github.com/google/go-tpm/tpm2" ) // NumPCRs is set to the spec minimum of 24, as that's all go-tpm supports. const NumPCRs = 24 // We hard-code SHA256 as the policy session hash algorithms. Note that this // diff...
vendor/github.com/google/go-tpm-tools/client/pcr.go
0.602062
0.421433
pcr.go
starcoder
package spritenik // code and blog from https://github.com/jakesgordon/bin-packing func NewNode(name string, width, height int) *Node { return &Node{Key: name, Width: width, Height: height} } type Node struct { Key string Width int Height int X int Y int Used bool Right *Node Down *Node } ...
growing_packer.go
0.705176
0.560734
growing_packer.go
starcoder
package main func parsePlayer(b *Buffer) { checkVers(b, 1, "Player") b.GetInt32le() // planetID b.GetFloat32() // position.x b.GetFloat32() // position.y b.GetFloat32() // uPosition.z b.GetFloat64() // uPosition.x b.GetFloat64() // uPosition.y b.GetFloat64() // uPosition.z b.GetFloat32() // uRotation.x b.Ge...
cmd/parsefile/parse_player.go
0.501465
0.412944
parse_player.go
starcoder
package support import ( "strings" "unicode" "github.com/fatih/camelcase" ) // IsCamelCase checks if a string is camelCase. func IsCamelCase(str string) bool { return !isFirstRuneDigit(str) && isMadeByAlphanumeric(str) && unicode.IsLower(runeAt(str, 0)) } // IsChainCase checks if a string is a chain-case. func ...
support/string.go
0.66072
0.516778
string.go
starcoder
package genlsystem import ( "bufio" "fmt" "github.com/Flokey82/go_gens/vectors" "image/color" "math" "os" ) type Bounds3d struct { minX, minY, minZ float64 maxX, maxY, maxZ float64 } func (a *Bounds3d) AddPoint(x, y, z float64) { if a.minX > x { a.minX = x } if a.maxX < x { a.maxX = x } if a.minY > ...
genlsystem/turtlegraph3d.go
0.795301
0.42477
turtlegraph3d.go
starcoder
package g // --- --- --- --- --- --- --- --- --- --- --- --- --- --- --- --- --- --- --- --- // HTML Audio / Video Methods - http://www.w3schools.com/tags/ref_av_dom.asp // --- --- --- --- --- --- --- --- --- --- --- --- --- --- --- --- --- --- --- --- func (ele *ELEMENT) AddTextTrack(eval string) *ELEMENT { return ...
markup/html_av.go
0.563378
0.42179
html_av.go
starcoder
package graph // PageRank implements type PageRank struct { DirectedNetwork [][]bool H [][]float64 G [][]float64 Rank map[int64]float64 Directed map[int64]bool NodeNum int64 } // NewPageRank return pagerank func NewPageRank(nodeNum int64, edges [][2]int64) *...
graph/pagerank.go
0.566019
0.439928
pagerank.go
starcoder
package mpc import ( "crypto/rand" "fmt" "math/big" mr "math/rand" ) var one = new(big.Int).SetInt64(1) // GenerateShares generates `n` shares such that (`s_1` + ... + `s_n`) mod `M` = `secret` func GenerateShares(secret int64, n int, M *big.Int) []*big.Int { s := new(big.Int).SetInt64(secret) sum := new(big.I...
secret_sharing.go
0.70304
0.416737
secret_sharing.go
starcoder
package testgomavlib import ( "bytes" "errors" "math" "reflect" "regexp" "strings" "testing" "github.com/stretchr/testify/assert" "github.com/stretchr/testify/require" "github.com/team-rocos/gomavlib" libgen "github.com/team-rocos/gomavlib/commands/dialgen/libgen" "github.com/xeipuuv/gojsonschema" ) // D...
testgomavlib/dialectRTTestFunctions.go
0.562417
0.410284
dialectRTTestFunctions.go
starcoder
package trueskill import ( "errors" "fmt" "math" "github.com/chobie/go-gaussian" "github.com/gami/go-trueskill/factorgraph" "github.com/gami/go-trueskill/mathmatics" ) const ( defaultMu = 25.0 defaultSigmaDenom = 3 defaultBetaDenom = 2 defaultTauDenom = 100 defaultDrawProbab...
trueskill.go
0.715921
0.592784
trueskill.go
starcoder
package field import ( "math" "github.com/csweichel/go-pen/pkg/plot" "github.com/aquilax/go-perlin" ) // NewVectorField produces a new vector field from vectors func NewVectorField(counts, spacing plot.XY, sampler func(p plot.XY) Vector) *VectorField { res := make([][]Vector, counts.X) for x := 0; x < counts.X...
pkg/field/field.go
0.853058
0.708112
field.go
starcoder
package slippy import "math" // ==== lat lon (aka WGS 84) ==== // Lat2Tile takes a zoom and a lat to produce the lon func Lat2Tile(zoom uint, lat float64) (y uint) { latRad := lat * math.Pi / 180 return uint(math.Exp2(float64(zoom))* (1.0-math.Log( math.Tan(latRad)+ (1/math.Cos(latRad)))/math.Pi)) / 2....
vendor/github.com/go-spatial/geom/slippy/projections.go
0.715821
0.633226
projections.go
starcoder
package data import ( "fmt" "math" ) import "strconv" const maxDigits = 6 func ff(x float64) string { minExact := strconv.FormatFloat(x, 'g', -1, 64) fixed := strconv.FormatFloat(x, 'g', maxDigits, 64) if len(minExact) < len(fixed) { return minExact } return fixed } type Bin struct { LeftInclusive float...
pkg/data/histogram.go
0.591959
0.508605
histogram.go
starcoder
package geoutil import ( "fmt" "github.com/golang/geo/s1" "github.com/golang/geo/s2" ) const ( PrecisionMax = 0 PrecisionE5 = iota PrecisionE6 = iota PrecisionE7 = iota ) func precisionMax(a s1.Angle) float64 { return a.Degrees() } func precisionE5(a s1.Angle) float64 { return float64(a.E5()) / 1e5 } ...
geoutil.go
0.801354
0.462412
geoutil.go
starcoder
package proto2gql import ( "go/build" "path/filepath" "reflect" "strings" "github.com/pkg/errors" "github.com/EGT-Ukraine/go2gql/generator/plugins/graphql" "github.com/EGT-Ukraine/go2gql/generator/plugins/proto2gql/parser" ) var goTypesScalars = map[string]graphql.GoType{ "double": {Scalar: true, Kind: refl...
generator/plugins/proto2gql/helpers.go
0.529507
0.427038
helpers.go
starcoder
package iso20022 // Specifies periods of a corporate action. type CorporateActionPeriod10 struct { // Period during which the price of a security is determined. PriceCalculationPeriod *Period3Choice `xml:"PricClctnPrd,omitempty"` // Period during which the interest rate has been applied. InterestPeriod *Period3C...
CorporateActionPeriod10.go
0.810366
0.607343
CorporateActionPeriod10.go
starcoder
Crankcase Pattern and Core Box */ //----------------------------------------------------------------------------- package main import ( "math" "github.com/deadsy/sdfx/sdf" ) //----------------------------------------------------------------------------- const crankcaseOuterRadius = 1.0 + (5.0 / 16.0) const cra...
examples/midget/crankcase.go
0.693265
0.406096
crankcase.go
starcoder
package LectureService import ( "github.com/Projects/RidingTrainingSystem/internal/pkg/Lecture" "github.com/Projects/RidingTrainingSystem/internal/pkg/entity" ) // LectureService struct type LectureService struct { LectureRepo Lecture.LectureRepo } // NewLectureService function func NewLectureService(lecturerepo ...
internal/pkg/Lecture/LectureService/lecture_main_service.go
0.554229
0.478407
lecture_main_service.go
starcoder
package schema // CampaignSpecSchemaJSON is the content of the file "campaign_spec.schema.json". const CampaignSpecSchemaJSON = `{ "$schema": "http://json-schema.org/draft-07/schema#", "title": "CampaignSpec", "description": "A campaign specification, which describes the campaign and what kinds of changes to ma...
schema/campaign_spec_stringdata.go
0.811863
0.538923
campaign_spec_stringdata.go
starcoder
package radix import ( "strings" ) const glob = "*" // Label is the minimum comparing unit in the tree. type Label interface { // Match returns true if label matches the given string. Match(other string) bool // String returns the string representation. String() string // Literal returns if this label contains...
x/radix/key.go
0.769687
0.422624
key.go
starcoder
package data // A Direct Acyclic Graph. // It doesn't actually check for cycles while adding nodes and links. type Dag[T comparable, D any] struct { nodes []*DagNode[T, D] } func NewDag[T comparable, D any](expectedSize int) *Dag[T, D] { return &Dag[T, D]{nodes: make([]*DagNode[T, D], 0, expectedSize)} } func (d *...
data/dag.go
0.728748
0.614828
dag.go
starcoder
Holes */ //----------------------------------------------------------------------------- package obj import "github.com/jakoblorz/sdfx/sdf" //----------------------------------------------------------------------------- // CounterBoredHole3D returns the SDF3 for a counterbored hole. func CounterBoredHole3D( l fl...
obj/hole.go
0.817502
0.440048
hole.go
starcoder
PrettyTest is a simple testing library for golang. It aims to simplify/prettify testing in golang. It features: * a simple assertion vocabulary for better readability * customizable formatters through interfaces * before/after functions * integrated with the go test command * pretty and colorful output with repo...
Godeps/_workspace/src/github.com/remogatto/prettytest/prettytest.go
0.532182
0.533033
prettytest.go
starcoder
package exponentialbackoff import ( "fmt" "time" ) const ( // initialDurationBeforeRetry is the amount of time after an error occurs // that GoroutineMap will refuse to allow another operation to start with // the same target (if exponentialBackOffOnError is enabled). Each // successive error results in a wait ...
vendor/k8s.io/kubernetes/pkg/util/goroutinemap/exponentialbackoff/exponential_backoff.go
0.729423
0.415017
exponential_backoff.go
starcoder
package maps import ( "bytes" "encoding/gob" "encoding/json" "sort" "strings" ) // A StringSliceMap combines a map with a slice so that you can range over a // map in a predictable order. By default, the order will be the same order that items were inserted, // i.e. a FIFO list. This is similar to how PHP array...
pkg/maps/strslicemap.go
0.73678
0.464112
strslicemap.go
starcoder
package number import ( "math" "reflect" ) // InRange checks whether e is present in between n to s // Supported Types : int8, uint8, uint16, int16, uint32, int32, uint64, int64, int, uint, float32, float64 func InRange(n, s, e interface{}) bool { if reflect.TypeOf(n) != reflect.TypeOf(s) || reflect.TypeOf(n) != r...
number/in_range.go
0.669961
0.44083
in_range.go
starcoder
package persian import ( "fmt" "regexp" ) //ToPersianDigits Converts all English digits in the string to Persian digits. func ToPersianDigits(text string) string { var checker = map[string]string{ "0": "۰", "1": "۱", "2": "۲", "3": "۳", "4": "۴", "5": "۵", "6": "۶", "7": "۷", "8": "۸", "9": "۹"...
persian.go
0.509032
0.444866
persian.go
starcoder
package main import ( sdlgfx "github.com/veandco/go-sdl2/gfx" "github.com/veandco/go-sdl2/sdl" "github.com/roeldev/go-sdl2-experiments/pkg/sdlkit" "github.com/roeldev/go-sdl2-experiments/pkg/sdlkit/geom" ) const ( MinBallRadius int32 = 10 MaxBallRadius int32 = 30 ) type ball struct { geom.Circle Vel geo...
collisions/olc_balls/ball.go
0.726717
0.455744
ball.go
starcoder
// Package equation implements SPOOK equations based on // the 2007 PhD thesis of <NAME> titled // "Ghosts and Machines: Regularized Variational Methods for // Interactive Simulations of Multibodies with Dry Frictional Contacts" package equation import ( "github.com/adamlenda/engine/math32" ) // IBody is the interf...
experimental/physics/equation/equation.go
0.899528
0.705005
equation.go
starcoder
package sphere import ( "math" "github.com/adrianderstroff/pbr/pkg/cgm" "github.com/adrianderstroff/pbr/pkg/core/gl" mesh "github.com/adrianderstroff/pbr/pkg/view/mesh" "github.com/go-gl/mathgl/mgl32" ) // Make constructs a sphere of the specified horizontal and vertical // resolution. The resolution should be ...
pkg/view/mesh/sphere/sphere.go
0.635788
0.44897
sphere.go
starcoder
package openapi import ( "encoding/json" ) // EventTypeIn struct for EventTypeIn type EventTypeIn struct { Description string `json:"description"` Name string `json:"name"` } // NewEventTypeIn instantiates a new EventTypeIn object // This constructor will assign default values to properties that have it defined,...
go/internal/openapi/model_event_type_in.go
0.745676
0.41561
model_event_type_in.go
starcoder