String returns the map as a string, only hashed keys are printed.
()
| 198 | |
| 199 | // String returns the map as a string, only hashed keys are printed. |
| 200 | func (m *Map[Key, Value]) String() string { |
| 201 | buffer := bytes.NewBufferString("") |
| 202 | buffer.WriteRune('[') |
| 203 | |
| 204 | first := m.linkedList.First() |
| 205 | item := first |
| 206 | |
| 207 | for item != nil { |
| 208 | if item != first { |
| 209 | buffer.WriteRune(',') |
| 210 | } |
| 211 | fmt.Fprint(buffer, item.keyHash) |
| 212 | item = item.Next() |
| 213 | } |
| 214 | buffer.WriteRune(']') |
| 215 | return buffer.String() |
| 216 | } |
| 217 | |
| 218 | // Range calls f sequentially for each key and value present in the map. |
| 219 | // If f returns false, range stops the iteration. |