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

Method Set

v2/orderedmap.go:44–54  ·  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 K, value V)

Source from the content-addressed store, hash-verified

42// will be returned. The returned value will be false if the value was replaced
43// (even if the value was the same).
44func (m *OrderedMap[K, V]) Set(key K, value V) bool {
45 _, alreadyExist := m.kv[key]
46 if alreadyExist {
47 m.kv[key].Value = value
48 return false
49 }
50
51 element := m.ll.PushBack(key, value)
52 m.kv[key] = element
53 return true
54}
55
56// ReplaceKey replaces an existing key with a new key while preserving order of
57// the value. This function will return true if the operation was successful, or

Callers 6

TestOrderedMap_CopyFunction · 0.45
CopyMethod · 0.45
TestOrderedMap_CopyFunction · 0.45

Calls 1

PushBackMethod · 0.45

Tested by 4

TestOrderedMap_CopyFunction · 0.36
TestOrderedMap_CopyFunction · 0.36