rater

package module
v0.1.3 Latest Latest
Warning

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

Go to latest
Published: Feb 3, 2021 License: MIT Imports: 3 Imported by: 0

README

RATER

A thread-safe rating container that can be traversed in order and reverse order according to ratings.

Go Report Card codecov GitHub license Go.Dev reference

Documentation

Overview

Package rater is a sample, thread-safe container, suitable for use in some occasions with grade requirements, e.g: priority ranking

Index

Constants

This section is empty.

Variables

This section is empty.

Functions

This section is empty.

Types

type Rater

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

Rater structure

func NewRater

func NewRater() *Rater

NewRater new container instance.

func (*Rater) ASC

func (r *Rater) ASC(fn func(int, interface{}))

ASC traverses in ascending order of 'rate'.

func (*Rater) DESC

func (r *Rater) DESC(fn func(rate int, val interface{}))

DESC traverses in descending order of 'rate'.

func (*Rater) Len

func (r *Rater) Len() int

Len length of all values

func (*Rater) Pop

func (r *Rater) Pop(val interface{})

Pop a value, if this value is not pushed, nothing will happen.

func (*Rater) Push

func (r *Rater) Push(val interface{}, rate ...int)

Push value, if the 'rate' is not assigned, the default 'rate' is 0, if the value has been Pushed, the original rate will be overwritten.

func (*Rater) Rate added in v0.1.3

func (r *Rater) Rate(rate int, fn func(val interface{}))

Rate iterate over the elements of a 'rate'

Jump to

Keyboard shortcuts

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