maputil

package
v1.5.4 Latest Latest
Warning

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

Go to latest
Published: Mar 31, 2023 License: MIT Imports: 0 Imported by: 1 module, 0 packages

The first number is the count of modules that contain a package that imports this one. The module count is a better indicator of popularity than the package count. A module with 100 importing packages is counted only once instead of 100 times, reflecting the fact that the choice to use the package was likely made only once, not 100 times.
A '?' means that the value hasn't been computed yet.

Documentation

Index

Constants

This section is empty.

Variables

This section is empty.

Functions

func Clear

func Clear[T comparable, U any](m map[T]U)

Clear ... map を空にする

func Has

func Has[T comparable, U any](m map[T]U, key T) bool

Has ... key が存在するかどうか

func Keys

func Keys[T comparable, U any](m map[T]U) []T

Keys ... キーのslice を返す

func NewOrderedSet

func NewOrderedSet[T comparable](s []T) orderedSet[T]

NewOrderedSet ... slice から orderedSet を作成する。orderedSet は Set と違い Keys() の戻り値が挿入した順になります。そのため、uniqなsliceのような扱い方もできます。

func NewSet

func NewSet[T comparable](s []T) set[T]

NewSet ... slice から Set を作成する

func Values

func Values[T comparable, U any](m map[T]U) []U

Values ... 値のslice を返す

func ValuesByKeys

func ValuesByKeys[T comparable, U any](m map[T]U, keys []T) []U

ValuesByKeys ... keys slice の順番で value のslice を返す(map に存在するもののみ)

Types

type JSON

type JSON map[string]any

func (JSON) ToMap

func (j JSON) ToMap() Map[string, any]

ToMap ... JSON 型を Map 型に変換する

type Map

type Map[T comparable, U any] map[T]U

func NewMap

func NewMap[T comparable, U any](m map[T]U) Map[T, U]

NewMap ... Map を作成する

func (Map[T, U]) Clear

func (m Map[T, U]) Clear()

Clear ... Map を空にする

func (Map[T, U]) Delete

func (m Map[T, U]) Delete(key T)

Delete ... キーを削除する

func (Map[T, U]) Has

func (m Map[T, U]) Has(key T) bool

Has ... key が存在するかどうか

func (Map[T, U]) Keys

func (m Map[T, U]) Keys() []T

Keys ... キーのslice を返す

func (Map[T, U]) Len

func (m Map[T, U]) Len() int

Len ... 要素数を返す

func (Map[T, U]) Values

func (m Map[T, U]) Values() []U

Values ... 値のslice を返す

func (Map[T, U]) ValuesByKeys

func (m Map[T, U]) ValuesByKeys(keys []T) []U

ValuesByKeys ... keys slice の順番で value のslice を返す(map に存在するもののみ)

Jump to

Keyboard shortcuts

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