Documentation ¶
Index ¶
Examples ¶
Constants ¶
This section is empty.
Variables ¶
This section is empty.
Functions ¶
This section is empty.
Types ¶
type OrderedMap ¶
OrderedMap is a map that can be iterated in the natural order of its keys.
TODO implement json.Marshaler and json.Unmarshaler?
Example ¶
m := OrderedMap[int, string]{} m[2] = "two" m[3] = "three" m[1] = "one" m[5] = "five" m[0] = "zero" m[4] = "four" m.Iterate(func(k int, v string) bool { fmt.Println(v) return k != 4 })
Output: zero one two three four
func (OrderedMap[K, V]) Iterate ¶
func (m OrderedMap[K, V]) Iterate(iterator func(key K, value V) bool)
Iterate iterates over the keys of the OrderedMap in natural sort order. If the iterator returns false, iteration is aborted (like the break keyword).
Iterate is not safe for concurrent modification.
Click to show internal directories.
Click to hide internal directories.