Documentation
¶
Overview ¶
Package zset provides a concurrent, ranked sorted set implemented in pure Go.
Index ¶
- Constants
- type ZSet
- func (z *ZSet) Add(score float64, member string)
- func (z *ZSet) Count() int
- func (z *ZSet) Dump()
- func (z *ZSet) Limit(count int) int
- func (z *ZSet) Range(first, last int) []string
- func (z *ZSet) RangeByScore(first, last float64) []string
- func (z *ZSet) Rank(member string) int
- func (z *ZSet) Rem(member string)
- func (z *ZSet) RevLimit(count int) int
- func (z *ZSet) RevRange(first, last int) []string
- func (z *ZSet) RevRank(member string) int
- func (z *ZSet) Score(member string) (float64, bool)
Constants ¶
const DEFAULT_TBL_LEN = 16
DEFAULT_TBL_LEN is the initial member-index capacity, retained for compatibility.
Variables ¶
This section is empty.
Functions ¶
This section is empty.
Types ¶
type ZSet ¶
type ZSet struct {
// contains filtered or unexported fields
}
ZSet sorts by score ascending, then member bytes ascending. Methods are safe concurrently; each query and trim observes one locked state. The zero value works. Do not copy a ZSet after first use.
func New ¶
func New() *ZSet
New creates an empty set. No C compiler, finalizer or explicit Close is needed.
func (*ZSet) Add ¶
Add inserts a member or updates its score. NaN panics before changing the set; infinities are supported. Updating a member reuses its allocated node/tower.
func (*ZSet) Dump ¶
func (z *ZSet) Dump()
Dump prints a diagnostic snapshot to stdout. The text format is not an API.
func (*ZSet) Limit ¶
Limit retains the lowest count members, returning the number removed. A negative count is treated as zero. The entire trim is atomic.
func (*ZSet) Range ¶
Range returns an inclusive, 1-based rank range. first>last walks backwards from first. Nonpositive ranks return nil; an out-of-set first returns empty. Endpoints beyond the end are bounded without allocating for the excess range.
func (*ZSet) RangeByScore ¶
RangeByScore returns the inclusive score range, descending when first>last. NaN bounds return an empty slice. Equal scores are ordered by member bytes.
func (*ZSet) RevLimit ¶
RevLimit retains the highest count members, returning the number removed. A negative count is treated as zero. The entire trim is atomic.
func (*ZSet) RevRange ¶
RevRange uses 1-based ranks counted from the largest member. An end beyond Count is clamped. Reversing the endpoints reverses traversal direction.