Documentation
¶
Index ¶
- Constants
- type GetByScoreRangeOptions
- type SCORE
- type SortedSet
- func (ss *SortedSet) FindRank(key string) int
- func (ss *SortedSet) FindRevRank(key string) int
- func (ss *SortedSet) GetByKey(key string) *SortedSetNode
- func (ss *SortedSet) GetByRank(rank int, remove bool) *SortedSetNode
- func (ss *SortedSet) GetByRankRange(start, end int, remove bool) []*SortedSetNode
- func (ss *SortedSet) GetByScoreRange(start SCORE, end SCORE, options *GetByScoreRangeOptions) []*SortedSetNode
- func (ss *SortedSet) PeekMax() *SortedSetNode
- func (ss *SortedSet) PeekMin() *SortedSetNode
- func (ss *SortedSet) PopMax() *SortedSetNode
- func (ss *SortedSet) PopMin() *SortedSetNode
- func (ss *SortedSet) Put(key string, score SCORE, value []byte) error
- func (ss *SortedSet) Remove(key string) *SortedSetNode
- func (ss *SortedSet) Size() int
- type SortedSetLevel
- type SortedSetNode
Constants ¶
const ( // SkipListMaxLevel represents the skipList max level number. SkipListMaxLevel = 32 // SkipListP represents the p parameter of the skipList. SkipListP = 0.25 )
Variables ¶
This section is empty.
Functions ¶
This section is empty.
Types ¶
type GetByScoreRangeOptions ¶
type GetByScoreRangeOptions struct { Limit int // limit the max nodes to return ExcludeStart bool // exclude start value, so it search in interval (start, end] or (start, end) ExcludeEnd bool // exclude end value, so it search in interval [start, end) or (start, end) }
GetByScoreRangeOptions represents the options of the GetByScoreRange function.
type SortedSet ¶
type SortedSet struct { Dict map[string]*SortedSetNode // contains filtered or unexported fields }
SortedSet represents the sorted set.
func New ¶
func New() *SortedSet
New returns a newly initialized SortedSet Object that implements the SortedSet.
func (*SortedSet) FindRank ¶
FindRank Returns the rank of member in the sorted set stored at key, with the scores ordered from low to high. Note that the rank is 1-based integer. Rank 1 means the first node If the node is not found, 0 is returned. Otherwise rank(> 0) is returned.
Time complexity of this method is : O(log(N)).
func (*SortedSet) FindRevRank ¶
FindRevRank Returns the rank of member in the sorted set stored at key, with the scores ordered from high to low.
func (*SortedSet) GetByKey ¶
func (ss *SortedSet) GetByKey(key string) *SortedSetNode
GetByKey returns the node at given key. If node is not found, nil is returned
Time complexity : O(1).
func (*SortedSet) GetByRank ¶
func (ss *SortedSet) GetByRank(rank int, remove bool) *SortedSetNode
GetByRank returns the node at given rank. Note that the rank is 1-based integer. Rank 1 means the first node; Rank -1 means the last node. If remove is true, the returned nodes are removed If node is not found at specific rank, nil is returned.
Time complexity of this method is : O(log(N)).
func (*SortedSet) GetByRankRange ¶
func (ss *SortedSet) GetByRankRange(start, end int, remove bool) []*SortedSetNode
GetByRankRange returns nodes within specific rank range [start, end]. Note that the rank is 1-based integer. Rank 1 means the first node; Rank -1 means the last node If start is greater than end, the returned array is in reserved order If remove is true, the returned nodes are removed.
Time complexity of this method is : O(log(N)).
func (*SortedSet) GetByScoreRange ¶
func (ss *SortedSet) GetByScoreRange(start SCORE, end SCORE, options *GetByScoreRangeOptions) []*SortedSetNode
GetByScoreRange returns the nodes whose score within the specific range. If options is nil, it searches in interval [start, end] without any limit by default.
Time complexity of this method is : O(log(N)).
func (*SortedSet) PeekMax ¶
func (ss *SortedSet) PeekMax() *SortedSetNode
PeekMax returns the element with maximum score, nil if the set is empty.
Time Complexity : O(1).
func (*SortedSet) PeekMin ¶
func (ss *SortedSet) PeekMin() *SortedSetNode
PeekMin returns the element with minimum score, nil if the set is empty.
Time complexity of this method is : O(log(N)).
func (*SortedSet) PopMax ¶
func (ss *SortedSet) PopMax() *SortedSetNode
PopMax returns and remove the element with maximum score, nil if the set is empty.
Time complexity of this method is : O(log(N)).
func (*SortedSet) PopMin ¶
func (ss *SortedSet) PopMin() *SortedSetNode
PopMin returns and remove the element with minimal score, nil if the set is empty.
Time complexity of this method is : O(log(N)).
func (*SortedSet) Put ¶
Put puts an element into the sorted set with specific key / value / score.
Time complexity of this method is : O(log(N)).
func (*SortedSet) Remove ¶
func (ss *SortedSet) Remove(key string) *SortedSetNode
Remove removes element specified at given key.
Time complexity of this method is : O(log(N)).
type SortedSetLevel ¶
type SortedSetLevel struct {
// contains filtered or unexported fields
}
SortedSetLevel records forward and span.
type SortedSetNode ¶
type SortedSetNode struct { Value []byte // associated data // contains filtered or unexported fields }
SortedSetNode represents a node in the SortedSet.
func (*SortedSetNode) Score ¶
func (ssn *SortedSetNode) Score() SCORE
Score returns the score of the node.