orderedmap icon indicating copy to clipboard operation
orderedmap copied to clipboard

Range

Open tigh-latte opened this issue 2 years ago • 0 comments

Add a Range function for ordered traversal.

I know that #8 is already opened and adds an iterator, however, this solution is both simplified and conforms to a pattern already in Golang, sync.Map.Range.

Usage:

om.Range(func(k string, v interface{}) bool {
	fmt.Printf("key=%s, val=%v\n", k, v)
	return true
})

If a user wants to break, then they can just return false from the passed function.

tigh-latte avatar Aug 22 '23 00:08 tigh-latte