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)
| 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. |
| 706 | func 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. |
| 717 | func (m *Map[K, V]) Len() int { |
searching dependent graphs…