Basic usage of OrderedMap
masterAn *OrderedMap is a high-performance ordered map that maintains amortized O(1) complexity for Set, Get, Delete, and Len. It is implemented using a standard Go map combined with a trimmed-down linked list to preserve insertion order.
Version Compatibility:
- v3: Requires Go v1.23+.
- v2: Requires Go v1.18+ (for generics support).
- v1: Supports Go v1.17 and below.
import "github.com/elliotchance/orderedmap/v3"
func main() {
m := orderedmap.NewOrderedMap[string, any]()
m.Set("foo", "bar")
m.Set("qux", 1.23)
m.Set("123", true)
m.Delete("qux")
}