MCPcopy Create free account
hub / github.com/elliotchance/orderedmap / Set

Method Set

orderedmap.go:36–46  ·  view source on GitHub ↗

Set will set (or replace) a value for a key. If the key was new, then true will be returned. The returned value will be false if the value was replaced (even if the value was the same).

(key, value interface{})

Source from the content-addressed store, hash-verified

34// will be returned. The returned value will be false if the value was replaced
35// (even if the value was the same).
36func (m *OrderedMap) Set(key, value interface{}) bool {
37 _, alreadyExist := m.kv[key]
38 if alreadyExist {
39 m.kv[key].Value = value
40 return false
41 }
42
43 element := m.ll.PushBack(key, value)
44 m.kv[key] = element
45 return true
46}
47
48// GetOrDefault returns the value for a key. If the key does not exist, returns
49// the default value instead.

Callers 15

TestGetFunction · 0.95
TestSetFunction · 0.95
TestLenFunction · 0.95
TestKeysFunction · 0.95
TestDeleteFunction · 0.95
TestOrderedMap_FrontFunction · 0.95
TestOrderedMap_BackFunction · 0.95
TestOrderedMap_CopyFunction · 0.95
TestGetElementFunction · 0.95
TestOrderedMap_HasFunction · 0.95
benchmarkOrderedMap_SetFunction · 0.95
benchmarkOrderedMap_GetFunction · 0.95

Calls 1

PushBackMethod · 0.45

Tested by 15

TestGetFunction · 0.76
TestSetFunction · 0.76
TestLenFunction · 0.76
TestKeysFunction · 0.76
TestDeleteFunction · 0.76
TestOrderedMap_FrontFunction · 0.76
TestOrderedMap_BackFunction · 0.76
TestOrderedMap_CopyFunction · 0.76
TestGetElementFunction · 0.76
TestOrderedMap_HasFunction · 0.76
benchmarkOrderedMap_SetFunction · 0.76
benchmarkOrderedMap_GetFunction · 0.76