MCPcopy Create free account
hub / github.com/benbjohnson/immutable / NewMapOf

Function NewMapOf

immutable.go:706–714  ·  view source on GitHub ↗

NewMapOf returns a new instance of Map, containing a map of provided entries. If hasher is nil, a default hasher implementation will automatically be chosen based on the first key added. Default hasher implementations only exist for int, string, and byte slice types.

(hasher Hasher[K], entries map[K]V)

Source from the content-addressed store, hash-verified

704// If hasher is nil, a default hasher implementation will automatically be chosen based on the first key added.
705// Default hasher implementations only exist for int, string, and byte slice types.
706func NewMapOf[K comparable, V any](hasher Hasher[K], entries map[K]V) *Map[K, V] {
707 m := &Map[K, V]{
708 hasher: hasher,
709 }
710 for k, v := range entries {
711 m.set(k, v, true)
712 }
713 return m
714}
715
716// Len returns the number of elements in the map.
717func (m *Map[K, V]) Len() int {

Callers 1

TestMap_SetFunction · 0.85

Calls 1

setMethod · 0.65

Tested by 1

TestMap_SetFunction · 0.68

Used in the wild real call sites across dependent graphs

searching dependent graphs…