elliotchance / orderedmap

🔃 An ordered map in Go with amortized O(1) for Set, Get, Delete and Len.
MIT License
849 stars 63 forks source link

Implement Go 1.23 iterators #41

Closed thiagokokada closed 2 months ago

thiagokokada commented 2 months ago

Close issue: https://github.com/elliotchance/orderedmap/issues/40.

This PR implements Iterator() and ReverseIterator() methods, that allow usage with for ... range in Go 1.23:

for key, value := range m.Iterator() {
    fmt.Println(key, value)
}

for key, value := range m.ReverseIterator() {
    fmt.Println(key, value)
}

This change is Reviewable