deckarep / golang-set

A simple, battle-tested and generic set type for the Go language. Trusted by Docker, 1Password, Ethereum and Hashicorp.
Other
4.15k stars 274 forks source link

iterate with random sequence? #107

Closed ZhengQiushi closed 1 year ago

ZhengQiushi commented 1 year ago

it := join_seq.Iterator() for elem := range it.C { }

Following your document, I use the iterator to scan the set, but the result will be random... and is not the fixed sequence in data.s

deckarep commented 1 year ago

If I understand your question, order is not guaranteed when iterating the sets.

The primary reason is because the implementation is backed by a map and Go map’s don’t provide any guaranteed order when iterating over the key/values.