sortedset

package
v1.2.9 Latest Latest
Warning

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

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

Documentation

Index

Constants

This section is empty.

Variables

This section is empty.

Functions

This section is empty.

Types

type Element

type Element struct {
	Member string
	Score  float64
}

Element is a key-score pair

type Level

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

Level aspect of a node

type ScoreBorder

type ScoreBorder struct {
	Inf     int8
	Value   float64
	Exclude bool
}

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

func ParseScoreBorder

func ParseScoreBorder(s string) (*ScoreBorder, error)

ParseScoreBorder creates ScoreBorder from redis arguments

type SortedSet

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

SortedSet is a set which keys sorted by bound score

func Make

func Make() *SortedSet

Make makes a new SortedSet

func (*SortedSet) Add

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

Add puts member into set, and returns whether has inserted new node

func (*SortedSet) Count

func (sortedSet *SortedSet) Count(min *ScoreBorder, max *ScoreBorder) int64

Count returns the number of members which score within the given border

func (*SortedSet) ForEach

func (sortedSet *SortedSet) ForEach(start int64, stop int64, desc bool, consumer func(element *Element) bool)

ForEach visits each member which rank within [start, stop), sort by ascending order, rank starts from 0

func (*SortedSet) ForEachByScore

func (sortedSet *SortedSet) ForEachByScore(min *ScoreBorder, max *ScoreBorder, offset int64, limit int64, desc bool, consumer func(element *Element) bool)

ForEachByScore visits members which score within the given border

func (*SortedSet) Get

func (sortedSet *SortedSet) Get(member string) (element *Element, ok bool)

Get returns the given member

func (*SortedSet) GetRank

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

GetRank returns the rank of the given member, sort by ascending order, rank starts from 0

func (*SortedSet) Len

func (sortedSet *SortedSet) Len() int64

Len returns number of members in set

func (*SortedSet) PopMin added in v1.2.9

func (sortedSet *SortedSet) PopMin(count int) []*Element

func (*SortedSet) Range

func (sortedSet *SortedSet) Range(start int64, stop int64, desc bool) []*Element

Range returns members which rank within [start, stop), sort by ascending order, rank starts from 0

func (*SortedSet) RangeByScore

func (sortedSet *SortedSet) RangeByScore(min *ScoreBorder, max *ScoreBorder, offset int64, limit int64, desc bool) []*Element

RangeByScore returns members which score within the given border param limit: <0 means no limit

func (*SortedSet) Remove

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

Remove removes the given member from set

func (*SortedSet) RemoveByRank

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

RemoveByRank removes member ranking within [start, stop) sort by ascending order and rank starts from 0

func (*SortedSet) RemoveByScore

func (sortedSet *SortedSet) RemoveByScore(min *ScoreBorder, max *ScoreBorder) int64

RemoveByScore removes members which score within the given border

Jump to

Keyboard shortcuts

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