common

package
v0.0.0-...-32a7359 Latest Latest
Warning

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

Go to latest
Published: Jun 14, 2023 License: GPL-3.0 Imports: 5 Imported by: 0

Documentation

Index

Constants

View Source
const TimeFormat = "Mon, 2 Jan 2006 15:04:05 -0700"

Similar to RFC1123Z but without trailing zero on day

Variables

This section is empty.

Functions

func AdditiveValueMapInsert

func AdditiveValueMapInsert[K comparable, V any, M ~map[K]V](inMap map[K]V, key K, additiveFunc func(V, V) V, valueToAdd V)

Insert operation that adds to an existing value in the map using a specified additive function

func CopyMap

func CopyMap[K comparable, V any, M ~map[K]V](inMap M) map[K]V

func CorrelateYearMonthCounts

func CorrelateYearMonthCounts(ymc1 YearMonthCount, ymc2 YearMonthCount) float64

func EqualiseYearMonths

func EqualiseYearMonths(ymc1 YearMonthCount, ymc2 YearMonthCount) (YearMonthCount, YearMonthCount)

Returns two filtered YMCs that contain data for the same years and months

func HigherStartKey

func HigherStartKey[K constraints.Ordered, V any, M ~map[K]V](inMapA M, inMapB M) K

Returns whichever map has the higher key at the beginning when sorted

func KeysInCommon

func KeysInCommon[K comparable, V any, M ~map[K]V](inMapA M, inMapB M) []K

func LowerEndKey

func LowerEndKey[K constraints.Ordered, V any, M ~map[K]V](inMapA M, inMapB M) K

Returns whichever map has the lower key at the end when sorted

func MaxInt

func MaxInt(numA int, numB int) int

func MinInt

func MinInt(numA int, numB int) int

func SliceContains

func SliceContains[V comparable](slice []V, valueToFind V) (bool, int)

func SliceIntToFloat

func SliceIntToFloat[I constraints.Integer, F constraints.Float](slice []I) []F

func SortedMapKeys

func SortedMapKeys[K constraints.Ordered, V any, M ~map[K]V](inMap M) []K

func SubtractiveValueMapRemove

func SubtractiveValueMapRemove[K comparable, V any, M ~map[K]V](inMap map[K]V, key K, subtractiveFunc func(V, V) (V, bool), valueToSubtract V)

Operation that subtracts from an existing value in the map using a specified subtractive function

Types

type Changes

type Changes struct {
	LineChanges
	NumFilesChanged int
}

func AddChanges

func AddChanges(a *Changes, b *Changes) *Changes

func SubtractChanges

func SubtractChanges(a *Changes, b *Changes) (*Changes, bool)

type Commit

type Commit struct {
	Changes

	Id            string
	RepoName      string
	Author        Person
	AuthorTime    int64
	Committer     Person
	CommitterTime int64
	Subject       string
	Body          string
}

type CommitMap

type CommitMap map[string]*Commit

func (*CommitMap) AddCommitMap

func (cm *CommitMap) AddCommitMap(cmToAdd CommitMap)

func (*CommitMap) SubtractCommitMap

func (cm *CommitMap) SubtractCommitMap(cmToSubtract CommitMap)

func (*CommitMap) YearMonthCounts

func (cm *CommitMap) YearMonthCounts() (YearMonthCount, YearMonthCount, YearMonthCount)

func (*CommitMap) YearRange

func (cm *CommitMap) YearRange(excludeEmpty bool) []int

type EmailSet

type EmailSet map[string]bool

func AddEmailSet

func AddEmailSet(a EmailSet, b EmailSet) EmailSet

func SubtractEmailSet

func SubtractEmailSet(a EmailSet, b EmailSet) (EmailSet, bool)

type LineChanges

type LineChanges struct {
	NumInsertions int
	NumDeletions  int
}

func AddLineChanges

func AddLineChanges(a *LineChanges, b *LineChanges) *LineChanges

func SubtractLineChanges

func SubtractLineChanges(a *LineChanges, b *LineChanges) (*LineChanges, bool)

type MonthCount

type MonthCount map[int]int

type Person

type Person struct {
	Name  string
	Email string
}

type Report

type Report interface {
	Generate()
}

type YearMonthCount

type YearMonthCount map[int]MonthCount

func (*YearMonthCount) Flatten

func (ymc *YearMonthCount) Flatten() []int

type YearlyChangeMap

type YearlyChangeMap map[int]*Changes

func (*YearlyChangeMap) AddChanges

func (ycm *YearlyChangeMap) AddChanges(changesToAdd *Changes, commitYear int)

YearlyChangeMap

func (*YearlyChangeMap) LineChanges

func (ycm *YearlyChangeMap) LineChanges() YearlyLineChangeMap

func (*YearlyChangeMap) SubtractChanges

func (ycm *YearlyChangeMap) SubtractChanges(changesToSubtract *Changes, commitYear int)

type YearlyEmailMap

type YearlyEmailMap map[int]EmailSet

func (*YearlyEmailMap) AddEmailSet

func (yem *YearlyEmailMap) AddEmailSet(emailSetToAdd EmailSet, year int)

func (*YearlyEmailMap) AddYearlyEmailMap

func (yem *YearlyEmailMap) AddYearlyEmailMap(yemToAdd YearlyEmailMap)

func (*YearlyEmailMap) CountArray

func (yem *YearlyEmailMap) CountArray(years []int) []int

func (*YearlyEmailMap) SubtractEmailSet

func (yem *YearlyEmailMap) SubtractEmailSet(emailSetToSubtract EmailSet, year int)

func (*YearlyEmailMap) SubtractYearlyEmailMap

func (yem *YearlyEmailMap) SubtractYearlyEmailMap(yemToSubtract YearlyEmailMap)

type YearlyLineChangeMap

type YearlyLineChangeMap map[int]*LineChanges

func (*YearlyLineChangeMap) AddLineChanges

func (ylcm *YearlyLineChangeMap) AddLineChanges(lineChangesToAdd *LineChanges, commitYear int)

YearlyLineChangeMap

func (*YearlyLineChangeMap) AddYearlyLineChangeMap

func (ylcm *YearlyLineChangeMap) AddYearlyLineChangeMap(ylcmToAdd YearlyLineChangeMap)

func (*YearlyLineChangeMap) SeparatedChangeArrays

func (ylcm *YearlyLineChangeMap) SeparatedChangeArrays(years []int) ([]int, []int)

Returns insertions and deletions in two separate arraus

func (*YearlyLineChangeMap) SubtractLineChanges

func (ylcm *YearlyLineChangeMap) SubtractLineChanges(lineChangesToSubtract *LineChanges, commitYear int)

func (*YearlyLineChangeMap) SubtractYearlyLineChangeMap

func (ylcm *YearlyLineChangeMap) SubtractYearlyLineChangeMap(ylcmToSubtract YearlyLineChangeMap)

Jump to

Keyboard shortcuts

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