Skip to content

Need GetElement methodΒ #15

@jyotisj

Description

@jyotisj

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

Metadata

Metadata

Assignees

No one assigned

    Labels

    No labels
    No labels

    Projects

    No projects

    Milestone

    No milestone

    Relationships

    None yet

    Development

    No branches or pull requests

    Issue actions