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 solutions
type AllOne struct {
firstMetadata map[string]int
secondMetadata map[int]map[string]interface{}
maxValue int
minValue int
}
func Constructor() AllOne {
return AllOne{
firstMetadata: map[string]int{},
secondMetadata: map[int]map[string]interface{}{},
maxV... | solutions/432.go | 0.605099 | 0.419648 | 432.go | starcoder |
package main
/*
题目:用队列实现栈
请你仅使用两个队列实现一个后入先出(LIFO)的栈,并支持普通队列的全部四种操作(push、top、pop 和 empty)。
实现 MyStack 类:
void push(int x) 将元素 x 压入栈顶。
int pop() 移除并返回栈顶元素。
int top() 返回栈顶元素。
boolean empty() 如果栈是空的,返回 true ;否则,返回 false 。
注意:
你只能使用队列的基本操作 —— 也就是 push to back、peek/pop from front、size 和 is empty 这些操作。
你所使用的语言也许不支持队列。 你... | internal/leetcode/225.implement-stack-using-queues/main.go | 0.539469 | 0.489564 | main.go | starcoder |
package mesh
import (
"math"
"github.com/ungerik/go3d/float64/vec3"
)
type Box struct {
LowerBound, UpperBound vec3.T
}
func (this *Box) Center() vec3.T {
return vec3.T{
(this.LowerBound[0] + this.UpperBound[0]) / 2,
(this.LowerBound[1] + this.UpperBound[1]) / 2,
(this.LowerBound[2] + this.UpperBound[2]) ... | src/space.go | 0.702326 | 0.501282 | space.go | starcoder |
package unityai
import (
"math"
)
type AABB struct {
m_Center Vector3f
m_Extent Vector3f
}
func NewAABBFromMinMax(data MinMaxAABB) AABB {
return AABB{
m_Center: data.m_Min.Add(data.m_Max).Mulf(0.5),
m_Extent: data.m_Max.Sub(data.m_Min).Mulf(0.5),
}
}
func (this *AABB) SetCenterAndExtent(center, extent Vect... | aabb.go | 0.702224 | 0.426202 | aabb.go | starcoder |
package integration
import (
"errors"
"testing"
"time"
"github.com/CyCoreSystems/ari"
)
func TestLiveRecordingData(t *testing.T, s Server) {
runTest("ok", t, s, func(t *testing.T, m *mock, cl ari.Client) {
expected := ari.LiveRecordingData{
Name: "n1",
Format: "format",
Cause: "c1",
Si... | internal/integration/liverecording.go | 0.60964 | 0.555797 | liverecording.go | starcoder |
package cloudtruth
import (
"encoding/json"
)
// ValueCreate A value for a parameter in a given environment.
type ValueCreate struct {
// The environment this value is set in.
Environment string `json:"environment"`
// An external parameter leverages a CloudTruth integration to retrieve content on-demand from an... | pkg/cloudtruth/model_value_create.go | 0.844762 | 0.538498 | model_value_create.go | starcoder |
package input
import (
"context"
"fmt"
"sync/atomic"
"time"
"github.com/Jeffail/benthos/v3/internal/bloblang"
"github.com/Jeffail/benthos/v3/internal/bloblang/mapping"
"github.com/Jeffail/benthos/v3/internal/bloblang/parser"
"github.com/Jeffail/benthos/v3/internal/docs"
"github.com/Jeffail/benthos/v3/lib/inp... | lib/input/bloblang.go | 0.781289 | 0.57526 | bloblang.go | starcoder |
package go_opv
import (
"reflect"
"strconv"
"strings"
)
func compareVerify(value reflect.Value, verifyStr, separator string) bool {
switch value.Kind() {
case reflect.String, reflect.Slice, reflect.Array:
return compare(value.Len(), verifyStr, separator)
case reflect.Uint, reflect.Uint8, reflect.Uint16, refl... | verify.go | 0.505371 | 0.518546 | verify.go | starcoder |
package main
import (
"fmt"
"reflect"
)
type Slicing interface {
GetLast()
GetFirst()
GetAny()
Remove()
RemoveLast()
}
// anyToSlice converts any input type given the interface{} builtin type to a full slice variant,
// creates the slice with the same lenght and values. !!The slice that is given for reflectio... | go/reflection.go | 0.742982 | 0.414603 | reflection.go | starcoder |
package install
// Viz defines the primary Conduit Grafana dashboard, installed via the `conduit install` command.
const Viz = `{
"rows": [
{
"collapse": false,
"height": "50px",
"panels": [
{
"content": "<div>\n <div style=\"position: absolute; to... | cli/install/viz.go | 0.740174 | 0.436202 | viz.go | starcoder |
package day5
import (
"fmt"
"log"
)
type Grid struct {
width int
height int
data [][]rune
}
func initGrid(vectors []Vector) Grid {
grid := Grid{
width: 0,
height: 0,
data: nil,
}
for _, currentVector := range vectors {
if currentVector.start.x > grid.width {
grid.width = currentVector.start.x
... | day5/grid.go | 0.575707 | 0.62019 | grid.go | starcoder |
package queue
// Keeping below as var so it is possible to run the slice size bench tests with no coding changes.
var (
// firstSliceSize holds the size of the first slice.
firstSliceSize = 1
// maxFirstSliceSize holds the maximum size of the first slice.
maxFirstSliceSize = 16
// maxInternalSliceSize holds th... | collections/queue/unbounded.go | 0.832305 | 0.495667 | unbounded.go | starcoder |
package wordcloud_go
import (
"math"
"os"
"fmt"
"image/png"
"github.com/fogleman/gg"
)
func TwoByBitmap(imgpath string) *WorldMap {
worldMap := &WorldMap{
CollisionMap: make([]int, 0),
}
file, err := os.Open(imgpath)
if err != nil {
fmt.Println(err)
}
img, err := png.Decode(file)
file.Close()
bounds ... | helper.go | 0.522446 | 0.446857 | helper.go | starcoder |
package hexgrid
import (
"fmt"
"math"
"sort"
)
type costData struct {
index int
distSoFar float64
estRemaining float64
prevIndex int
}
func (pc costData) estTotal() float64 {
return pc.distSoFar + pc.estRemaining
}
type byScore []costData
func (a byScore) Len() int { return len(a) }
... | findpath.go | 0.765067 | 0.487978 | findpath.go | starcoder |
package otelzap
import (
"fmt"
"time"
"go.uber.org/zap/zapcore"
)
// bufferArrayEncoder implements zapcore.bufferArrayEncoder.
// It represents all added objects to their string values and
// adds them to the stringsSlice buffer.
type bufferArrayEncoder struct {
stringsSlice []string
}
var _ zapcore.ArrayEncode... | otelzap/arrayencoder.go | 0.634656 | 0.447641 | arrayencoder.go | starcoder |
package labels
import (
"bytes"
"strings"
)
// Sep is the default domain fragment separator.
const Sep = "."
// DomainFrag mangles the given name in order to produce a valid domain fragment.
// A valid domain fragment will consist of one or more host name labels
// concatenated by the given separator.
func DomainF... | vendor/github.com/mesosphere/mesos-dns/records/labels/labels.go | 0.806738 | 0.414662 | labels.go | starcoder |
package paths
import (
"github.com/anaseto/gruid"
)
// Dijkstra is the interface that allows to build a dijkstra map using the
// DijkstraMap function.
type Dijkstra interface {
Pather
// Cost represents the cost from one position to an adjacent one. It
// should not produce negative costs.
Cost(gruid.Point, gr... | paths/dijkstra.go | 0.749271 | 0.465752 | dijkstra.go | starcoder |
package stream
import (
"context"
"github.com/searKing/golang/go/util"
"github.com/searKing/golang/go/util/function/binary"
"github.com/searKing/golang/go/util/function/consumer"
"github.com/searKing/golang/go/util/function/predicate"
"github.com/searKing/golang/go/util/optional"
)
/**
* A sequence of elemen... | go/container/stream/stream.go | 0.883764 | 0.573917 | stream.go | starcoder |
package btcount
import (
"sort"
"time"
"github.com/shopspring/decimal"
)
// Transaction is a single transaction that stores the amount of coins
// that has been sent and the time of it.
type Transaction struct {
Amount Decimal `json:"amount"`
Datetime time.Time `json:"datetime"`
}
// Decimal is a wrapper a... | internal/btcount/btcount.go | 0.792585 | 0.437223 | btcount.go | starcoder |
package levels
import (
"github.com/inkyblackness/hacked/editor/render"
"github.com/inkyblackness/hacked/ss1/content/archive/level"
"github.com/inkyblackness/hacked/ui/opengl"
)
var gridVertexShaderSource = `
#version 150
precision mediump float;
in vec3 vertexPosition;
uniform mat4 viewMatrix;
uniform mat4 proj... | editor/levels/BackgroundGrid.go | 0.769773 | 0.503601 | BackgroundGrid.go | starcoder |
package main
import (
"aoc2021/util"
"fmt"
"math"
)
type Pixel struct {
x, y int
}
type Image struct {
background bool
x1, y1, x2, y2 int
pixels map[Pixel]int
}
// Advent of Code (AOC) 2021 Day 20
func main() {
var algorithm string
var image Image
util.ReadFile("../input/20a.txt", func(line s... | 2021/go/d20/main.go | 0.621656 | 0.469338 | main.go | starcoder |
package entities
import (
"crypto/sha512"
"fmt"
"io"
"math"
"math/rand"
"strconv"
"time"
"unicode"
"github.com/Vladimiroff/vec2d"
)
type CartesianEquation struct {
a, b float64
}
func NewCartesianEquation(startPoint, endPoint *vec2d.Vector) *CartesianEquation {
ce := new(CartesianEquation)
ce.a = (endPo... | entities/utils.go | 0.788583 | 0.508971 | utils.go | starcoder |
package sets
import "github.com/tdakkota/algo2/alg"
// Creates copy of set
func Copy[T comparable](src Set[T]) (dst Set[T]) {
dst = HashSet[T](src.Len())
Fill(src, dst)
return
}
// Fill src from dst
func Fill[T any](src, dst Set[T]) {
src.Iterate(func(t T) bool {
dst.Add(t)
return true
})
return
}
// Add ... | sets/util.go | 0.736116 | 0.736993 | util.go | starcoder |
package condition
import (
"github.com/aws/aws-sdk-go-v2/feature/dynamodb/expression"
"github.com/ericmaustin/dyno/encoding"
)
// GreaterThan returns a Builder with a GreaterThan condition for the input name and value
func GreaterThan(name string, value interface{}) expression.ConditionBuilder {
return expression.... | condition/conditions.go | 0.863075 | 0.648286 | conditions.go | starcoder |
package udwCryptoSha3
type spongeDirection int
const (
spongeAbsorbing spongeDirection = iota
spongeSqueezing
)
const (
maxRate = 168
)
type state struct {
a [25]uint64
buf []byte
rate int
dsbyte byte
storage [maxRate]byte
fixedOutput bool
outputLen int
state spongeDirection
}
func (d *s... | udwCryptoSha3/sha3.go | 0.515864 | 0.470737 | sha3.go | starcoder |
package shared
import (
"fmt"
"strings"
)
// ParsedImportType represents the various types of parsed imports.
type ParsedImportType int
const (
// ParsedImportTypeLocal indicates that the import is a local file system import.
ParsedImportTypeLocal ParsedImportType = iota
// ParsedImportTypeAlias indicates tha... | parser/shared/imports.go | 0.692434 | 0.42322 | imports.go | starcoder |
package pricing
import (
"fmt"
"github.com/tealeg/xlsx/v3"
"github.com/transcom/mymove/pkg/appcontext"
"github.com/transcom/mymove/pkg/models"
)
var parseDomesticMoveAccessorialPrices processXlsxSheet = func(appCtx appcontext.AppContext, params ParamConfig, sheetIndex int) (interface{}, error) {
// XLSX Sheet ... | pkg/parser/pricing/parse_access_and_add_prices.go | 0.511229 | 0.468243 | parse_access_and_add_prices.go | starcoder |
package dwt
import (
"math"
"github.com/goccmack/godsp"
)
type Transform struct {
st []float64
level int
sections []*transformSection
}
type transformSection struct {
start int
size int
}
// Daubechies4 returns the DWT with Daubechies 4 coeficients to level.
func Daubechies4(s []float64, level int... | dwt/dwt.go | 0.623492 | 0.446736 | dwt.go | starcoder |
package ast
// Arguments is a linked list that contains Argument values.
type Arguments struct {
Data Argument
next *Arguments
pos int
}
// Add appends a Argument to this linked list and returns this new head.
func (as *Arguments) Add(data Argument) *Arguments {
var pos int
if as != nil {
pos = as.pos + 1
}... | ast/lists.go | 0.850142 | 0.439747 | lists.go | starcoder |
package geometry
import (
"math"
"github.com/tab58/v1/spatial/pkg/numeric"
"gonum.org/v1/gonum/blas"
"gonum.org/v1/gonum/blas/blas64"
)
// Vector4DReader is a read-only interface for a 4D vector.
type Vector4DReader interface {
GetX() float64
GetY() float64
GetZ() float64
GetW() float64
GetComponents() (fl... | pkg/geometry/vector4d.go | 0.857798 | 0.767537 | vector4d.go | starcoder |
package non_linear_data_structure
// KeyValue type
type KeyValue interface {
LessThan(KeyValue) bool
EqualTo(KeyValue) bool
}
// AVLTreeNode class
type AVLTreeNode struct {
KeyValue KeyValue
BalanceValue int
LinkedNodes [2]*AVLTreeNode
}
// opposite method takes a node value and returns the opposite node's... | non_linear_data_structure/avl_tree.go | 0.807233 | 0.534977 | avl_tree.go | starcoder |
package metrics
import (
"sort"
"time"
)
type FloatMetricsRecorder struct {
min float64
max float64
sum float64
count uint64
values []float64
buckets map[float64]uint64
}
func NewFloatMetricsRecorder(buckets ...float64) *FloatMetricsRecorder {
bucketsMap := make(map[float64]uint64, len(bucket... | internal/armada/metrics/recorder.go | 0.684264 | 0.556038 | recorder.go | starcoder |
package holiday
import (
"time"
"github.com/infobaleen/date"
)
// Predefined fixed date holidays
var (
NewYearsDay = FixedHoliday{Month: 1, Day: 1, Name: "New years day"}
NewYearsEve = FixedHoliday{Month: 12, Day: 31, Name: "New Year's Eve"}
Epiphany = FixedHoliday{Month: ... | holiday/predefinedHolidays.go | 0.510252 | 0.410934 | predefinedHolidays.go | starcoder |
package blockchain
const pricingABI = `[
{
"constant": false,
"inputs": [
{
"name": "alerter",
"type": "address"
}
],
"name": "removeAlerter",
"outputs": [],
"payable": false,
"stateMutability": "nonpayable",
"type": "function"
},
{
"constant": fals... | blockchain/pricing_abi.go | 0.599016 | 0.446796 | pricing_abi.go | starcoder |
package any
import (
"fmt"
"reflect"
)
// Value represents any value.
type Value struct {
i interface{}
}
// ValueOf creates a Value from any value.
// The ValueOf nil is equivalent to the zero Value.
func ValueOf(i interface{}) Value {
return Value{i: i}
}
// Bool returns the value as a bool type.
// The zero ... | value.go | 0.776114 | 0.581244 | value.go | starcoder |
package cstructs
import (
math "github.com/chewxy/math32"
"github.com/r4stl1n/micro-hal/code/pkg/hmath"
)
type Transformation struct {
Rotation Rotation
Point hmath.Vec3
}
func (transformation Transformation) X() float32 {
return transformation.Point.X()
}
func (transformation Transformation) Y() float32 {
... | code/pkg/champ/cstructs/transformation.go | 0.819857 | 0.488527 | transformation.go | starcoder |
package tsplot
import (
"image/color"
"time"
"gonum.org/v1/plot"
"gonum.org/v1/plot/font"
"gonum.org/v1/plot/plotter"
monitoringpb "google.golang.org/genproto/googleapis/monitoring/v3"
"google.golang.org/protobuf/types/known/durationpb"
)
// PlotOption defines the type used to configure the underlying *plot.P... | tsplot/options.go | 0.864096 | 0.431165 | options.go | starcoder |
package util
import (
cryptorand "crypto/rand"
"fmt"
"math/big"
mathrand "math/rand"
"sync"
)
// Random is an interface that provides utility functions for generating random
// bytes, and integers.
type Random interface {
// RandomBytes returns the specified |num| bytes of random data from a uniform
// distri... | shuffler/src/util/rand_util.go | 0.838349 | 0.506164 | rand_util.go | starcoder |
package main
import (
"flag"
"fmt"
"math"
"os"
)
// radian
type rad float64
type geo struct {
Lng float64 //経度 x
Lat float64 //緯度 y
}
func (point *geo) radian() (rad, rad) {
return degToRad(point.Lat), degToRad(point.Lng)
}
// 地球の半径(km)
const r = 6378.137
// 地球の半径(m)
const rm = 6378137
//ベッセル楕円体(旧日本測地系)
c... | main.go | 0.645679 | 0.474996 | main.go | starcoder |
package prime
import "fmt"
// FactorsOf returns the prime factors of the given number
func FactorsOf(n uint64) ([]uint64, error) {
sqrt, err := intsqrt(n, 10_000)
if err != nil {
return nil, fmt.Errorf("Took too long to calculate sqrt(%v)", n)
}
// intsqrt is always less than or equal to the actual sqrt...
//... | pkg/prime/main.go | 0.742141 | 0.542984 | main.go | starcoder |
package GoTrees
import (
"strconv"
)
// BTree is a b-tree using key-value nodes.
type BTree struct {
root *bTreeNode
size uint64
t uint
initAlloc int
}
// NewBTree returns an empty b-tree. The degree of the b tree is 2*t+2. (This ensures valid max-degree. Since this b-tree splits preemptively ... | BTree.go | 0.643665 | 0.647812 | BTree.go | starcoder |
package waves
import (
"fmt"
"github.com/sirupsen/logrus"
"github.com/spf13/cobra"
"github.com/spf13/viper"
"github.com/foundriesio/fioctl/subcommands"
)
func init() {
showCmd := &cobra.Command{
Use: "status [<wave>]",
Short: "Show a status for a given wave by name",
Long: `Show a status for a given w... | subcommands/waves/status.go | 0.709925 | 0.483526 | status.go | starcoder |
package main
/*
When you start receiving packets from a certain source, start an interval timer.
On that interval, send the source an ack message containing a start time, an end time,
and the number of bytes you have received from that source during the time period.
When you receive such an ack from a destination, d... | main.go | 0.650911 | 0.541227 | main.go | starcoder |
package onshape
import (
"encoding/json"
)
// BTPConversionFunction1362AllOf struct for BTPConversionFunction1362AllOf
type BTPConversionFunction1362AllOf struct {
BtType *string `json:"btType,omitempty"`
From *BTPLiteralNumber258 `json:"from,omitempty"`
SpaceAfterType *BTPSpace10 `json:"spaceAfterType,omitempty"... | onshape/model_btp_conversion_function_1362_all_of.go | 0.695028 | 0.441974 | model_btp_conversion_function_1362_all_of.go | starcoder |
package govader
import (
"math"
"strings"
"gonum.org/v1/gonum/mat"
)
func negated(inputWords []string, includeNT bool, negateList []string) bool {
// Determine if input contains negation words
for _, x := range inputWords {
if inStringSlice(negateList, x) {
return true
}
}
if includeNT {
for _, w ... | vader.go | 0.717309 | 0.472075 | vader.go | starcoder |
// Copyright © 2016 <NAME> & <NAME>.
// License: https://creativecommons.org/licenses/by-nc-sa/4.0/
// See page 101.
// Package treesort provides insertion sort using an unbalanced binary tree.
package treesort
import (
"fmt"
"strconv"
)
//!+
type tree struct {
value int
left, right *tree
}
// Sort sort... | Chapter7/ex_7.3/sort.go | 0.89895 | 0.453443 | sort.go | starcoder |
package integration
func (a *application) rewriteAST(parent AST, node AST, replacer replacerFunc) bool {
if node == nil {
return true
}
switch node := node.(type) {
case BasicType:
return a.rewriteBasicType(parent, node, replacer)
case Bytes:
return a.rewriteBytes(parent, node, replacer)
case InterfaceCon... | go/tools/asthelpergen/integration/ast_rewrite.go | 0.531453 | 0.453746 | ast_rewrite.go | starcoder |
package openapi
import (
"encoding/json"
"time"
)
// WorkflowRunStateSummary A summary of the state of a workflow run
type WorkflowRunStateSummary struct {
// Time at which the workflow execution ended
EndedAt NullableTime `json:"ended_at"`
// Time at which workflow execution started
StartedAt NullableTime `js... | client/pkg/client/openapi/model_workflow_run_state_summary.go | 0.790975 | 0.520374 | model_workflow_run_state_summary.go | starcoder |
package bivariate
import (
"regexp"
"strconv"
"strings"
"github.com/ReneBoedker/algobra/errors"
"github.com/ReneBoedker/algobra/finitefield/ff"
)
type monomialMatch struct {
qr *QuotientRing
sign string
coef string
vars [2]string
degs [2]string
}
func newMonomialMatch(match []string, op errors.Op, qr *Q... | bivariate/parsing.go | 0.739705 | 0.508605 | parsing.go | starcoder |
package main
import (
"fmt"
"os"
"strconv"
"github.com/valdar/adventOfCode2017/utils"
)
type position struct {
x int
y int
hash string
}
func main() {
caseSelection := os.Args[1]
input, err := strconv.Atoi(os.Args[2])
utils.Check(err)
switch {
case caseSelection == "A":
position, layer := CalcS... | day3/day3.go | 0.569134 | 0.442697 | day3.go | starcoder |
package worldmap
import (
"math/rand"
"github.com/ironarachne/world/pkg/climate"
"github.com/ironarachne/world/pkg/grid"
)
// Tile is a map tile
type Tile struct {
Coordinate grid.Coordinate
Points []grid.Coordinate
Edges []grid.Edge
Temperature int
Humidity int
IsInhabited bool
IsOcean ... | pkg/worldmap/tiles.go | 0.745676 | 0.596463 | tiles.go | starcoder |
Goom Waves
A Goom Wave is a wave shape with the following segments:
1) s0: A falling (1 to -1) sine curve
2) f0: A flat piece at the bottom
3) s1: A rising (-1 to 1) sine curve
4) f1: A flat piece at the top
Shape is controlled by two parameters:
duty = split the total period between s0,f0 and s1,f1
slope = split s... | module/osc/goom.go | 0.864597 | 0.634317 | goom.go | starcoder |
package lingo
import (
"gonum.org/v1/gonum/mat"
"gonum.org/v1/hdf5"
"math"
)
const (
// ErrorThreshold is used in tests as the default error expected between predicted and expected values.
ErrorThreshold = 0.00001
)
type Validator interface {
validate(x []float64) error
}
// VecToArrayFloat64 converts a vecto... | util.go | 0.734215 | 0.496582 | util.go | starcoder |
package math3d
import "math"
// Vector struct holds the X, Y, Z and W coordinates
type Vector struct {
X float64
Y float64
Z float64
W float64
}
// ToArray converts a vector to an array
func (v Vector) ToArray() []float64 {
return []float64{v.X, v.Y, v.Z, v.W}
}
// FromArray converts an array to a vector
func ... | math3d/vector.go | 0.89793 | 0.823719 | vector.go | starcoder |
package mutable
import (
"fmt"
"sort"
"github.com/m4gshm/gollections/c"
"github.com/m4gshm/gollections/it/impl/it"
"github.com/m4gshm/gollections/notsafe"
"github.com/m4gshm/gollections/op"
"github.com/m4gshm/gollections/slice"
)
//NewVector creates the Vector with a predefined capacity.
func NewVector[T any]... | mutable/vector.go | 0.760562 | 0.579638 | vector.go | starcoder |
package vm
import (
"time"
)
func newTime(rt *Runtime) *Struct {
return NewStruct(rt, &rt.Owner.Exec.Structs[TIMESTRUCT])
}
func toTime(it *Struct) time.Time {
utc := time.Local
if it.Values[6].(int64) == 1 {
utc = time.UTC
}
return time.Date(int(it.Values[0].(int64)), time.Month(it.Values[1].(int64)),
in... | vm/time.go | 0.735547 | 0.439807 | time.go | starcoder |
package vt100
var (
_ CharDisplay = &Display{}
)
// Display implements fixed size CharDisplay.
type Display struct {
Blank Char
size Point
Lines [][]Char
}
// NewDisplay creates a display with the given dimensions.
func NewDisplay(width, height int) *Display {
d := &Display{
Blank: Char{
Code: 0xa0... | display.go | 0.68941 | 0.444565 | display.go | starcoder |
package main
import (
"bufio"
"fmt"
"math"
"os"
"strconv"
"strings"
)
func sum(arr []int) int {
sum := 0
for _, a := range arr {
sum += a
}
return sum
}
func findSumSign(op string) int {
for i, t := range op {
if t == '+' {
return i
}
}
return -1
}
func getLastNumber(op string) (int, int) {... | day_18/main.go | 0.605099 | 0.400192 | main.go | starcoder |
package store
import "database/sql"
// Data is used to index data.
type Data struct {
Key string
Value []byte
DataType string
Digest string
}
func newData(key string, value []byte) *Data {
return &Data{
Key: key,
Value: value,
}
}
func dataRowScan(rows *sql.Rows, data *Data) error {
// This ... | store/data.go | 0.604399 | 0.498596 | data.go | starcoder |
package value
import (
"strconv"
"strings"
)
type compareIntFunc func(a, b int64) bool
// IntSlice holds a slice of int64 values
type IntSlice struct {
valsPtr *[]int64
}
// NewIntSlice makes a new IntSlice with the given int64 values.
func NewIntSlice(vals ...int64) *IntSlice {
slice := make([]int64, len(vals)... | value/intslice.go | 0.832475 | 0.577227 | intslice.go | starcoder |
package mandelbrotlib
import (
"image"
"image/color"
"image/png"
"io"
"math/big"
"math/cmplx"
)
var (
// Width of the mandelbrot image
Width = 1024
// Height of the mandelbrot image
Height = 1024
Delta = 0.3 / float64(Width)
)
const (
xmin, ymin, xmax, ymax = -2, -2, +2, +2
)
// GenMandelbrotCmplx128 c... | mandelbrotlib.go | 0.67971 | 0.470189 | mandelbrotlib.go | starcoder |
package define
import (
"gotomate/fiber/variable"
"gotomate/log"
"strconv"
"strings"
)
// ArrayOfBool Define an array of bool in a flow
func ArrayOfBool(instructionData interface{}, finished chan bool) int {
log.FiberInfo("Defining an array of Bools")
value, err := variable.Keys{VarName: "VarName", IsVarName: ... | fiber/packages/Define/functions.go | 0.596903 | 0.415136 | functions.go | starcoder |
package privacy
import (
"github.com/lolopinto/ent/ent"
"github.com/lolopinto/ent/ent/viewer"
)
// AllowIfViewerInboundEdgeExistsRule is a privacy rule that passes if an edge exists between the viewer
// and the ent
type AllowIfViewerInboundEdgeExistsRule struct {
EdgeType ent.EdgeType
}
// Eval evaluates the All... | ent/privacy/edge_rules.go | 0.670069 | 0.408513 | edge_rules.go | starcoder |
package blocks
// Arr ...
type Arr struct {
buf []int
rows int
cols int
}
func (a *Arr) get(r int, c int) int {
return a.buf[r*a.cols+c]
}
func (a *Arr) set(r int, c int, val int) {
a.buf[r*a.cols+c] = val
}
// NewArr ...
func NewArr(rows int, cols int) *Arr {
return &Arr{
rows: rows,
cols: cols,
buf: ... | internal/blocks/arr.go | 0.632503 | 0.423518 | arr.go | starcoder |
package geom
import (
"math"
"github.com/ctessum/polyclip-go"
)
// MultiPolygon is a holder for multiple related polygons.
type MultiPolygon []Polygon
// Bounds gives the rectangular extents of the MultiPolygon.
func (mp MultiPolygon) Bounds() *Bounds {
b := NewBounds()
for _, polygon := range mp {
b.Extend(p... | multipolygon.go | 0.811937 | 0.6346 | multipolygon.go | starcoder |
package scene
import (
"image/color"
"github.com/benfrisbie/raytracer/geometry"
"github.com/benfrisbie/raytracer/geometry/renderable"
"github.com/benfrisbie/raytracer/geometry/shape"
"github.com/benfrisbie/raytracer/material"
)
type Scene1 struct {
Scene
Renderables []renderable.Renderable
Renderable... | scene/scene1.go | 0.623148 | 0.522689 | scene1.go | starcoder |
package time
import (
"errors"
"regexp"
"time"
)
const (
Layout_y = "2006"
Layout_y_m = "2006-01"
Layout_y_m_d = "2006-01-02"
Layout_y_m_d_time = "2006-01-02 15:04:05"
layout_default = "2006-01-02 15:04:05.999999999Z07:00"
)
// Unix returns the local Time corresponding to the given Un... | go-com/time/time.go | 0.67971 | 0.407864 | time.go | starcoder |
package models
import (
i336074805fc853987abe6f7fe3ad97a6a6f3077a16391fec744f671a015fbd7e "time"
i878a80d2330e89d26896388a3f487eef27b0a0e6c010c493bf80be1452208f91 "github.com/microsoft/kiota-abstractions-go/serialization"
)
// WindowsUpdateRolloutSettings a complex type to store the windows update rollout set... | models/windows_update_rollout_settings.go | 0.664105 | 0.42919 | windows_update_rollout_settings.go | starcoder |
package plug
import (
"fmt"
"math"
"reader"
)
func SpectralNormalize(spectral_original []reader.Spectrum) []reader.Spectrum {
fmt.Println("Spectral Normalization!")
for i := 0; i < len(spectral_original); i++ {
var calculation_signal []float64
for j := 0; j < len(spectral_original[i].Peaks); j++ {
calcula... | XY-Meta-code/src/plug/normalize.go | 0.531696 | 0.476214 | normalize.go | starcoder |
package main
import (
"time"
)
func RepoUpdater() *Container {
return &Container{
Name: "repo-updater",
Title: "Repo Updater",
Description: "Manages interaction with code hosts, instructs Gitserver to update repositories.",
Groups: []Group{
{
Title: "General",
Rows: []Row{
{
... | monitoring/repo_updater.go | 0.57081 | 0.409516 | repo_updater.go | starcoder |
package secp256k1
import (
"bytes"
"encoding/asn1"
"encoding/binary"
"errors"
"godot/ecdsa/prime"
"godot/rand"
"godot/sha256"
"math/big"
)
var OID asn1.ObjectIdentifier = []int{1, 3, 132, 0, 10}
// The order of the prime field over which secp256k1 is defined:
// 2^256 - 2^32 - 2^9 - 2^8 - 2^7 - 2^6 - 2^4 - ... | src/godot/ecdsa/secp256k1/secp256k1.go | 0.609175 | 0.407274 | secp256k1.go | starcoder |
package matcher
import "github.com/corvus-ch/bilocation/tag"
// Matcher defines the interface for matching a tag set against a set of criteria.
type Matcher interface {
// Match checks if the tag set matches the criteria.
Match(tag.Set) bool
}
type any struct{}
// NewAny create a matcher which always matches.
fun... | search/internal/matcher/matcher.go | 0.841891 | 0.463566 | matcher.go | starcoder |
package board
import (
"fmt"
"github.com/erikbryant/magnets/common"
)
// Board implements a widthxheight grid of runes.
type Board struct {
width int
height int
cells [][]rune
}
// Coord represents a single row/col address.
type Coord struct {
Row int
Col int
}
var (
// Adjacents contains the offsets for ... | board/board.go | 0.680135 | 0.441793 | board.go | starcoder |
package vectors
import (
"math"
"math/rand"
)
// IVec2 represents an integer vector.
type IVec2 struct {
X int64
Y int64
}
// NewIVec2 returns a new vector.
func NewIVec2(x, y int64) IVec2 {
return IVec2{
X: x,
Y: y,
}
}
// RandomVec2 returns a randomized vector.
func RandomVec2(scale float64) Vec2 {
ret... | vectors/vectors.go | 0.896402 | 0.709007 | vectors.go | starcoder |
package downsample
import (
"math"
"github.com/m3db/m3storage"
)
// NaNSafe returns a variant of the provided function that can account for NaN
// values in either of the parameters
func NaNSafe(f func(a, b float64) float64) func(float64, float64) float64 {
return func(a, b float64) float64 {
if math.IsNaN(a) ... | downsample/downsamplers.go | 0.858822 | 0.614654 | downsamplers.go | starcoder |
package splitsms
/**
* Go library for split SMS.
* This library support SMS in GSM 7, basic extended GSM 7 table and Unicode charset.
* The size of UDH can be defined for concatened SMS.
* https://en.wikipedia.org/wiki/GSM_03.38#GSM_7-bit_default_alphabet_and_extension_table_of_3GPP_TS_23.038_.2F_GSM_03.38
*/
// Bas... | charset.go | 0.634883 | 0.402627 | charset.go | starcoder |
package main
import (
"github.com/WhoBrokeTheBuild/GoDusk/dusk"
_ "github.com/WhoBrokeTheBuild/GoDusk/dusk/obj"
"github.com/WhoBrokeTheBuild/GoDusk/m32"
gl "github.com/go-gl/gl/v4.1-core/gl"
"github.com/go-gl/mathgl/mgl32"
)
type lightingShader struct {
dusk.DefaultShader
PointLight *lightEntity
}
func newLig... | demos/Lighting/main.go | 0.573559 | 0.441432 | main.go | starcoder |
package scanner
import (
"strings"
"unicode/utf8"
)
// Pos represents a byte position in the original input text from which
// this template was parsed.
type Pos int
func (p Pos) Position() Pos {
return p
}
const eof = -1
//Scanner, Iterates through a string.
type Scanner struct {
input string
start ... | scanner/scanner.go | 0.70477 | 0.419172 | scanner.go | starcoder |
package utility
import "time"
// This file includes conversion functions for using pointers as optional
// values.
// TruePtr returns a pointer to a true value.
func TruePtr() *bool {
res := true
return &res
}
// FalsePtr returns a pointer to a false value.
func FalsePtr() *bool {
res := false
return &res
}
//... | vendor/github.com/evergreen-ci/utility/optional.go | 0.76533 | 0.428413 | optional.go | starcoder |
package main
import (
"image/color"
"time"
"github.com/go-p5/p5"
"gonum.org/v1/gonum/spatial/r2"
)
func main() {
p5.Run(setup, draw)
}
const (
width = 1200
height = 1200
)
func setup() {
p5.Canvas(width, height)
p5.Background(color.Black)
}
func draw() {
dt := (15 * time.Millisecond).Seconds() * 5 * 1... | example/solar-system/main.go | 0.59302 | 0.548311 | main.go | starcoder |
package builtin
import (
"fmt"
"strings"
"github.com/stretchr/testify/assert"
)
var Assertions = map[string]func(t assert.TestingT, expected interface{}, actual interface{}, msgAndArgs ...interface{}) bool{
"equals": assert.EqualValues,
"equal": assert.EqualValues, // alias for equals
"g... | internal/builtin/assertion.go | 0.633977 | 0.659672 | assertion.go | starcoder |
package cryptoapis
import (
"encoding/json"
)
// GetExchangeRateByAssetsIDsRI struct for GetExchangeRateByAssetsIDsRI
type GetExchangeRateByAssetsIDsRI struct {
// Defines the time of the market data used to calculate the exchange rate in UNIX Timestamp.
CalculationTimestamp int32 `json:"calculationTimestamp"`
/... | model_get_exchange_rate_by_assets_ids_ri.go | 0.786049 | 0.464537 | model_get_exchange_rate_by_assets_ids_ri.go | starcoder |
// +build go1.15,!go1.16
package stdlib
import (
"image/color"
"reflect"
)
func init() {
Symbols["image/color/color"] = map[string]reflect.Value{
// function, constant and variable definitions
"Alpha16Model": reflect.ValueOf(&color.Alpha16Model).Elem(),
"AlphaModel": reflect.ValueOf(&color.AlphaModel).El... | stdlib/go1_15_image_color.go | 0.543106 | 0.424472 | go1_15_image_color.go | starcoder |
package glossary
import (
"math"
"github.com/faiface/pixel"
"github.com/faiface/pixel/imdraw"
"golang.org/x/image/colornames"
)
// Camera is a tool to get the screen center to be able to follow a certain point on a plane.
type Camera struct {
anglePhysic float64 // Angle in radians (math.Pi)
angleFollow ... | pixel-examples/community/amidakuji/glossary/cam.go | 0.858467 | 0.73782 | cam.go | starcoder |
package check
import (
"golang.stackrox.io/kube-linter/internal/pointers"
)
// ParameterType represents the expected type of a particular parameter.
type ParameterType string
// This block enumerates all known type names.
// These type names are chosen to be aligned with OpenAPI/JSON schema.
const (
StringType Pa... | pkg/check/parameter_desc.go | 0.799286 | 0.405331 | parameter_desc.go | starcoder |
package plan
import (
"fmt"
"math"
"time"
"github.com/influxdata/platform/query"
"github.com/pkg/errors"
uuid "github.com/satori/go.uuid"
)
// DefaultYieldName is the yield name to use in cases where no explicit yield name was specified.
const DefaultYieldName = "_result"
type PlanSpec struct {
// Now repres... | query/plan/physical.go | 0.631481 | 0.421016 | physical.go | starcoder |
package main
import (
"fmt"
"math/rand"
"strconv"
// "math/rand"
"time"
"github.com/sandertv/mcwss"
"github.com/sandertv/mcwss/mctype"
"github.com/sandertv/mcwss/protocol/command"
"k8s.io/client-go/kubernetes"
)
// PlayerFill will fill the playing area with blocktype, coordinates are relative to the player... | src/app/mcutil.go | 0.538498 | 0.429609 | mcutil.go | starcoder |
package improc
import (
"math"
"gopkg.in/gographics/imagick.v3/imagick"
)
type handler struct {
wand *imagick.MagickWand
}
func newHandler() *handler {
return &handler{
wand: imagick.NewMagickWand(),
}
}
func (h *handler) fromBlob(blob []byte) error {
err := h.wand.ReadImageBlob(blob)
if err != nil {
re... | image-handler.go | 0.595022 | 0.401101 | image-handler.go | starcoder |
package world
import (
"github.com/df-mc/dragonfly/server/block/cube"
"github.com/df-mc/dragonfly/server/event"
"github.com/go-gl/mathgl/mgl64"
)
// Handler handles events that are called by a world. Implementations of Handler may be used to listen to
// specific events such as when an entity is added to the world... | server/world/handler.go | 0.554953 | 0.472501 | handler.go | starcoder |
package metrics
import (
"sync"
"time"
)
// Timers capture the duration and rate of events.
type Timer interface {
Count() int64
Max() int64
Mean() float64
Min() int64
Percentile(float64) float64
Percentiles([]float64) []float64
Rate1() float64
Rate5() float64
Rate15() float64
RateMean() float64
RateStep... | vendor/github.com/niean/go-metrics-lite/timer.go | 0.849831 | 0.574693 | timer.go | starcoder |
package sink
import (
"github.com/searKing/golang/go/util/function/consumer"
)
/**
* An extension of {@link Consumer} used to conduct values through the stages of
* a stream pipeline, with additional methods to manage size information,
* control flow, etc. Before calling the {@code accept()} method on a
* {@co... | go/util/function/consumer/sink/sink.go | 0.914471 | 0.649773 | sink.go | starcoder |
package game
import (
"github.com/nsf/termbox-go"
)
// KeyEvent enumerates the different actions a user may take when using the application.
type KeyEvent int
const (
// MoveUp represents an upwards movement of the cursor
MoveUp KeyEvent = iota + 1
// MoveDown represents a downwards movement of the cursor.
Mov... | game/run.go | 0.695441 | 0.548674 | run.go | starcoder |
package ast
// Visitor is an interface for the structs which is used for traversing AST.
type Visitor interface {
// VisitTopdown defines the process when a node is visited. This method is called before
// children are visited.
// Returned value is a next visitor to use for succeeding visit. When wanting to stop
/... | ast/visitor.go | 0.569733 | 0.536495 | visitor.go | starcoder |
package continuous
import (
gsl "github.com/jtejido/ggsl"
"github.com/jtejido/stats"
"github.com/jtejido/stats/err"
"github.com/jtejido/trig"
"math"
"math/rand"
)
// Raised Cosine distribution
// https://en.wikipedia.org/wiki/Raised_cosine_distribution
type RaisedCosine struct {
location, scale float64
src ... | dist/continuous/raised_cosine.go | 0.787564 | 0.419232 | raised_cosine.go | starcoder |
package alert
import (
"github.com/grafana-tools/sdk"
)
// Operator represents a logical operator used to chain conditions.
type Operator string
// ConditionOption represents an option that can be used to configure a condition.
type ConditionOption func(condition *condition)
// And chains conditions with a logical... | vendor/github.com/K-Phoen/grabana/alert/condition.go | 0.850593 | 0.448607 | condition.go | starcoder |
package functions
import (
"math"
"testing"
"github.com/gopherd/gonum/diff/fd"
"github.com/gopherd/gonum/floats"
)
// function represents an objective function.
type function interface {
Func(x []float64) float64
}
type gradient interface {
Grad(grad, x []float64) []float64
}
// minimumer is an objective fu... | optimize/functions/validate.go | 0.555435 | 0.593226 | validate.go | starcoder |
package docs
import (
"bytes"
"encoding/json"
"strings"
"text/template"
"github.com/swaggo/swag"
)
var doc = `{
"schemes": {{ marshal .Schemes }},
"swagger": "2.0",
"info": {
"description": "{{escape .Description}}",
"title": "{{.Title}}",
"contact": {},
"license": {
... | docs/docs.go | 0.5794 | 0.401864 | docs.go | starcoder |
package time
type Zone struct {
Name string // Abbreviated name ("CET", "CEST").
Offset int // Seconds east of UTC.
}
// DST describes daylight saving time zone. 25 least significant bits of Start
// and End contain seconds from begining of year to the month-weekday-hour at
// which the DST starts/ends, assumi... | egroot/src/time/zoneinfo.go | 0.67694 | 0.514766 | zoneinfo.go | starcoder |
package geom
import (
"math"
)
type Coord struct {
X, Y float64
}
func (p *Coord) Hashcode() (hash uint64) {
x, y := uint64(p.X), uint64(p.Y)
hash = x + y
return
}
func (p *Coord) Equals(oi interface{}) (equals bool) {
o, equals := oi.(*Coord)
if !equals {
var op Coord
op, equals = oi.(Coord)
equals =... | vendor/github.com/whosonfirst/go-whosonfirst-static/vendor/github.com/whosonfirst/go-whosonfirst-svg/vendor/github.com/whosonfirst/go-whosonfirst-index/vendor/github.com/whosonfirst/go-whosonfirst-sqlite/vendor/github.com/whosonfirst/go-whosonfirst-geojson-v2/vendor/github.com/skelterjohn/geom/coord.go | 0.813609 | 0.477128 | coord.go | starcoder |
package microbitmatrix
import (
"image/color"
"machine"
"time"
)
var matrixRotations = [4][5][5][2]uint8{
{ // 0
{{0, 0}, {1, 3}, {0, 1}, {1, 4}, {0, 2}},
{{2, 3}, {2, 4}, {2, 5}, {2, 6}, {2, 7}},
{{1, 1}, {0, 8}, {1, 2}, {2, 8}, {1, 0}},
{{0, 7}, {0, 6}, {0, 5}, {0, 4}, {0, 3}},
{{2, 2}, {1, 6}, {2, 0... | microbitmatrix/microbitmatrix.go | 0.616705 | 0.689905 | microbitmatrix.go | starcoder |
Subsets and Splits
No community queries yet
The top public SQL queries from the community will appear here once available.