Skip to content

Commit

Permalink
fix orderMap set method
Browse files Browse the repository at this point in the history
  • Loading branch information
tarunKoyalwar committed Jun 28, 2023
1 parent da6ed76 commit 96f8f2c
Showing 1 changed file with 3 additions and 1 deletion.
4 changes: 3 additions & 1 deletion maps/ordered_map.go
Original file line number Diff line number Diff line change
Expand Up @@ -13,8 +13,10 @@ type OrderedMap[k comparable, v any] struct {

// Set sets a value in the OrderedMap (if the key already exists, it will be overwritten)
func (o *OrderedMap[k, v]) Set(key k, value v) {
if _, ok := o.m[key]; !ok {
o.keys = append(o.keys, key)
}
o.m[key] = value
o.keys = append(o.keys, key)
}

// Get gets a value from the OrderedMap
Expand Down

0 comments on commit 96f8f2c

Please sign in to comment.