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 cc
import (
"errors"
"fmt"
"strings"
)
/*
Combines multiple errors. Returned by `cc.Conc.All`.
While `cc.Errs` does implement the `error` interface, you should never cast it
to `error`. Instead, call the method `cc.Errs.Err`, which will correctly return
a nil interface when all errors are nil.
*/
type Err... | cc_err.go | 0.801819 | 0.421671 | cc_err.go | starcoder |
package iso20022
// Set of characteristics that apply to the debit side of the payment transactions included in the credit transfer initiation.
type PaymentInstructionInformation3 struct {
// Unique identification, as assigned by a sending party, to unambiguously identify the payment information group within the mes... | PaymentInstructionInformation3.go | 0.812533 | 0.486454 | PaymentInstructionInformation3.go | starcoder |
package rel
import "github.com/arr-ai/frozen"
// CombineOp specifies which pairings to include in Combine().
type CombineOp int
// The following masks control which elements to include in Combine().
const (
OnlyOnLHS CombineOp = 1 << iota // Include elements only found on lhs.
InBoth // In... | rel/ops_tuple.go | 0.747339 | 0.471649 | ops_tuple.go | starcoder |
package asset
import (
gl "github.com/go-gl/gl/v4.1-core/gl"
"github.com/go-gl/mathgl/mgl32"
)
type Material struct {
Ambient mgl32.Vec4
Diffuse mgl32.Vec4
Specular mgl32.Vec4
AmbientMap *Texture
DiffuseMap *Texture
SpecularMap *Texture
}
type MaterialData struct {
Ambient mgl32.Vec4
Diffuse mgl32.V... | asset/Material.go | 0.588416 | 0.403244 | Material.go | starcoder |
package tiff
import (
"image"
"image/color"
)
// Gray32 is an in-memory image whose At method returns color.Gray32 values.
type Gray32 struct {
// Pix holds the image's pixels, as gray values in big-endian format. The pixel at
// (x, y) starts at Pix[(y-Rect.Min.Y)*Stride + (x-Rect.Min.X)].
Pix []uint32
// Str... | image.go | 0.891363 | 0.682232 | image.go | starcoder |
package event
import (
"time"
"github.com/stnma7e/betuol/common"
)
type EventListener func(evt Event)
// Event is an interface to allow many different structs to be used as events as long as they specify their type.
type Event interface {
GetType() string
}
// EventMessage is a helper struct for keeping track o... | event/manager.go | 0.543833 | 0.412589 | manager.go | starcoder |
package operator
import (
"github.com/matrixorigin/matrixone/pkg/container/nulls"
"github.com/matrixorigin/matrixone/pkg/container/types"
"github.com/matrixorigin/matrixone/pkg/container/vector"
"github.com/matrixorigin/matrixone/pkg/vectorize/ge"
"github.com/matrixorigin/matrixone/pkg/vectorize/le"
"github.com/... | pkg/sql/plan2/function/operator/ge.go | 0.606848 | 0.450601 | ge.go | starcoder |
package tracker
import (
"encoding/json"
"math"
"strings"
"time"
"github.com/racingmars/flighttrack/decoder"
"github.com/rs/zerolog/log"
)
const sweepInterval = 30 * time.Second
const decayTime = 5 * time.Minute
const reportMinInterval = 5 * time.Second
const headingEpsilon = 10
const speedEpsilon = 10
const ... | tracker/tracker.go | 0.557845 | 0.404331 | tracker.go | starcoder |
package array
import (
"gotomate/fiber/variable"
"gotomate/log"
"math/rand"
"time"
)
// GetArrayLength Get the current length of an array
func GetArrayLength(instructionData interface{}, finished chan bool) int {
log.FiberInfo("Getting an array length")
array, err := variable.Keys{VarName: "ArrayVarName"}.GetV... | fiber/packages/Array/functions.go | 0.53048 | 0.609321 | functions.go | starcoder |
package examples
func subsrc2anysub(src subsrc) anysub {
return anysub{
Test: src.Field1,
}
}
func anysub2subsrc(src anysub) subsrc {
return subsrc{
Field1: src.Test,
}
}
func subsrcPtr2anysubPtr(src *subsrc) *anysub {
if src == nil {
return nil
}
m := subsrc2anysub(*src)
return &m
}
func anysubPtr2subs... | examples/subsrc_to_anysub.sts.go | 0.524395 | 0.48871 | subsrc_to_anysub.sts.go | starcoder |
package tuple
import (
"fmt"
"golang.org/x/exp/constraints"
)
// T1 is a tuple type holding 1 generic values.
type T1[Ty1 any] struct {
V1 Ty1
}
// Len returns the number of values held by the tuple.
func (t T1[Ty1]) Len() int {
return 1
}
// Values returns the values held by the tuple.
func (t T1[Ty1]) Values(... | tuple1.go | 0.864554 | 0.613367 | tuple1.go | starcoder |
package store
import (
"fmt"
"math"
"reflect"
"strconv"
"github.com/juju/errors"
)
func Num64(i interface{}) interface{} {
switch x := i.(type) {
case int:
return int64(x)
case int8:
return int64(x)
case int16:
return int64(x)
case int32:
return int64(x)
case int64:
return int64(x)
case uint:
... | Godeps/_workspace/src/github.com/reborndb/qdb/pkg/store/format.go | 0.554712 | 0.433502 | format.go | starcoder |
package ffnet
import (
"context"
"errors"
"math/rand"
"time"
"github.com/spy16/snowman/pkg/mat"
)
// SGDTrainer implements Stochastic Gradient Descent trainer for FFNet
// using BackPropagation algorithm.
type SGDTrainer struct {
// Embed the network that needs to be trained.
*FFNet
// Eta is the learning ra... | pkg/ffnet/trainer.go | 0.795857 | 0.403156 | trainer.go | starcoder |
package main
import (
"strconv"
"time"
"periph.io/x/periph/conn/gpio"
"periph.io/x/periph/conn/gpio/gpioreg"
"periph.io/x/periph/host"
)
// gpioProvider generates pins for the platform (used for testing)
var gpioProvider = xGpioProvider // For testing on non-test setups
// GpioState represents the current bina... | gpio.go | 0.759939 | 0.462473 | gpio.go | starcoder |
package syntax
// compact specifies whether we allow spaces between expressions.
// This is true for let
func (p *Parser) arithmExpr(compact bool) ArithmExpr {
return p.arithmExprComma(compact)
}
// These function names are inspired by Bash's expr.c
func (p *Parser) arithmExprComma(compact bool) ArithmExpr {
retur... | syntax/parser_arithm.go | 0.657648 | 0.618896 | parser_arithm.go | starcoder |
package main
import ("fmt";"math/rand"; "math"; "time"; "flag")
func flip() int {
return rand.Intn(2)
}
/*
Given an integer n, returns the least number of flips needed to generate a
bitstring that covers at least until n. E.g., for n = 7, we have to flip 3
times for n = 30, we have to flip 5 times
*/
func num... | flip.go | 0.696371 | 0.416203 | flip.go | starcoder |
package collections
import (
"fmt"
"time"
)
// An Ord represents a result of comparing two items.
type Ord int
const (
// Less represents the idea of x < y.
Less Ord = 1 << iota
// Equal represents the idea of x == y.
Equal
// Greater represents the idea of x > y.
Greater
)
// checkOrd returns an error if t... | base.go | 0.862728 | 0.608391 | base.go | starcoder |
package chapter09
import "constraints"
type Number interface {
constraints.Integer | constraints.Float | constraints.Signed
}
// GenericItem defines a take-able item which has three properties. A weight, a value and a name for displaying.
type GenericItem[T Number] interface {
Weight() T
Name() string
Value() T
... | chapter09/dynamic_programming.go | 0.777046 | 0.492188 | dynamic_programming.go | starcoder |
package graphics
import (
"fmt"
"github.com/stnma7e/betuol/common"
"github.com/stnma7e/betuol/component"
)
// TextGraphicsHandler implements the GraphicsHandler interface, but instead of rendering to a graphics context, TextGraphicsHandler instead outputs textual descriptions of each model.
type TextGraphicsHandl... | graphics/text.go | 0.796886 | 0.414069 | text.go | starcoder |
package value
import (
"math/big"
)
func asinh(c Context, v Value) Value {
if u, ok := v.(Complex); ok {
if !isZero(u.imag) {
return complexAsinh(c, u)
}
v = u.real
}
return evalFloatFunc(c, v, floatAsinh)
}
func acosh(c Context, v Value) Value {
if u, ok := v.(Complex); ok {
if !isZero(u.imag) {
... | value/asinh.go | 0.765155 | 0.448487 | asinh.go | starcoder |
package wtf
import (
"github.com/gdamore/tcell"
)
var Colors = map[string]tcell.Color{
"aliceblue": tcell.ColorAliceBlue,
"antiquewhite": tcell.ColorAntiqueWhite,
"aqua": tcell.ColorAqua,
"aquamarine": tcell.ColorAquaMarine,
"azure": tcell.ColorAzure,
... | wtf/colors.go | 0.504639 | 0.503967 | colors.go | starcoder |
// Renders a textured spinning cube using GLFW 3 and OpenGL 4.1 core forward-compatible profile.
// VS Code, left hand column: Green lines are new lines (since last commit), blue lines are changed from last commit,
// and red arrows mean deletion since last commit.
package main
import (
_ "image/png"
"github.com/... | cmd/Basics/09-RotateInShader/main.go | 0.702632 | 0.439567 | main.go | starcoder |
Package reversetunnel provides interfaces for accessing remote clusters
via reverse tunnels and directly.
Reverse Tunnels
Proxy server Proxy agent
Reverse tunnel
+----------+ +---------+
| <----------------------+ |
... | lib/reversetunnel/doc.go | 0.703855 | 0.619327 | doc.go | starcoder |
package parser
import (
"fmt"
"github.com/eliquious/aechbar/calculator/ast"
"github.com/eliquious/lexer"
"math/big"
"time"
)
func (p *Parser) parseLiteralExpression(tok lexer.Token, pos lexer.Pos, lit string) (ast.Expression, error) {
expr, err := p.parseLiteral(tok, pos, lit)
if err != nil {
return nil, err... | calculator/parser/literals.go | 0.586641 | 0.408041 | literals.go | starcoder |
package fixpoint
// Useful link:
// https://spin.atomicobject.com/2012/03/15/simple-fixed-point-math/
// Q24 is a Q7.24 fixed point integer type that has 24 bits of precision to the
// right of the fixed point. It is designed to be used as a more efficient
// replacement for unit vectors with some extra room to avoid... | fixpoint.go | 0.919276 | 0.734453 | fixpoint.go | starcoder |
package ma
import (
"time"
)
//trimaCalculator TRIMA
type trimaCalculator struct {
*Ticker
Period int32
Count int32
Factor float64
Idx float64
MiddleIdx int32
TrailingIdx int32
Temp []float64
NumeratorSub float64
NumeratorAdd float64
Numerator float64
SubDone ... | ma/trima.go | 0.534127 | 0.491517 | trima.go | starcoder |
package exec
import (
"context"
"fmt"
"github.com/ebay/beam/blog"
"github.com/ebay/beam/msg/facts"
"github.com/ebay/beam/query/planner/plandef"
"github.com/ebay/beam/rpc"
"github.com/ebay/beam/util/parallel"
"github.com/ebay/beam/viewclient/lookups"
)
// newProjection returns a projection operator (aka SELE... | src/github.com/ebay/beam/query/exec/projection.go | 0.612426 | 0.409693 | projection.go | starcoder |
package dynamodb
import (
"fmt"
"github.com/aws/aws-sdk-go/service/dynamodb/expression"
"github.com/pipe-cd/pipe/pkg/datastore"
)
func buildDynamoDBCondition(f datastore.ListFilter) (expression.ConditionBuilder, error) {
switch f.Operator {
case "==":
return expression.Name(f.Field).Equal(expression.Value(f... | pkg/datastore/dynamodb/expression.go | 0.535584 | 0.442757 | expression.go | starcoder |
package pizzabot
import (
"errors"
"strconv"
"strings"
"github.com/andrewcopp/geometry"
)
// Parser identies objects that can parse the Pizzabot args.
type Parser interface {
Parse(args []string) error
}
// Config is a strongly-typed representation of the command line args.
type Config struct {
Size *geomet... | config.go | 0.706393 | 0.458712 | config.go | starcoder |
package fn
//The Beta function and relatives.
import (
"math"
)
func betaContinuedFraction(α, β, x float64) float64 {
var aa, del, res, qab, qap, qam, c, d, m2, m, acc float64
var i int64
const eps = 2.2204460492503131e-16
const maxIter = 1000000000
acc = 1e-16
qab = α + β
qap = α + 1.0
qam = α - 1.0
c ... | go/src/code.google.com/p/go-fn/fn/beta.go | 0.602997 | 0.474509 | beta.go | starcoder |
package models
import (
i336074805fc853987abe6f7fe3ad97a6a6f3077a16391fec744f671a015fbd7e "time"
i878a80d2330e89d26896388a3f487eef27b0a0e6c010c493bf80be1452208f91 "github.com/microsoft/kiota-abstractions-go/serialization"
)
// UserSimulationEventInfo
type UserSimulationEventInfo struct {
// Stores additi... | models/user_simulation_event_info.go | 0.563618 | 0.494141 | user_simulation_event_info.go | starcoder |
package statistics
import (
"fmt"
"math"
"sort"
"github.com/rpinheiroalmeida/collections"
"github.com/rpinheiroalmeida/linalg"
)
func Sum(sample collections.Vector) float64 {
total := 0.0
for _, value := range sample {
total += value
}
return total
}
func Mean(sample collections.Vector) float64 {
check(... | statistics.go | 0.832849 | 0.599309 | statistics.go | starcoder |
package statistic
import (
"fmt"
"time"
"github.com/jansorg/marketplace-stats/marketplace"
)
// NewYear returns a pointer to a Year
func NewYear(year int) *Year {
return &Year{
Year: year,
}
}
// Year contains the statistics for a given year
type Year struct {
Year int
Months []*Month
TotalCustomers ... | statistic/year.go | 0.651577 | 0.445469 | year.go | starcoder |
package continuous
import (
"github.com/jtejido/ggsl/specfunc"
"github.com/jtejido/stats"
"github.com/jtejido/stats/err"
"math"
"math/rand"
)
// Beta Prime distribution (Beta Distribution of the second kind)
// https://en.wikipedia.org/wiki/Beta_prime_distribution
type BetaPrime struct {
baseContinuousWithSourc... | dist/continuous/beta_prime.go | 0.818011 | 0.433502 | beta_prime.go | starcoder |
package main
var help = `
Demlo is a music library organizer. It can encode, fix case, change path
according to tags or file properties, tag from an online database, copy covers
while ignoring duplicates or those below a quality threshold, and much more. It
makes it possible to manage your libraries uniformly and dyn... | doc.go | 0.518059 | 0.436322 | doc.go | starcoder |
package common
import (
"log"
"engo.io/engo"
"engo.io/gl"
"github.com/ilackarms/sprite-locator/models"
"encoding/json"
"image"
"github.com/engoengine/math"
)
// sort sprites into rows, starting with top left, and going down row by row
func sortSprites(sprites []models.Sprite) []models.Sprite {
sorted := []mo... | common/spritesheet.go | 0.525125 | 0.406155 | spritesheet.go | starcoder |
package basically
// A Document represents a given text, and is responsible for
// handling the summarization and keyword extraction process.
type Document interface {
Summarize(length int, threshold float64, focus string) ([]*Sentence, error)
Highlight(length int, merge bool) ([]*Keyword, error)
Characters() (int,... | basically.go | 0.619586 | 0.484807 | basically.go | starcoder |
package compast
// Set of functions to create ast Nodes.
import (
"github.com/omakoto/compromise/src/compromise"
"github.com/omakoto/compromise/src/compromise/compfunc"
"sync/atomic"
)
func assertType(t *Token, tokenType int, argName string) *Token {
if t == nil {
panic(compromise.NewSpecErrorf(nil, "%s must n... | src/compromise/compast/generator.go | 0.512937 | 0.473779 | generator.go | starcoder |
package server
import (
"time"
)
type Measurement interface {
SensorID() string
Measurement() string
Value() interface{}
Time() time.Time
}
type BatteryVoltageMeasurement struct {
SensorID_ string `json:"sensorID"`
// Voltage given in volts
Voltage_ float64 `json:"voltage"`
// Time when measurement was re... | server/measurement.go | 0.865082 | 0.434761 | measurement.go | starcoder |
package sat
import (
"fmt"
"strings"
)
// Constraint implementations limit the circumstances under which a
// particular Installable can appear in a solution.
type Constraint interface {
String(subject Identifier) string
apply(x constrainer, subject Identifier)
}
// AppliedConstraint values compose a single Cons... | pkg/controller/registry/resolver/sat/constraints.go | 0.847005 | 0.430147 | constraints.go | starcoder |
package main
import (
"fmt"
"sort"
"strings"
"github.com/scottyw/adventofcode2020/pkg/aoc"
)
func main() {
input := aoc.FileLinesToStringSlice("input/10.txt")
chain := parseInput(input)
fmt.Println(countCombinations(chain))
}
/****************************************************************
From part A we k... | cmd/day10b/main.go | 0.561936 | 0.493531 | main.go | starcoder |
package templates
const MigrateReadme = `# Migration Tools
Build and run:
{{.Backtick}}{{.Backtick}}{{.Backtick}}
cd migrate && go build -o "migrate"
migrate user:pass@tcp(localhost:3306)/dbname?parseTime=true&multiStatements=true /path/migrations/dir/
{{.Backtick}}{{.Backtick}}{{.Backtick}}
**Optional keys:**
- {{.... | templates/migrate.go | 0.527803 | 0.458046 | migrate.go | starcoder |
package utils
// ToInt32Slice takes a go slice and convets it to a []int32. No overflow checking
func ToInt32Slice(input interface{}) []int32 {
switch array := input.(type) {
case []int32:
return array
case []float32:
x := make([]int32, len(array))
for i := range array {
x[i] = int32(array[i])
}
return... | utils/typeslice.go | 0.537527 | 0.649655 | typeslice.go | starcoder |
package redblack
import (
"math"
"sync"
)
// NewRedBlackTree returns a new red-back tree. All operations on the tree are
// safe to be accessed concurrently.
func NewRedBlackTree() *Tree {
sentinel := &node{color: black, payload: "sentinel"}
return &Tree{
lock: sync.RWMutex{},
root: sentinel,
senti... | redblack/tree.go | 0.871803 | 0.489564 | tree.go | starcoder |
package sketchy
import (
"math/rand"
"github.com/ojrac/opensimplex-go"
)
const (
defaultScale = 0.001
defaultOctaves = 1
defaultPersistence = 0.9
defaultLacunarity = 2.0
)
// Pseudo-random number generator data
type Rng struct {
seed int64
noise opensimplex.Noise
octaves int
pe... | random.go | 0.785843 | 0.54256 | random.go | starcoder |
package processor
import (
"errors"
"fmt"
"time"
"github.com/Jeffail/benthos/v3/internal/docs"
"github.com/Jeffail/benthos/v3/lib/log"
"github.com/Jeffail/benthos/v3/lib/metrics"
"github.com/Jeffail/benthos/v3/lib/types"
"github.com/opentracing/opentracing-go"
"github.com/trivago/grok"
)
//-----------------... | lib/processor/grok.go | 0.792504 | 0.662943 | grok.go | starcoder |
package reconcile
import (
"k8s.io/apimachinery/pkg/types"
)
// Result contains the result of a Reconcile invocation.
type Result struct {
// Requeue tells the Controller to requeue the reconcile key. Defaults to false.
Requeue bool
}
// Request contains the information necessary to reconcile a Kubernetes object... | examples/godocbot/vendor/sigs.k8s.io/controller-runtime/pkg/reconcile/reconcile.go | 0.780453 | 0.575469 | reconcile.go | starcoder |
package xyzm
// Cell is a 128-bit integer that interleaves four coordinates.
type Cell struct {
Hi uint64
Lo uint64
}
func (c Cell) String() string {
s := make([]byte, 0, 32)
const hex = "0123456789abcdef"
for i := 0; i < 64; i += 4 {
s = append(s, hex[(c.Hi>>(60-i))&15])
}
for i := 0; i < 64; i += 4 {
s =... | xyzm/cell.go | 0.802981 | 0.446736 | cell.go | starcoder |
package geojson
import (
"github.com/tidwall/geojson/geometry"
)
// Clip clips the contents of a geojson object and return
func Clip(
obj Object, clipper Object, opts *geometry.IndexOptions,
) (clipped Object) {
switch obj := obj.(type) {
case *Point:
return clipPoint(obj, clipper, opts)
case *Rect:
return c... | clip.go | 0.738386 | 0.449513 | clip.go | starcoder |
package symbol
import (
"fmt"
"github.com/bazo-blockchain/lazo/parser/node"
)
// SymbolTable maps symbols to nodes, designators to declarations, expressions to types and contains the global scope
type SymbolTable struct {
GlobalScope *GlobalScope
symbolToNode map[Symbol]node.Node
designatorD... | checker/symbol/symbol_table.go | 0.830353 | 0.532547 | symbol_table.go | starcoder |
package rest
import (
"reflect"
)
type ReflectConsumer interface {
Consume(v reflect.Value)
ForIndex(index int) ReflectConsumer
ForField(field reflect.StructField) ReflectConsumer
ForKey(key string) ReflectConsumer
}
type ReflectShouldConsume func(t reflect.Type) bool
type ReflectIterator func(value reflect.Va... | pkg/rest/reflect.go | 0.611846 | 0.583559 | reflect.go | starcoder |
package event
import "fmt"
// Timing keeps min/max/avg information about a timer over a certain interval
type Timing struct {
Name string
Min int64
Max int64
Value int64
Count int64
}
// NewTiming is a factory for a Timing event, setting the Count to 1 to prevent div_by_0 errors
func NewTiming(k string, de... | event/timing.go | 0.741393 | 0.41401 | timing.go | starcoder |
package algorithm
import (
"bufio"
"fmt"
"models"
"os"
"path/filepath"
)
func Select(S *models.Graph2D) (*models.Point2D, *models.Point2D) {
var p,q models.Point2D
for index, point := range S.Points {
if index == 0 {
p = point
continue
}
if index == 1 {
q = point
continue
}
// maximum y... | src/algorithm/algorithm2d.go | 0.534612 | 0.496521 | algorithm2d.go | starcoder |
package transformer
import (
"image"
"github.com/cs3238-tsuzu/prasoba/driver"
"github.com/hajimehoshi/ebiten/v2"
)
// Rect is a image.Rectangle with the capability to translate
type Rect struct {
rect image.Rectangle
}
// NewRect returns a new Rect
func NewRect(r image.Rectangle) *Rect {
return &Rect{
rect: ... | transformer/rect.go | 0.873566 | 0.546617 | rect.go | starcoder |
package gorp
import (
"fmt"
"reflect"
)
type SqliteDialect struct {
suffix string
}
func (d SqliteDialect) QuerySuffix() string { return ";" }
func (d SqliteDialect) ToSqlType(val reflect.Type, maxsize int, isAutoIncr bool) string {
switch val.Kind() {
case reflect.Ptr:
return d.ToSqlType(val.Elem(), maxsiz... | dialect_sqlite.go | 0.687105 | 0.407216 | dialect_sqlite.go | starcoder |
package day17
import (
"bufio"
"fmt"
"io"
"os"
)
const (
Inactive = '.'
Active = '#'
)
type Grid1D map[int]byte
type Grid2D map[int]Grid1D
type Grid3D map[int]Grid2D
type Grid4D map[int]Grid3D
func Day17() {
input, err := parseInput()
if err != nil {
panic(err)
}
fmt.Printf("Day 17 part 1 answer is %d... | day17/day17.go | 0.511473 | 0.433981 | day17.go | starcoder |
package gollection
func HashSetOf[T comparable](hasher func(data T) int, elements ...T) HashSet[T] {
var size = len(elements)
var set = MakeHashSet(hasher, size)
for _, v := range elements {
set.Put(v)
}
return set
}
func NumberSetOf[T Number](elements ...T) HashSet[T] {
return HashSetOf(NumberHasher[T], elem... | hash_set.go | 0.695855 | 0.534916 | hash_set.go | starcoder |
package memory
import (
"fmt"
"reflect"
)
// Read reads the value pointed at p from the decoder d using C alignment rules.
// If v is an array or slice, then each of the elements will be read,
// sequentially.
func Read(d *Decoder, p interface{}) {
v := reflect.ValueOf(p)
if v.Kind() != reflect.Ptr {
panic(fmt... | gapis/memory/read.go | 0.522689 | 0.415492 | read.go | starcoder |
package main
/*
Given a sorted array nums, remove the duplicates in-place such that each element appear only once and return the new length.
Do not allocate extra space for another array, you must do this by modifying the input array in-place with O(1) extra memory.
Example 1:
Given nums = [1,1,2],
Your function s... | Programs/026Remove Duplicates from Sorted Array/026Remove Duplicates from Sorted Array.go | 0.516108 | 0.733571 | 026Remove Duplicates from Sorted Array.go | starcoder |
package geodbtools
import "fmt"
// RecordBelongsRightFunc tests if a given record, given the byte-slice representation of
// its IP address, belongs into the right sub-tree or not.
// This function is used during build of a RecordTree.
type RecordBelongsRightFunc func(b []byte, depth uint) bool
// RecordTree represe... | record_tree.go | 0.822795 | 0.661766 | record_tree.go | starcoder |
package numbercompression
//Ref https://stackoverflow.com/questions/5901153/compress-large-integers-into-smallest-possible-string
//base64::urlsafe()
//Base64 := "ABCDEFGHIJKLMNOPQRSTUVWXYZabcdefghijklmnopqrstuvwxyz0123456789-_"
var defaultEncodeDic = map[int]string{
0: "A",
1: "B",
2: "C",
3: "D",
4: "E",... | numbercompression/numbercompression.go | 0.513181 | 0.422147 | numbercompression.go | starcoder |
package iso20022
// Provides further details specific to the individual direct debit transaction(s) included in the message.
type DirectDebitTransactionInformation11 struct {
// Set of elements used to reference a payment instruction.
PaymentIdentification *PaymentIdentification1 `xml:"PmtId"`
// Set of elements ... | DirectDebitTransactionInformation11.go | 0.793946 | 0.482185 | DirectDebitTransactionInformation11.go | starcoder |
package audio
type Format struct {
NumChans int // number of channels (0 if unset)
Rate int // samples per second (0 if unset)
Layout int
Type int
}
type Formatted interface {
GetFormat(name string) Format
}
type FormatSetter interface {
SetFormat(f Format)
}
const Unspecified = 0
// layouts (earlier are... | _vendor/src/github.com/rogpeppe/rog-go/exp/abc/audio/format.go | 0.649356 | 0.407687 | format.go | starcoder |
package main
import (
"fmt"
)
type Trimesh struct {
Namer
Grouper
V []Tuple // Vertices
VN []Tuple // Vertex normals
VT []Tuple // Vertex texture coordinates
T []MeshTriangle
material *Material // TODO! Handling of material needs to be refactored
}
type MeshTriangle struct {
mesh ... | trimesh.go | 0.520253 | 0.524943 | trimesh.go | starcoder |
package timelearn
// Counts contains statistics about the current state of problems.
type Counts struct {
// The number of "Active" problems. Something is considered
// active if it is due for learning.
Active int
// The number of problems that are being learned, but aren't
// ready to be asked again.
Later in... | timelearn/stats.go | 0.577495 | 0.494629 | stats.go | starcoder |
package tls
import (
"crypto/tls"
"crypto/x509"
"io/ioutil"
)
//------------------------------------------------------------------------------
// Documentation is a markdown description of how and why to use TLS settings.
const Documentation = `### TLS
Custom TLS settings can be used to override system defaults... | lib/util/tls/type.go | 0.731346 | 0.522202 | type.go | starcoder |
package models
import (
i878a80d2330e89d26896388a3f487eef27b0a0e6c010c493bf80be1452208f91 "github.com/microsoft/kiota-abstractions-go/serialization"
)
// SensitivityLabelAssignment
type SensitivityLabelAssignment struct {
// Stores additional data not described in the OpenAPI description found when deseriali... | models/sensitivity_label_assignment.go | 0.717903 | 0.422505 | sensitivity_label_assignment.go | starcoder |
package aho_corasick
import (
"unsafe"
)
type iDFA struct {
atom automaton
}
func (d iDFA) MatchKind() *matchKind {
return d.atom.MatchKind()
}
func (d iDFA) StartState() stateID {
return d.atom.StartState()
}
func (d iDFA) MaxPatternLen() int {
return d.atom.Repr().max_pattern_len
}
func (d iDFA) PatternCou... | dfa.go | 0.572723 | 0.442335 | dfa.go | starcoder |
package extinfo
// TeamScore contains the name of the team and the score, i.e. flags scored in flag modes / points gained for holding bases in capture modes / frags achieved in DM modes / skulls collected
type TeamScore struct {
Name string `json:"name"` // name of the team, e.g. "good"
Score int `json:"score"`... | team_scores.go | 0.665302 | 0.407157 | team_scores.go | starcoder |
package autoscaler
import (
"context"
"errors"
"go.opencensus.io/stats"
"go.opencensus.io/stats/view"
"go.opencensus.io/tag"
"go.uber.org/zap"
)
// Measurement represents the type of the autoscaler metric to be reported
type Measurement int
const (
// DesiredPodCountM is used for the pod count that autoscale... | pkg/autoscaler/stats_reporter.go | 0.703651 | 0.460046 | stats_reporter.go | starcoder |
package aep
import (
"github.com/rioam2/rifx"
)
// LayerQualityLevel denotes the quality level of a layer (eg: Best, Draft, Wireframe)
type LayerQualityLevel uint16
const (
// LayerQualityBest enumerates the value of a layer with Best Quality
LayerQualityBest LayerQualityLevel = 0x0002
// LayerQualityDraft enume... | layer.go | 0.639286 | 0.616503 | layer.go | starcoder |
package models
import (
"time"
"gonum.org/v1/gonum/mat"
)
type BrownianModelConfig struct {
InitialVariance float64
ProcessVariance float64
ObservationVariance float64
}
type BrownianModel struct {
initialState State
dims int
transition *mat.Dense
observationModel *mat.Dens... | models/brownian.go | 0.784567 | 0.460835 | brownian.go | starcoder |
package assert
import (
"time"
)
func abs(x float64) float64 {
if x < 0 {
return -x
}
return x
}
// EqualErrors - asserts that specific error was produced
func EqualErrors(reporter interface{}, want, got error) {
if want == nil || got == nil || want.Error() != got.Error() {
reportError(reporter, &failedErro... | equality.go | 0.674587 | 0.414129 | equality.go | starcoder |
package transform
import (
"errors"
"fmt"
)
// Sort by Rank Transform is a family of transforms typically used after
// a BWT to reduce the variance of the data prior to entropy coding.
// SBR(alpha) is defined by sbr(x, alpha) = (1-alpha)*(t-w1(x,t)) + alpha*(t-w2(x,t))
// where x is an item in the data list, t is... | transform/SBRT.go | 0.772359 | 0.412294 | SBRT.go | starcoder |
package parse
import (
"errors"
"fmt"
"strconv"
"strings"
"time"
)
// Private function to catch Epoch integer in string
func ifEpoch(s string) (time.Time, error) {
i, err := strconv.ParseInt(s, 10, 64)
if err != nil {
return time.Time{}, err
}
if len(s) > 10 {
seconds, _ := strconv.ParseInt(s[0:10], 10... | parse/dateparse.go | 0.602296 | 0.545286 | dateparse.go | starcoder |
package sql
import (
"context"
"strconv"
"github.com/google/uuid"
"vitess.io/vitess/go/vt/sqlparser"
"github.com/liquidata-inc/dolt/go/libraries/doltcore/row"
"github.com/liquidata-inc/dolt/go/libraries/doltcore/schema"
"github.com/liquidata-inc/dolt/go/store/chunks"
"github.com/liquidata-inc/dolt/go/store/... | go/libraries/doltcore/sql/values.go | 0.652684 | 0.481759 | values.go | starcoder |
package prjn
import (
"github.com/emer/emergent/evec"
"github.com/emer/etable/etensor"
"github.com/goki/ki/ints"
"github.com/goki/mat32"
)
// Rect implements a rectangular pattern of connectivity between two layers
// where the lower-left corner moves in proportion to receiver position with offset
// and multipl... | prjn/rect.go | 0.698432 | 0.53127 | rect.go | starcoder |
package labels
import (
"bufio"
"bytes"
"os"
"sort"
"strconv"
"strings"
"github.com/cespare/xxhash"
"github.com/pkg/errors"
)
const sep = '\xff'
// Label is a key/value pair of strings.
type Label struct {
Name, Value string
}
// Labels is a sorted set of labels. Order has to be guaranteed upon
// instan... | vendor/github.com/dnxware/tsdb/labels/labels.go | 0.66628 | 0.404331 | labels.go | starcoder |
package value
import (
"encoding/base64"
"fmt"
"reflect"
)
// NewValueReflect creates a Value backed by an "interface{}" type,
// typically an structured object in Kubernetes world that is uses reflection to expose.
// The provided "interface{}" value must be a pointer so that the value can be modified via reflect... | vendor/sigs.k8s.io/structured-merge-diff/v4/value/valuereflect.go | 0.673192 | 0.519399 | valuereflect.go | starcoder |
package mlpack
/*
#cgo CFLAGS: -I./capi -Wall
#cgo LDFLAGS: -L. -lmlpack_go_approx_kfn
#include <capi/approx_kfn.h>
#include <stdlib.h>
*/
import "C"
import "gonum.org/v1/gonum/mat"
type ApproxKfnOptionalParam struct {
Algorithm string
CalculateError bool
ExactDistances *mat.Dense
InputModel *appro... | approx_kfn.go | 0.668556 | 0.420659 | approx_kfn.go | starcoder |
package model
import (
"math"
"strconv"
native_time "time"
)
// Timestamp is the number of milliseconds since the epoch
// (1970-01-01 00:00 UTC) excluding leap seconds.
type Timestamp int64
const (
// MinimumTick is the minimum supported time resolution. This has to be
// at least native_time.Second in order... | Godeps/_workspace/src/github.com/prometheus/client_golang/model/timestamp.go | 0.880579 | 0.441854 | timestamp.go | starcoder |
package flightdb
import (
"fmt"
"time"
"github.com/skypies/adsb"
"github.com/skypies/geo"
)
// Trackpoint is a data point that locates an aircraft in space and time, etc
type Trackpoint struct {
DataSource string // What kind of trackpoint is this; flightaware radar, local ADSB, etc
//DataSystem // emb... | trackpoint.go | 0.628407 | 0.465387 | trackpoint.go | starcoder |
// Package skein256 implements the Skein256 hash function
// based on the Threefish256 tweakable block cipher.
package skein256
import (
"hash"
"github.com/aead/skein"
)
// Sum512 computes the 512 bit Skein256 checksum (or MAC if key is set) of msg
// and writes it to out. The key is optional and can be nil.
func... | vendor/github.com/aead/skein/skein256/skein.go | 0.835416 | 0.488222 | skein.go | starcoder |
package starlark
import (
"fmt"
"reflect"
"github.com/pkg/errors"
"go.starlark.net/starlark"
"go.starlark.net/starlarkstruct"
)
// GoValue represents an inherent Go value which can be
// converted to a Starlark value/type
type GoValue struct {
val interface{}
}
// NewGoValue creates a value with inherent Go ... | starlark/govalue.go | 0.729905 | 0.441071 | govalue.go | starcoder |
package filters
import (
"gitee.com/andrewgithub/FireShotGo/firetheme"
"github.com/golang/freetype/truetype"
"github.com/golang/glog"
"golang.org/x/image/font"
"golang.org/x/image/math/fixed"
"image"
"image/color"
"strings"
)
// DPI constant. Ideally it would be read from the various system.
const DPI = 96
t... | filters/text.go | 0.772531 | 0.428413 | text.go | starcoder |
package quantize
import (
"image"
"image/color"
"sort"
)
// Spread takes in a slice of RGB pixels, and returns the delta across the red,
// green, & blue components of all pixels.
func Spread(pixels []color.RGBA) (uint8, uint8, uint8) {
// If there are no pixels, then the spread must be zero
if len(pixels) == ... | mmcq.go | 0.865267 | 0.597696 | mmcq.go | starcoder |
package data
import (
"fmt"
"image"
)
type Layer [][]float32
func NewLayer(sizeX, sizeY int) Layer {
data := make([][]float32, sizeY)
for j := 0; j < sizeY; j++ {
data[j] = make([]float32, sizeX)
}
return data
}
func GetLayers(image image.Image) (Layer, Layer, Layer, uint, uint) {
sizeX := image.Bounds().... | labo-2/jpeg2000/data/layer.go | 0.604282 | 0.44077 | layer.go | starcoder |
package fields
import (
"bytes"
"encoding/base64"
"encoding/binary"
"fmt"
"math"
)
const (
// CurrentVersion is the Forest version that this library writes
CurrentVersion Version = 1
// HashDigestLengthSHA512_256 is the length of the digest produced by the SHA512/256 hash algorithm
HashDigestLengthSHA512_25... | fields/primitives.go | 0.747432 | 0.408867 | primitives.go | starcoder |
package main
import "errors"
// returns true if rune is a letter of the English alphabet
func isAlpha(r rune) bool {
return (r >= 65 && r <= 90) || (r >= 97 && r <= 122)
}
// returns true if rune is a numeral
func isNumeral(r rune) bool {
return (r >= 48 && r <= 57)
}
func isSigil(r rune) bool {
for _, s := rang... | lexer.go | 0.539711 | 0.460956 | lexer.go | starcoder |
package mind
import "github.com/gonum/matrix/mat64"
// Version.
const Version = "0.0.1"
// Mind represents the neural network.
type Mind struct {
LearningRate float64 // speed the network will learn at
Iterations int // number of training iterations
HiddenUn... | mind.go | 0.830181 | 0.539469 | mind.go | starcoder |
package core
// InteractorTypeRef defines the location, name and version of an Interactor type.
type InteractorTypeRef struct {
TypeLocation string
TypeName string
TypeVersion VersionSpec
}
// VersionSpec defines the a version using Semantic Versioning (SemVer) with an
// optional label.
type VersionSpec stru... | core/specs.go | 0.62395 | 0.441191 | specs.go | starcoder |
package db
// Database allows the persistence and retrieval of key / value data.
type Database interface {
// View provides a Transaction that can be used to read from the database
View(func(Transaction) error) error
// Update provides a Transaction that can be used to read from or write to the database
Updat... | db/interface.go | 0.83825 | 0.532425 | interface.go | starcoder |
package geometry
import (
"math"
"github.com/tab58/v1/spatial/pkg/numeric"
"gonum.org/v1/gonum/blas/blas64"
)
// Matrix4D is a row-major representation of a 4x4 matrix.
type Matrix4D struct {
elements [16]float64
}
// Rows returns the number of rows in the matrix.
func (m *Matrix4D) Rows() uint { return 4 }
//... | pkg/geometry/matrix4d.go | 0.810516 | 0.771069 | matrix4d.go | starcoder |
package docs
import (
"bytes"
"encoding/json"
"strings"
"github.com/alecthomas/template"
"github.com/swaggo/swag"
)
var doc = `{
"schemes": {{ marshal .Schemes }},
"swagger": "2.0",
"info": {
"description": "{{.Description}}",
"title": "{{.Title}}",
"contact": {},
"l... | docs/docs.go | 0.515376 | 0.405566 | docs.go | starcoder |
package main
import (
"bufio"
"fmt"
"log"
"os"
"reflect"
"sort"
"strconv"
"strings"
)
// Hand represents a five-card poker hand.
type Hand struct {
// The ranks are sorted in descending order.
// e.g. the hand [AC 8D 8H 3S 2S] has ranks [14 8 8 3 2]
// [KC 9D 9H 3C 2C] [13 9 9 3 2]... | go/problems/problem54.go | 0.566258 | 0.442034 | problem54.go | starcoder |
package gographviz
//The analysed representation of the Graph parsed from the DOT format.
type Graph struct {
Attrs Attrs
Name string
Directed bool
Strict bool
Nodes *Nodes
Edges *Edges
SubGraphs *SubGraphs
Relations *Relations
}
//Creates a new empty graph, ready to be populated.
func N... | vendor/github.com/awalterschulze/gographviz/graph.go | 0.759225 | 0.542257 | graph.go | starcoder |
package seq
import (
"time"
"github.com/leesjensen/go-chart/util"
)
// Time is a utility singleton with helper functions for time seq generation.
var Time timeSequence
type timeSequence struct{}
// Days generates a seq of timestamps by day, from -days to today.
func (ts timeSequence) Days(days int) []time.Time {... | seq/time.go | 0.68458 | 0.499878 | time.go | starcoder |
package dnaThreeBit
import (
"github.com/vertgenlab/gonomics/dna"
"log"
"strings"
)
// RuneToThreeBitBase returns a single bases in ThreeBitBase format that corresponds to the given rune
func RuneToThreeBitBase(r rune) ThreeBitBase {
switch r {
case 'A':
return A
case 'C':
return C
case 'G':
return G
ca... | dnaThreeBit/convert.go | 0.821796 | 0.434761 | convert.go | starcoder |
package onshape
import (
"encoding/json"
)
// BTPTopLevelEnumDeclaration284AllOf struct for BTPTopLevelEnumDeclaration284AllOf
type BTPTopLevelEnumDeclaration284AllOf struct {
Annotations *[]BTPAnnotation231 `json:"annotations,omitempty"`
BtType *string `json:"btType,omitempty"`
SpaceInEmptyList *BTPSpace10 `json... | onshape/model_btp_top_level_enum_declaration_284_all_of.go | 0.748995 | 0.407805 | model_btp_top_level_enum_declaration_284_all_of.go | starcoder |
package graph
import (
"fmt"
"github.com/graphql-go/graphql"
)
type Term struct {
id string
name string
value string
terms []string
}
func CreateTermSchema() (*graphql.Schema, error) {
terms := map[string]Term{
"entropy": Term{
id: "entropy",
name: "Entropy",
value: "Entropy represents the... | packages/go/graph/term.go | 0.605099 | 0.7017 | term.go | starcoder |
Subsets and Splits
No community queries yet
The top public SQL queries from the community will appear here once available.