sortedset

package
v1.2.3 Latest Latest
Warning

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

Go to latest
Published: May 9, 2021 License: GPL-3.0 Imports: 3 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
}

type Level

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

level aspect of a Node

type Node

type Node struct {
	Element
	// contains filtered or unexported fields
}

type ScoreBorder

type ScoreBorder struct {
	Inf     int8
	Value   float64
	Exclude bool
}

func ParseScoreBorder

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

type SortedSet

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

func Make

func Make() *SortedSet

func (*SortedSet) Add

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

* return: has inserted new node

func (*SortedSet) Count

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

func (*SortedSet) ForEach

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

*

  • traverse [start, stop), 0-based rank

func (*SortedSet) ForEachByScore

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

func (*SortedSet) Get

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

func (*SortedSet) GetRank

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

*

  • get 0-based rank

func (*SortedSet) Len

func (sortedSet *SortedSet) Len() int64

func (*SortedSet) Range

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

*

  • return [start, stop), 0-based rank
  • assert start in [0, size), stop in [start, size]

func (*SortedSet) RangeByScore

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

* param limit: <0 means no limit

func (*SortedSet) Remove

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

func (*SortedSet) RemoveByRank

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

* 0-based rank, [start, stop)

func (*SortedSet) RemoveByScore

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

Jump to

Keyboard shortcuts

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