ranking

package
v0.0.0-...-29c100b Latest Latest
Warning

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

Go to latest
Published: Jun 20, 2017 License: Apache-2.0 Imports: 2 Imported by: 0

Documentation

Index

Constants

View Source
const SKIPLIST_MAXLEVEL = 32

跳跃表最大层数

View Source
const SKIPLIST_P = 0.25

随机概率

Variables

View Source
var (
	RTS map[int32]*RankTree
)

Functions

func ResetRankTree

func ResetRankTree(rtype int32)

Types

type RankInfo

type RankInfo struct {
	Id        int64
	Val       int64
	Rank      int32
	Timestamp int64
}

type RankTree

type RankTree struct {
	Sl           *skiplist
	EntryMapping map[int64]*RankInfo
}

func GetRankTree

func GetRankTree(rtype int32) *RankTree

func NewRankTree

func NewRankTree() *RankTree

func (*RankTree) AddRankInfo

func (rt *RankTree) AddRankInfo(uid int64, val int64, timestamp int64)

添加新排名信息

func (*RankTree) IncrRankInfo

func (rt *RankTree) IncrRankInfo(uid int64, val int64, timestamp int64)

增加个人排行榜数据

func (*RankTree) QueryByRank

func (rt *RankTree) QueryByRank(rank int32) *RankInfo

根据排名查询信息

func (*RankTree) QueryByRankRange

func (rt *RankTree) QueryByRankRange(min, max int32) []*RankInfo

查询指定范围排名

func (*RankTree) QueryRankInfo

func (rt *RankTree) QueryRankInfo(uid int64) *RankInfo

查询用户排名

func (*RankTree) RemoveRankInfo

func (rt *RankTree) RemoveRankInfo(uid int64) bool

删除排名信息

func (*RankTree) UpdateRankInfo

func (rt *RankTree) UpdateRankInfo(uid int64, val int64, timestamp int64)

更新排名信息(比自己原有数据小,则不做更新)

Jump to

Keyboard shortcuts

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