Skip to content

Commit 417c644

Browse files
committed
Add orderedmap.Values() to return underlying map
1 parent 2a68200 commit 417c644

File tree

2 files changed

+16
-0
lines changed

2 files changed

+16
-0
lines changed

orderedmap.go

Lines changed: 4 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -80,6 +80,10 @@ func (o *OrderedMap) Keys() []string {
8080
return o.keys
8181
}
8282

83+
func (o *OrderedMap) Values() map[string]interface{} {
84+
return o.values
85+
}
86+
8387
// SortKeys Sort the map keys using your sort func
8488
func (o *OrderedMap) SortKeys(sortFunc func(keys []string)) {
8589
sortFunc(o.keys)

orderedmap_test.go

Lines changed: 12 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -3,6 +3,7 @@ package orderedmap
33
import (
44
"encoding/json"
55
"fmt"
6+
"reflect"
67
"sort"
78
"strings"
89
"testing"
@@ -70,6 +71,17 @@ func TestOrderedMap(t *testing.T) {
7071
t.Error("Keys method", key, "!=", expectedKeys[i])
7172
}
7273
}
74+
// Values method
75+
values := o.Values()
76+
expectedValues := map[string]interface{}{
77+
"number": 4,
78+
"string": "x",
79+
"strings": []string{"t", "u"},
80+
"mixed": []interface{}{ 1, "1" },
81+
}
82+
if !reflect.DeepEqual(values, expectedValues) {
83+
t.Error("Values method returned unexpected map")
84+
}
7385
// delete
7486
o.Delete("strings")
7587
o.Delete("not a key being used")

0 commit comments

Comments
 (0)