-
Notifications
You must be signed in to change notification settings - Fork 75
Description
Hi Elliot,
Thank you so much for implementing an awesome module. Your orderedmap module has helped me in two projects.
One of my project's requirement is to get previous and next values when a specific key is provided. Next() and Prev() are implemented for Element. However there is no GetElement method to get a specific Element when a key if provided.
How about adding a GetElement method in orderedmap package?
// GetElement returns the element for a key. If the key does not exist, the
// second return parameter will be false and the pointer will be nil.
func (m *OrderedMap) GetElement(key interface{}) (*Element, bool) {
value, ok := m.kv[key]
if ok {
element := value.Value.(*orderedMapElement)
return &Element{
element: value,
Key: element.key,
Value: element.value,
}, true
}
return nil, false
}
I am currently writing tests for the GetElement method. Thank you for writing detailed tests for the Get method. I'm following those to write tests for GetElement.
If you are fine with adding GetElement method then I'll create a pull request.
Thank you,
Jyoti