Delete deletes the value found under the given key.
(key string)
| 80 | |
| 81 | // Delete deletes the value found under the given key. |
| 82 | func (m *Map) Delete(key string) *Map { |
| 83 | // Delete the data entry. |
| 84 | delete(m.data, key) |
| 85 | |
| 86 | // Remove the item from the keys. |
| 87 | foundIndex := -1 |
| 88 | for i, k := range m.keys { |
| 89 | if k == key { |
| 90 | foundIndex = i |
| 91 | break |
| 92 | } |
| 93 | } |
| 94 | |
| 95 | if foundIndex >= 0 { |
| 96 | m.keys = append((m.keys)[:foundIndex], (m.keys)[foundIndex+1:]...) |
| 97 | } |
| 98 | |
| 99 | return m |
| 100 | } |
| 101 | |
| 102 | // KeyValues returns the KeyValue pairs within the map, in the order that they were added. |
| 103 | func (m *Map) KeyValues() []KeyValue { |
no outgoing calls