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

Function NewSortedMapOf

immutable.go:1595–1603  ·  view source on GitHub ↗

NewSortedMapOf returns a new instance of SortedMap, containing a map of provided entries. If comparer is nil then a default comparer is set after the first key is inserted. Default comparers exist for int, string, and byte slice keys.

(comparer Comparer[K], entries map[K]V)

Source from the content-addressed store, hash-verified

1593// If comparer is nil then a default comparer is set after the first key is inserted. Default comparers
1594// exist for int, string, and byte slice keys.
1595func NewSortedMapOf[K comparable, V any](comparer Comparer[K], entries map[K]V) *SortedMap[K, V] {
1596 m := &SortedMap[K, V]{
1597 comparer: comparer,
1598 }
1599 for k, v := range entries {
1600 m.set(k, v, true)
1601 }
1602 return m
1603}
1604
1605// Len returns the number of elements in the sorted map.
1606func (m *SortedMap[K, V]) Len() int {

Callers

nothing calls this directly

Calls 1

setMethod · 0.65

Tested by

no test coverage detected

Used in the wild real call sites across dependent graphs

searching dependent graphs…