zset

package
v1.0.0 Latest Latest
Warning

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

Go to latest
Published: Feb 10, 2023 License: MIT Imports: 4 Imported by: 0

Documentation

Index

Constants

This section is empty.

Variables

This section is empty.

Functions

This section is empty.

Types

type EncodeKey

type EncodeKey func(key, subKey []byte) []byte

type SkipList

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

SkipList defines the structure of skip list.

func NewSkipList

func NewSkipList() *SkipList

NewSkipList creates a new skip list.

func (*SkipList) Delete

func (skl *SkipList) Delete(score float64, member string)

delete removes nodes according to score and member.

func (*SkipList) GetByRank

func (skl *SkipList) GetByRank(rank uint64) *SklNode

getByRank returns node according to the rank. If the node corresponding to the rank is not found, then nil will be returned.

func (*SkipList) GetRank

func (skl *SkipList) GetRank(score float64, member string) int64

getRank returns the rank of node according to score and member. // The rank (or index) is 1-based, which means that the member with the lowest score has rank 1. If the node corresponding to the score and member is not found, then 0 will be returned.

func (*SkipList) Insert

func (skl *SkipList) Insert(score float64, member string) *SklNode

insert adds a member with score to skip list.

func (*SkipList) RevScoreRange

func (skl *SkipList) RevScoreRange(min, max float64) (val []interface{})

RevScoreRange returns all the elements whose score is between min and max. The elements are consideres to be ordered from high to low scores.

func (*SkipList) ScoreRange

func (skl *SkipList) ScoreRange(min, max float64) (val []interface{})

ScoreRange returns all the elements whose score is between min and max. The elements are consideres to be ordered from low to high scores.

func (*SkipList) Size

func (skl *SkipList) Size() int64

Size returns the length of skip list.

type SklLevel

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

SklLevel defines the structure of skip list level.

type SklNode

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

SklNode defines the structure of skip list node.

type SortedSet

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

SortedSet defines the structure of sorted set.

func New

func New() *SortedSet

New creates a new sorted set.

func (*SortedSet) IterateAndSend

func (z *SortedSet) IterateAndSend(chn chan *storage.LogEntry, encode EncodeKey)

func (*SortedSet) ZAdd

func (z *SortedSet) ZAdd(key string, score float64, member string)

ZAdd adds the specified member with the specified score to the sprted set stored at key.

func (*SortedSet) ZCard

func (z *SortedSet) ZCard(key string) int

ZCard returns the sorted set cardinality (number of elements) of he sorted set stored at key.

func (*SortedSet) ZClear

func (z *SortedSet) ZClear(key string)

ZClear clears the key in the sorted set.

func (*SortedSet) ZGetByRank

func (z *SortedSet) ZGetByRank(key string, rank int) (val []interface{})

ZGetByRank gets the member at key by rank, the rank is ordered from lowest to highest. The rank of lowest is 0 and so on.

func (*SortedSet) ZIncrBy

func (z *SortedSet) ZIncrBy(key string, member string, increment float64) float64

ZIncrBy increments the score of member in the sorted set stored at key by increment. If member does not exist in the sorted set, it is added with increment as its score (as if its previous score was 0.0). If key does not exist, a new sroted set with the specified member as its sole member is created.

func (*SortedSet) ZKeyExists

func (z *SortedSet) ZKeyExists(key string) bool

ZKeyExists checks if the key exists in the sorted set,

func (*SortedSet) ZRange

func (z *SortedSet) ZRange(key string, start, stop int) []interface{}

ZRange returns the specified range of elements in the sorted set stored at key.

func (*SortedSet) ZRangeWithScores

func (z *SortedSet) ZRangeWithScores(key string, start, stop int) []interface{}

ZRangeWithScores returns the specified range of elements in the sorted set stored at key.

func (*SortedSet) ZRank

func (z *SortedSet) ZRank(key, member string) int64

ZRank returns the rank of member in the sorted set stored at key, with the scores ordered from low to high. The rank (or index) is 0-based, which means that the member with the lowest score has rank 0. If the key or the member does not exist, -1 will be returned.

func (*SortedSet) ZRem

func (z *SortedSet) ZRem(key, member string) bool

ZRem removes the specified members from the sorted set stored at key. Non existing members are ignored.

func (*SortedSet) ZRevRange

func (z *SortedSet) ZRevRange(key string, start, stop int) []interface{}

ZRevRange returns the specified range of elements in the sorted set stored at key. The elements are considered to be ordered from the highest to the lowest score. Descending lexicographical order is used for elements with same score.

func (*SortedSet) ZRevRangeWithScores

func (z *SortedSet) ZRevRangeWithScores(key string, start, stop int) []interface{}

ZRevRangeWithScores returns the specified range of elements in the sorted set stored at key. The elements are considered to be ordered from the highest to the lowest score. Descending lexicographical order is used for elements with same score.

func (*SortedSet) ZRevRank

func (z *SortedSet) ZRevRank(key, member string) int64

ZRevRank returns the rank of member in the sorted set stored at key, with the scores ordered from high to low. The rank (or index) is 0-based, which means that the member with the highest score has rank 0.

func (*SortedSet) ZRevScoreRange

func (z *SortedSet) ZRevScoreRange(key string, min, max float64) (val []interface{})

ZRevScoreRange returns all the elements in the sorted set at key with a score between min and max (including elements with score equal to min or max). The elements are considered to be ordered from high to low scores.

func (*SortedSet) ZScore

func (z *SortedSet) ZScore(key string, member string) (ok bool, score float64)

ZScore returns the score of member in the sorted set at key.

func (*SortedSet) ZScoreRange

func (z *SortedSet) ZScoreRange(key string, min, max float64) (val []interface{})

ZScoreRange returns all the elements in the sorted set at key with a score between min and max (including elements with score equal to min or max). The elements are considered to be ordered from low to high scores.

type SortedSetNode

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

SortedSetNode defines the structure of sorted set node.

Jump to

Keyboard shortcuts

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