sortedset

package
v0.0.0-...-c3f54fb Latest Latest
Warning

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

Go to latest
Published: Oct 13, 2024 License: Apache-2.0 Imports: 6 Imported by: 0

Documentation

Index

Constants

This section is empty.

Variables

This section is empty.

Functions

This section is empty.

Types

type Border

type Border interface {
	// contains filtered or unexported methods
}

func ParseLexBorder

func ParseLexBorder(s string) (Border, error)

ParseLexBorder creates LexBorder from redis arguments

func ParseScoreBorder

func ParseScoreBorder(s string) (Border, error)

模拟score的范围 ParseScoreBorder creates ScoreBorder from redis arguments

type Level

type Level struct {
	// contains filtered or unexported fields
}

type LexBorder

type LexBorder struct {
	Inf     int8
	Value   string
	Exclude bool
}

模拟字符串的范围 LexBorder represents range of a string value, including: <, <=, >, >=, +, -

type Pair

type Pair struct {
	Member string
	Score  float64
}

要存储的值

type ScoreBorder

type ScoreBorder struct {
	Inf     int8
	Value   float64
	Exclude bool // 不包含(排除的意思)
}

ScoreBorder represents range of a float value, including: <, <=, >, >=, +inf, -inf

type SortedSet

type SortedSet struct {
	// contains filtered or unexported fields
}

score可以相同,member不能重复

func NewSortedSet

func NewSortedSet() *SortedSet

func (*SortedSet) Add

func (s *SortedSet) Add(member string, score float64) bool

bool 为true表示新增, false表示修改

func (*SortedSet) ForEach

func (s *SortedSet) ForEach(min, max Border, offset int64, count int64, desc bool, consumer func(pair *Pair) bool)

扫描[min,max] 范围内的节点,从偏移min + offset位置开始,扫面 count 个元素

func (*SortedSet) ForEachByRank

func (s *SortedSet) ForEachByRank(start, stop int64, desc bool, consumer func(pair *Pair) bool) error

start / stop都是正数 进行范围查询,扫描有序链表[start,stop)索引范围的节点,desc表示按照正序还是倒序

func (*SortedSet) Get

func (s *SortedSet) Get(member string) (*Pair, bool)

func (*SortedSet) GetRank

func (s *SortedSet) GetRank(member string, desc bool) (rank int64)

获取在链表中的排序索引号

func (*SortedSet) Len

func (s *SortedSet) Len() int64

func (*SortedSet) PopMin

func (s *SortedSet) PopMin(count int) []*Pair

删除最小的值

func (*SortedSet) Range

func (s *SortedSet) Range(min Border, max Border, offset int64, count int64, desc bool) []*Pair

func (*SortedSet) RangeByRank

func (s *SortedSet) RangeByRank(start, stop int64, desc bool) []*Pair

扫描[start,stop)范围的节点,起始索引从0开始

func (*SortedSet) RangeCount

func (s *SortedSet) RangeCount(min, max Border) int64

func (*SortedSet) Remove

func (s *SortedSet) Remove(member string) bool

func (*SortedSet) RemoveByRank

func (s *SortedSet) RemoveByRank(start int64, stop int64) int64

表示删除索引[start,stop)的节点

func (*SortedSet) RemoveRange

func (s *SortedSet) RemoveRange(min Border, max Border) int64

删除范围[min,max]的元素,这里的Border表示是Score或者Member

Jump to

Keyboard shortcuts

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