Hi. I've been looking at using this in go-task instead of our naive implementation. Would you be open to a PR that added the ability to easily create an ordered map containing a set of initial data? since OrderedMap.kv and OrderedMap.ll are not exported, it is not possible to create an inline structure. I've been using .Set() for this instead, but this can be quite cumbersome when writing table-tests or similar.
I was thinking something along the lines of:
func NewOrderedMapWithElements[K comparable, V any](els ...*Element[K, V]) *OrderedMap[K, V] {
om := &OrderedMap[K, V]{
kv: make(map[K]*Element[K, V], len(els)),
}
for _, el := range els {
om.Set(el.Key, el.Value)
}
return om
}
Or perhaps something using the functional options pattern if you prefer. If you're open to this, I'm happy to open a PR.
Hi. I've been looking at using this in go-task instead of our naive implementation. Would you be open to a PR that added the ability to easily create an ordered map containing a set of initial data? since
OrderedMap.kv
andOrderedMap.ll
are not exported, it is not possible to create an inline structure. I've been using.Set()
for this instead, but this can be quite cumbersome when writing table-tests or similar.I was thinking something along the lines of:
Or perhaps something using the functional options pattern if you prefer. If you're open to this, I'm happy to open a PR.