utils

package
v0.0.30 Latest Latest
Warning

This package is not in the latest version of its module.

Go to latest
Published: Jul 8, 2022 License: Apache-2.0 Imports: 9 Imported by: 0

Documentation

Index

Constants

This section is empty.

Variables

This section is empty.

Functions

func CalcRating added in v0.0.29

func CalcRating[T RatingRater](list []T) error

注意 list 应按照比赛成绩从高到底排序 implementing https://codeforces.com/blog/entry/20762 https://codeforces.com/blog/entry/77890

func CopyFile

func CopyFile(src, dst string) (int64, error)

func Map

func Map[T any, M any](s []T, f func(T) M) []M

func RandomString

func RandomString(n int) string

func TopoSort added in v0.0.25

func TopoSort(size int, dependon func(i, j int) bool) (res []int, err error)

dependon: whether i dependon j. Complexity: O(n^2)

Types

type ByteValue

type ByteValue int64

func (ByteValue) String

func (r ByteValue) String() string

type Checksum

type Checksum [32]byte

comparable

func FileChecksum

func FileChecksum(name string) Checksum

SHA256 hash for file content. for any error, return empty hash

func ReaderChecksum

func ReaderChecksum(reader io.Reader) Checksum

func (Checksum) String

func (r Checksum) String() string

type CtntType

type CtntType int
const (
	Cplain CtntType = iota
	Cbinary
	Csource
)

type HashValue

type HashValue []byte

func HashSum

func HashSum(a []HashValue) (sum HashValue)

type LangTag

type LangTag int
const (
	Lcpp LangTag = iota
	Lcpp11
	Lcpp14
	Lcpp17
	Lcpp20
	Lpython2
	Lpython3
	Lgo
	Ljava
	Lc
	Lplain
)

func SourceLang added in v0.0.26

func SourceLang(s string) LangTag

根据字符串推断程序语言

type RatingRater added in v0.0.29

type RatingRater interface {
	Rate(rating int)
	Rating() int
	// 此前参加了多少场比赛(不算当前这场)
	Count() int
}

Jump to

Keyboard shortcuts

? : This menu
/ : Search site
f or F : Jump to
y or Y : Canonical URL