-
Notifications
You must be signed in to change notification settings - Fork 0
/
api.go
27 lines (22 loc) · 831 Bytes
/
api.go
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
// Package map_ provides unordered mutable.Map constructors
package map_
import (
"github.com/m4gshm/gollections/c"
"github.com/m4gshm/gollections/collection/mutable"
)
// Of instantiates a ap from the specified key/value pairs
func Of[K comparable, V any](elements ...c.KV[K, V]) *mutable.Map[K, V] {
return mutable.NewMap(elements...)
}
// Empty instantiates a Map with zero capacity.
func Empty[K comparable, V any]() *mutable.Map[K, V] {
return New[K, V](0)
}
// New instantiates a Map with a predefined capacity.
func New[K comparable, V any](capacity int) *mutable.Map[K, V] {
return mutable.NewMapCap[K, V](capacity)
}
// From instantiates a map with elements obtained by passing the 'loop' function
func From[K comparable, V any](next func() (K, V, bool)) *mutable.Map[K, V] {
return mutable.MapFromLoop(next)
}