Versions in this module Expand all Collapse all v0 v0.6.1 Aug 17, 2024 v0.6.0 Aug 14, 2024 Changes in this version + var ErrIndexErr = errors.New("ranking index error") + var ErrNonexistentRanking = errors.New("nonexistent ranking") + var ErrNotExistCompetitor = errors.New("ranking not exist competitor") + type BinarySearch struct + func NewBinarySearch[CompetitorID comparable, Score constraints.Ordered](options ...BinarySearchOption[CompetitorID, Score]) *BinarySearch[CompetitorID, Score] + func (slf *BinarySearch[CompetitorID, Score]) Clear() + func (slf *BinarySearch[CompetitorID, Score]) Cmp(s1, s2 Score) int + func (slf *BinarySearch[CompetitorID, Score]) Competitor(competitorId CompetitorID, score Score) + func (slf *BinarySearch[CompetitorID, Score]) GetAllCompetitor() []CompetitorID + func (slf *BinarySearch[CompetitorID, Score]) GetCompetitor(rank int) (competitorId CompetitorID, err error) + func (slf *BinarySearch[CompetitorID, Score]) GetCompetitorWithRange(start, end int) ([]CompetitorID, error) + func (slf *BinarySearch[CompetitorID, Score]) GetRank(competitorId CompetitorID) (int, error) + func (slf *BinarySearch[CompetitorID, Score]) GetRankDefault(competitorId CompetitorID, defaultValue int) int + func (slf *BinarySearch[CompetitorID, Score]) GetScore(competitorId CompetitorID) (score Score, err error) + func (slf *BinarySearch[CompetitorID, Score]) GetScoreDefault(competitorId CompetitorID, defaultValue Score) Score + func (slf *BinarySearch[CompetitorID, Score]) MarshalJSON() ([]byte, error) + func (slf *BinarySearch[CompetitorID, Score]) OnRankChangeEvent(competitorId CompetitorID, oldRank, newRank int, oldScore, newScore Score) + func (slf *BinarySearch[CompetitorID, Score]) OnRankClearBeforeEvent() + func (slf *BinarySearch[CompetitorID, Score]) RegRankChangeEvent(handle BinarySearchRankChangeEventHandle[CompetitorID, Score]) + func (slf *BinarySearch[CompetitorID, Score]) RegRankClearBeforeEvent(handle BinarySearchRankClearBeforeEventHandle[CompetitorID, Score]) + func (slf *BinarySearch[CompetitorID, Score]) RemoveCompetitor(competitorId CompetitorID) + func (slf *BinarySearch[CompetitorID, Score]) Size() int + func (slf *BinarySearch[CompetitorID, Score]) UnmarshalJSON(bytes []byte) error + func (slf BinarySearch) RegRankChangeEventHandle(handle BinarySearchRankChangeEventHandle[CompetitorID, Score]) + func (slf BinarySearch) RegRankClearBeforeEventHandle(handle BinarySearchRankClearBeforeEventHandle[CompetitorID, Score]) + type BinarySearchOption func(list *BinarySearch[CompetitorID, Score]) + func WithBinarySearchASC[CompetitorID comparable, Score constraints.Ordered]() BinarySearchOption[CompetitorID, Score] + func WithBinarySearchCount[CompetitorID comparable, Score constraints.Ordered](rankCount int) BinarySearchOption[CompetitorID, Score] + type BinarySearchRankChangeEventHandle func(ranking *BinarySearch[CompetitorID, Score], competitorId CompetitorID, ...) + type BinarySearchRankClearBeforeEventHandle func(ranking *BinarySearch[CompetitorID, Score])