randommap

package
v0.0.0-...-5dd4785 Latest Latest
Warning

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

Go to latest
Published: Sep 29, 2020 License: Apache-2.0, BSD-2-Clause Imports: 3 Imported by: 0

Documentation

Index

Constants

This section is empty.

Variables

This section is empty.

Functions

This section is empty.

Types

type RandomMap

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

RandomMap defines a map with extended ability to return a random entry.

func New

func New() *RandomMap

New creates a new random map

func (*RandomMap) Delete

func (rmap *RandomMap) Delete(key interface{}) (result interface{}, exists bool)

Delete removes the mapping for the specified key in the map.

func (*RandomMap) ForEach

func (rmap *RandomMap) ForEach(consumer func(key interface{}, value interface{}))

ForEach iterates through the elements in the map and calls the consumer function for each element.

func (*RandomMap) Get

func (rmap *RandomMap) Get(key interface{}) (result interface{}, exists bool)

Get returns the value to which the specified key is mapped.

func (*RandomMap) Keys

func (rmap *RandomMap) Keys() (result []interface{})

Keys returns the list of keys stored in the RandomMap.

func (*RandomMap) RandomEntry

func (rmap *RandomMap) RandomEntry() (result interface{})

RandomEntry returns a random value from the map.

func (*RandomMap) RandomKey

func (rmap *RandomMap) RandomKey() (result interface{})

RandomKey returns a random key from the map.

func (*RandomMap) Set

func (rmap *RandomMap) Set(key interface{}, value interface{}) (updated bool)

Set associates the specified value with the specified key. If the association already exists, it updates the value.

func (*RandomMap) Size

func (rmap *RandomMap) Size() (result int)

Size returns the number of key-value mappings in the map.

Jump to

Keyboard shortcuts

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