sets the value of e to v
(e Hashable, v interface{})
| 28 | |
| 29 | // sets the value of e to v |
| 30 | func (m Map) Set(e Hashable, v interface{}) { |
| 31 | h := e.HashCode() |
| 32 | s, ok := m[h] |
| 33 | if !ok { |
| 34 | s = make([]mapEntry, 0, 1) |
| 35 | } else { |
| 36 | for _, x := range s { |
| 37 | if x.e.EqualI(e) { |
| 38 | x.v = v |
| 39 | return |
| 40 | } |
| 41 | } |
| 42 | } |
| 43 | m[h] = append(s, mapEntry{ |
| 44 | e: e, |
| 45 | v: v, |
| 46 | }) |
| 47 | } |
| 48 | |
| 49 | // adds (e, v) to the map, returns the current value when e already exists |
| 50 | func (m Map) Add(e Hashable, v interface{}) interface{} { |
no test coverage detected