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

Method Copy

orderedmap.go:111–119  ·  view source on GitHub ↗

Copy returns a new OrderedMap with the same elements. Using Copy while there are concurrent writes may mangle the result.

()

Source from the content-addressed store, hash-verified

109// Copy returns a new OrderedMap with the same elements.
110// Using Copy while there are concurrent writes may mangle the result.
111func (m *OrderedMap) Copy() *OrderedMap {
112 m2 := NewOrderedMapWithCapacity(m.Len())
113
114 for el := m.Front(); el != nil; el = el.Next() {
115 m2.Set(el.Key, el.Value)
116 }
117
118 return m2
119}
120
121// Has checks if a key exists in the map.
122func (m *OrderedMap) Has(key interface{}) bool {

Callers 3

TestOrderedMap_CopyFunction · 0.95
TestOrderedMap_CopyFunction · 0.95
TestOrderedMap_CopyFunction · 0.95

Calls 5

LenMethod · 0.95
FrontMethod · 0.95
NextMethod · 0.45
SetMethod · 0.45

Tested by 3

TestOrderedMap_CopyFunction · 0.76
TestOrderedMap_CopyFunction · 0.76
TestOrderedMap_CopyFunction · 0.76