Copy returns a new OrderedMap with the same elements. Using Copy while there are concurrent writes may mangle the result.
()
| 109 | // Copy returns a new OrderedMap with the same elements. |
| 110 | // Using Copy while there are concurrent writes may mangle the result. |
| 111 | func (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. |
| 122 | func (m *OrderedMap) Has(key interface{}) bool { |