sortedset

package
v1.2.10 Latest Latest
Warning

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

Go to latest
Published: Aug 26, 2024 License: GPL-3.0 Imports: 5 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)

ParseScoreBorder creates ScoreBorder from redis arguments

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 LexBorder

type LexBorder struct {
	Inf     int8
	Value   string
	Exclude bool
}

LexBorder represents range of a string value, including: <, <=, >, >=, +, -

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
}

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 it has inserted new node

func (*SortedSet) ForEach

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

ForEach visits members which score or member within the given border

func (*SortedSet) ForEachByRank

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

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

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

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

func (*SortedSet) Range

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

Range returns members which score or member within the given border param limit: <0 means no limit

func (*SortedSet) RangeByRank

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

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

func (*SortedSet) RangeCount

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

RangeCount returns the number of members which score or member within the given border

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) RemoveRange

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

RemoveRange removes members which score or member within the given border

func (*SortedSet) ZSetScan

func (sortedSet *SortedSet) ZSetScan(cursor int, count int, pattern string) ([][]byte, int)

Jump to

Keyboard shortcuts

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