wk8 / go-ordered-map

Optimal implementation of ordered maps for Golang - ie maps that remember the order in which keys were inserted.
Apache License 2.0
534 stars 40 forks source link

Add alias function Load and Store, Expose Move function from list.List #6

Closed KusakabeShi closed 2 years ago

KusakabeShi commented 2 years ago
  1. Add alias function Load and Store sync.Map uses Load/Store but this uses Get() and Set(), so I added alias to make the API more consistency.

  2. Expose Move* function from list.List so that users cam move the order of the element in orderedMap directly.

    om := New()
    om.Set("1", "bar")
    om.Set(2, 28)
    om.Set(3, 100)
    om.Set("4", "baz")
    om.Set(5, "28")
    om.Set(6, "100")
    om.Set("7", "baz")
    om.Set("8", "baz")
    
    om.MoveAfter(2, 3)
    om.MoveBefore(6, "4")
        om.MoveToBack(3)
    om.MoveToFront(5)
justincpresley commented 2 years ago

Looking into this module. There are some other functions on top of these functions that I would like to either add myself or have someone be willing to.

Could we have this pull request be reviewed?

wk8 commented 2 years ago

Thanks for the PR!