util

package
v0.0.0-...-180b4dd Latest Latest
Warning

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

Go to latest
Published: Sep 17, 2017 License: MIT Imports: 5 Imported by: 0

Documentation

Index

Constants

This section is empty.

Variables

This section is empty.

Functions

func Call

func Call(srv gfs.ServerAddress, rpcname string, args interface{}, reply interface{}) error

Call is RPC call helper

func CallAll

func CallAll(dst []gfs.ServerAddress, rpcname string, args interface{}) error

CallAll applies the rpc call to all destinations.

func Sample

func Sample(n, k int) ([]int, error)

Sample randomly chooses k elements from {0, 1, ..., n-1}. n should not be less than k.

Types

type ArraySet

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

ArraySet is a set implemented using array. I suppose it'll provide better performance than golang builtin map when the set is really really small. It is thread-safe since a mutex is used.

func (*ArraySet) Add

func (s *ArraySet) Add(element interface{})

Add adds an element to the set.

func (*ArraySet) Delete

func (s *ArraySet) Delete(element interface{})

Delete delete an element in the set.

func (*ArraySet) GetAll

func (s *ArraySet) GetAll() []interface{}

GetAll returns all elements of the set.

func (*ArraySet) GetAllAndClear

func (s *ArraySet) GetAllAndClear() []interface{}

GetAllAndClear returns all elements of the set.

func (*ArraySet) RandomPick

func (s *ArraySet) RandomPick() interface{}

RandomPick picks a random element from the set.

func (*ArraySet) Size

func (s *ArraySet) Size() int

Size returns the size of the set.

Jump to

Keyboard shortcuts

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